X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-common%2Fwatch-test.c;h=cd70117574d38249ffd1a7edb18a96051e6292b1;hb=df591ee292c99ead3a286c50f64e5c461f3a9d8e;hp=af46805cdde0fd3739747f57f2889aeb29ad7ef8;hpb=4f0a5e7572a4257894b4bfede42c26d65152609e;p=catta diff --git a/avahi-common/watch-test.c b/avahi-common/watch-test.c index af46805..cd70117 100644 --- a/avahi-common/watch-test.c +++ b/avahi-common/watch-test.c @@ -32,11 +32,12 @@ #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; }