summaryrefslogtreecommitdiffstats
path: root/avahi-common/simple-watch.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-08-14 02:33:41 +0000
committerLennart Poettering <lennart@poettering.net>2005-08-14 02:33:41 +0000
commitfcc9b0efe1accdb0edcb3143a8e15782e69383db (patch)
tree38589765599804bee4808d49d5695f8a5e7c56c4 /avahi-common/simple-watch.c
parent7934ca5e102693ba02d9ca6dcdee4960f2ba1a64 (diff)
* doxygen documentation updates
* make AvahiPoll objects const * make poll() functions pluggable in AvahiSimplePoll git-svn-id: file:///home/lennart/svn/public/avahi/trunk@314 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-common/simple-watch.c')
-rw-r--r--avahi-common/simple-watch.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/avahi-common/simple-watch.c b/avahi-common/simple-watch.c
index 3caf371..5e03fe4 100644
--- a/avahi-common/simple-watch.c
+++ b/avahi-common/simple-watch.c
@@ -46,6 +46,7 @@ struct AvahiWatch {
struct AvahiSimplePoll {
AvahiPoll api;
+ AvahiPollFunc poll_func;
struct pollfd* pollfds;
int n_pollfds, max_pollfds, rebuild_pollfds;
@@ -62,7 +63,7 @@ struct AvahiSimplePoll {
AVAHI_LLIST_HEAD(AvahiWatch, watches);
};
-static AvahiWatch* watch_new(AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata) {
+static AvahiWatch* watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata) {
AvahiWatch *w;
AvahiSimplePoll *s;
@@ -142,7 +143,7 @@ static void watch_free(AvahiWatch *w) {
w->simple_poll->req_cleanup = 1;
}
-static void set_wakeup(AvahiPoll *api, const struct timeval *tv, AvahiWakeupCallback callback, void *userdata) {
+static void set_wakeup(const AvahiPoll *api, const struct timeval *tv, AvahiWakeupCallback callback, void *userdata) {
AvahiSimplePoll *s;
assert(api);
@@ -207,6 +208,8 @@ AvahiSimplePoll *avahi_simple_poll_new(void) {
s->n_watches = 0;
s->req_cleanup = 0;
+ avahi_simple_poll_set_func(s, NULL);
+
AVAHI_LLIST_HEAD_INIT(AvahiWatch, s->watches);
return s;
@@ -315,7 +318,7 @@ int avahi_simple_poll_iterate(AvahiSimplePoll *s, int timeout) {
timeout = t;
}
- if ((r = poll(s->pollfds, s->n_pollfds, timeout)) < 0)
+ if ((r = s->poll_func(s->pollfds, s->n_pollfds, timeout)) < 0)
return -1;
/* Check whether the wakeup time has been reached now */
@@ -359,8 +362,14 @@ void avahi_simple_poll_quit(AvahiSimplePoll *w) {
w->quit = 1;
}
-AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s) {
+const AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s) {
assert(s);
return &s->api;
}
+
+void avahi_simple_poll_set_func(AvahiSimplePoll *s, AvahiPollFunc func) {
+ assert(s);
+
+ s->poll_func = func ? func : (AvahiPollFunc) poll;
+}