s3: Remove a bunch of calls to procid_self()
[samba.git] / source3 / utils / smbcontrol.c
index 04aeb8d6bd5452b46f1de11afc19ac7cef9c22b5..747c35ceba44b6f3e54f512a68b570b1dbbb88f3 100644 (file)
 #include "includes.h"
 #include "system/filesys.h"
 #include "popt_common.h"
-#include "librpc/gen_ndr/messaging.h"
 #include "librpc/gen_ndr/spoolss.h"
 #include "nt_printing.h"
 #include "printing/notify.h"
 #include "libsmb/nmblib.h"
 #include "messages.h"
+#include "util_tdb.h"
 
 #if HAVE_LIBUNWIND_H
 #include <libunwind.h>
@@ -64,7 +64,7 @@ static bool send_message(struct messaging_context *msg_ctx,
        if (procid_to_pid(&pid) != 0)
                return NT_STATUS_IS_OK(
                        messaging_send_buf(msg_ctx, pid, msg_type,
-                                          (uint8 *)buf, len));
+                                          (const uint8 *)buf, len));
 
        ret = message_send_all(msg_ctx, msg_type, buf, len, &n_sent);
        DEBUG(10,("smbcontrol/send_message: broadcast message to "
@@ -119,7 +119,7 @@ static void print_pid_string_cb(struct messaging_context *msg,
 {
        char *pidstr;
 
-       pidstr = procid_str(talloc_tos(), &pid);
+       pidstr = server_id_str(talloc_tos(), &pid);
        printf("PID %s: %.*s", pidstr, (int)data->length,
               (const char *)data->data);
        TALLOC_FREE(pidstr);
@@ -197,13 +197,13 @@ static bool do_idmap(struct messaging_context *msg_ctx,
        }
 
        if (strcmp(argv[1], "flush") == 0) {
-               msg_type = MSG_IDMAP_FLUSH;
+               msg_type = ID_CACHE_FLUSH;
        }
        else if (strcmp(argv[1], "delete") == 0) {
-               msg_type = MSG_IDMAP_DELETE;
+               msg_type = ID_CACHE_DELETE;
        }
        else if (strcmp(argv[1], "kill") == 0) {
-               msg_type = MSG_IDMAP_KILL;
+               msg_type = ID_CACHE_KILL;
        }
        else if (strcmp(argv[1], "help") == 0) {
                fprintf(stdout, "%s", usage);
@@ -433,7 +433,7 @@ static void pong_cb(struct messaging_context *msg,
                    struct server_id pid,
                    DATA_BLOB *data)
 {
-       char *src_string = procid_str(NULL, &pid);
+       char *src_string = server_id_str(NULL, &pid);
        printf("PONG from pid %s\n", src_string);
        TALLOC_FREE(src_string);
        num_replies++;
@@ -749,7 +749,7 @@ static bool do_printnotify(struct messaging_context *msg_ctx,
 
                notify_printer_byname(messaging_event_context(msg_ctx),
                                      msg_ctx, argv[2], attribute,
-                                     CONST_DISCARD(char *, argv[4]));
+                                     discard_const_p(char, argv[4]));
 
                goto send;
        }
@@ -954,10 +954,10 @@ static bool do_winbind_online(struct messaging_context *msg_ctx,
        /* Remove the entry in the winbindd_cache tdb to tell a later
           starting winbindd that we're online. */
 
-       tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
+       tdb = tdb_open_log(state_path("winbindd_cache.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
        if (!tdb) {
                fprintf(stderr, "Cannot open the tdb %s for writing.\n",
-                       cache_path("winbindd_cache.tdb"));
+                       state_path("winbindd_cache.tdb"));
                return False;
        }
 
@@ -984,14 +984,14 @@ static bool do_winbind_offline(struct messaging_context *msg_ctx,
           starting winbindd that we're offline. We may actually create
           it here... */
 
-       tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
+       tdb = tdb_open_log(state_path("winbindd_cache.tdb"),
                                WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE,
                                TDB_DEFAULT|TDB_INCOMPATIBLE_HASH /* TDB_CLEAR_IF_FIRST */,
                                O_RDWR|O_CREAT, 0600);
 
        if (!tdb) {
                fprintf(stderr, "Cannot open the tdb %s for writing.\n",
-                       cache_path("winbindd_cache.tdb"));
+                       state_path("winbindd_cache.tdb"));
                return False;
        }
 
@@ -1143,7 +1143,7 @@ static void winbind_validate_cache_cb(struct messaging_context *msg,
                                      struct server_id pid,
                                      DATA_BLOB *data)
 {
-       char *src_string = procid_str(NULL, &pid);
+       char *src_string = server_id_str(NULL, &pid);
        printf("Winbindd cache is %svalid. (answer from pid %s)\n",
               (*(data->data) == 0 ? "" : "NOT "), src_string);
        TALLOC_FREE(src_string);
@@ -1202,7 +1202,7 @@ static void my_make_nmb_name( struct nmb_name *n, const char *name, int type)
        strupper_m(unix_name);
        push_ascii(n->name, unix_name, sizeof(n->name), STR_TERMINATE);
        n->name_type = (unsigned int)type & 0xFF;
-       push_ascii(n->scope,  global_scope(), 64, STR_TERMINATE);
+       push_ascii(n->scope,  lp_netbios_scope(), 64, STR_TERMINATE);
 }
 
 static bool do_nodestatus(struct messaging_context *msg_ctx,
@@ -1471,14 +1471,14 @@ int main(int argc, const char **argv)
        if (argc <= 1)
                usage(pc);
 
-       lp_load(get_dyn_CONFIGFILE(),False,False,False,True);
+       lp_load_global(get_dyn_CONFIGFILE());
 
        /* Need to invert sense of return code -- samba
          * routines mostly return True==1 for success, but
          * shell needs 0. */ 
 
        if (!(evt_ctx = tevent_context_init(NULL)) ||
-           !(msg_ctx = messaging_init(NULL, procid_self(), evt_ctx))) {
+           !(msg_ctx = messaging_init(NULL, evt_ctx))) {
                fprintf(stderr, "could not init messaging context\n");
                TALLOC_FREE(frame);
                exit(1);