Merge branch 'master' of ssh://git.samba.org/data/git/samba
[kai/samba.git] / source3 / utils / smbcontrol.c
index 9d571f7ee39c7e62795fa5b62dcafd51b2be934e..fc7d0aa360f87ef1364be37440b8b4d6caef664a 100644 (file)
@@ -65,10 +65,10 @@ static bool send_message(struct messaging_context *msg_ctx,
        return ret;
 }
 
-static void timeout_handler(struct event_context *event_ctx,
-                           struct timed_event *te,
-                           const struct timeval *now,
-                           void *private_data)
+static void smbcontrol_timeout(struct tevent_context *event_ctx,
+                              struct tevent_timer *te,
+                              struct timeval now,
+                              void *private_data)
 {
        bool *timed_out = (bool *)private_data;
        TALLOC_FREE(te);
@@ -80,22 +80,24 @@ static void timeout_handler(struct event_context *event_ctx,
 static void wait_replies(struct messaging_context *msg_ctx,
                         bool multiple_replies)
 {
-       struct timed_event *te;
+       struct tevent_timer *te;
        bool timed_out = False;
 
-       if (!(te = event_add_timed(messaging_event_context(msg_ctx), NULL,
-                                  timeval_current_ofs(timeout, 0),
-                                  "smbcontrol_timeout",
-                                  timeout_handler, (void *)&timed_out))) {
-               DEBUG(0, ("event_add_timed failed\n"));
+       if (!(te = tevent_add_timer(messaging_event_context(msg_ctx), NULL,
+                                   timeval_current_ofs(timeout, 0),
+                                   smbcontrol_timeout, (void *)&timed_out))) {
+               DEBUG(0, ("tevent_add_timer failed\n"));
                return;
        }
 
        while (!timed_out) {
-               message_dispatch(msg_ctx);
+               int ret;
                if (num_replies > 0 && !multiple_replies)
                        break;
-               event_loop_once(messaging_event_context(msg_ctx));
+               ret = tevent_loop_once(messaging_event_context(msg_ctx));
+               if (ret != 0) {
+                       break;
+               }
        }
 }
 
@@ -667,11 +669,11 @@ static bool do_printnotify(struct messaging_context *msg_ctx,
                }
 
                if (strcmp(argv[3], "comment") == 0) {
-                       attribute = PRINTER_NOTIFY_COMMENT;
+                       attribute = PRINTER_NOTIFY_FIELD_COMMENT;
                } else if (strcmp(argv[3], "port") == 0) {
-                       attribute = PRINTER_NOTIFY_PORT_NAME;
+                       attribute = PRINTER_NOTIFY_FIELD_PORT_NAME;
                } else if (strcmp(argv[3], "driver") == 0) {
-                       attribute = PRINTER_NOTIFY_DRIVER_NAME;
+                       attribute = PRINTER_NOTIFY_FIELD_DRIVER_NAME;
                } else {
                        fprintf(stderr, "Invalid printer command '%s'\n",
                                argv[3]);
@@ -868,10 +870,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(lock_path("winbindd_cache.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
+       tdb = tdb_open_log(cache_path("winbindd_cache.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600);
        if (!tdb) {
                fprintf(stderr, "Cannot open the tdb %s for writing.\n",
-                       lock_path("winbindd_cache.tdb"));
+                       cache_path("winbindd_cache.tdb"));
                return False;
        }
 
@@ -898,13 +900,13 @@ 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(lock_path("winbindd_cache.tdb"),
+       tdb = tdb_open_log(cache_path("winbindd_cache.tdb"),
                                WINBINDD_CACHE_TDB_DEFAULT_HASH_SIZE,
                                TDB_DEFAULT /* TDB_CLEAR_IF_FIRST */, O_RDWR|O_CREAT, 0600);
 
        if (!tdb) {
                fprintf(stderr, "Cannot open the tdb %s for writing.\n",
-                       lock_path("winbindd_cache.tdb"));
+                       cache_path("winbindd_cache.tdb"));
                return False;
        }
 
@@ -1325,7 +1327,7 @@ int main(int argc, const char **argv)
 {
        poptContext pc;
        int opt;
-       struct event_context *evt_ctx;
+       struct tevent_context *evt_ctx;
        struct messaging_context *msg_ctx;
 
        static struct poptOption long_options[] = {
@@ -1388,7 +1390,7 @@ int main(int argc, const char **argv)
          * routines mostly return True==1 for success, but
          * shell needs 0. */ 
        
-       if (!(evt_ctx = event_context_init(NULL)) ||
+       if (!(evt_ctx = tevent_context_init(NULL)) ||
            !(msg_ctx = messaging_init(NULL, server_id_self(), evt_ctx))) {
                fprintf(stderr, "could not init messaging context\n");
                TALLOC_FREE(frame);