]> git.meshlink.io Git - catta/blobdiff - avahi-common/watch-test.c
* split dbus-protocol.c in multiple sources files
[catta] / avahi-common / watch-test.c
index af46805cdde0fd3739747f57f2889aeb29ad7ef8..cd70117574d38249ffd1a7edb18a96051e6292b1 100644 (file)
 #include "watch.h"
 #include "simple-watch.h"
 #include "timeval.h"
+#include "gccmacro.h"
 
-static AvahiPoll *api = NULL;
+static const AvahiPoll *api = NULL;
 static AvahiSimplePoll *simple_poll = NULL;
 
-static void callback(AvahiWatch *w, int fd, AvahiWatchEvent event, void *userdata) {
+static void callback(AvahiWatch *w, int fd, AvahiWatchEvent event, AVAHI_GCC_UNUSED void *userdata) {
 
     if (event & AVAHI_WATCH_IN) {
         ssize_t r;
@@ -52,7 +53,7 @@ static void callback(AvahiWatch *w, int fd, AvahiWatchEvent event, void *userdat
     }
 }
 
-static void wakeup(AvahiPoll *_api, void *userdata) {
+static void wakeup(AvahiTimeout *t, AVAHI_GCC_UNUSED void *userdata) {
     static int i = 0;
     struct timeval tv;
 
@@ -62,11 +63,11 @@ static void wakeup(AvahiPoll *_api, void *userdata) {
         avahi_simple_poll_quit(simple_poll);
     else {
         avahi_elapse_time(&tv, 1000, 0);
-        api->set_wakeup(api, &tv, wakeup, NULL);
+        api->timeout_update(t, &tv);
     }
 }
 
-int main(int argc, char *argv[]) {
+int main(AVAHI_GCC_UNUSED int argc, AVAHI_GCC_UNUSED char *argv[]) {
     struct timeval tv;
     
     simple_poll = avahi_simple_poll_new();
@@ -75,12 +76,13 @@ int main(int argc, char *argv[]) {
     api->watch_new(api, 0, AVAHI_WATCH_IN, callback, NULL);
 
     avahi_elapse_time(&tv, 1000, 0);
-    api->set_wakeup(api, &tv, wakeup, NULL);
+    api->timeout_new(api, &tv, wakeup, NULL);
 
     /* Our main loop */
-    for (;;)
-        if (avahi_simple_poll_iterate(simple_poll, -1) != 0)
-            break;
+    avahi_simple_poll_loop(simple_poll);
+
+
+    avahi_simple_poll_free(simple_poll);
     
     return 0;
 }