• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/avahi-0.6.31/avahi-common/
1#ifndef foosimplewatchhfoo
2#define foosimplewatchhfoo
3
4/***
5  This file is part of avahi.
6
7  avahi is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Lesser General Public License as
9  published by the Free Software Foundation; either version 2.1 of the
10  License, or (at your option) any later version.
11
12  avahi is distributed in the hope that it will be useful, but WITHOUT
13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15  Public License for more details.
16
17  You should have received a copy of the GNU Lesser General Public
18  License along with avahi; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  USA.
21***/
22
23/** \file simple-watch.h Simple poll() based main loop implementation */
24
25#include <sys/poll.h>
26#include <avahi-common/cdecl.h>
27#include <avahi-common/watch.h>
28
29AVAHI_C_DECL_BEGIN
30
31/** A main loop object. Main loops of this type aren't very flexible
32 * since they only support a single wakeup type. Nevertheless it
33 * should suffice for small test and example applications.  */
34typedef struct AvahiSimplePoll AvahiSimplePoll;
35
36/** Create a new main loop object */
37AvahiSimplePoll *avahi_simple_poll_new(void);
38
39/** Free a main loop object */
40void avahi_simple_poll_free(AvahiSimplePoll *s);
41
42/** Return the abstracted poll API object for this main loop
43 * object. The is will return the same pointer each time it is
44 * called. */
45const AvahiPoll* avahi_simple_poll_get(AvahiSimplePoll *s);
46
47/** Run a single main loop iteration of this main loop. If sleep_time
48is < 0 this will block until any of the registered events happens,
49then it will execute the attached callback function. If sleep_time is
500 the routine just checks if any event is pending. If yes the attached
51callback function is called, otherwise the function returns
52immediately. If sleep_time > 0 the function will block for at most the
53specified time in msecs. Returns -1 on error, 0 on success and 1 if a
54quit request has been scheduled. Usually this function should be called
55in a loop until it returns a non-zero value*/
56int avahi_simple_poll_iterate(AvahiSimplePoll *s, int sleep_time);
57
58/** Request that the main loop quits. If this is called the next
59 call to avahi_simple_poll_iterate() will return 1 */
60void avahi_simple_poll_quit(AvahiSimplePoll *s);
61
62/** Prototype for a poll() type function */
63typedef int (*AvahiPollFunc)(struct pollfd *ufds, unsigned int nfds, int timeout, void *userdata);
64
65/** Replace the internally used poll() function. By default the system's poll() will be used */
66void avahi_simple_poll_set_func(AvahiSimplePoll *s, AvahiPollFunc func, void *userdata);
67
68/** The first stage of avahi_simple_poll_iterate(), use this function only if you know what you do */
69int avahi_simple_poll_prepare(AvahiSimplePoll *s, int timeout);
70
71/** The second stage of avahi_simple_poll_iterate(), use this function only if you know what you do */
72int avahi_simple_poll_run(AvahiSimplePoll *s);
73
74/** The third and final stage of avahi_simple_poll_iterate(), use this function only if you know what you do */
75int avahi_simple_poll_dispatch(AvahiSimplePoll *s);
76
77/** Call avahi_simple_poll_iterate() in a loop and return if it returns non-zero */
78int avahi_simple_poll_loop(AvahiSimplePoll *s);
79
80/** Wakeup the main loop. (for threaded environments) */
81void avahi_simple_poll_wakeup(AvahiSimplePoll *s);
82
83AVAHI_C_DECL_END
84
85#endif
86