avahi  0.7
watch.h
Go to the documentation of this file.
1 #ifndef foowatchhfoo
2 #define foowatchhfoo
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 
25 #include <poll.h>
26 #include <sys/time.h>
27 
28 #include <avahi-common/cdecl.h>
29 
30 AVAHI_C_DECL_BEGIN
31 
33 typedef struct AvahiWatch AvahiWatch;
34 
36 typedef struct AvahiTimeout AvahiTimeout;
37 
39 typedef struct AvahiPoll AvahiPoll;
40 
42 typedef enum {
43  AVAHI_WATCH_IN = POLLIN,
44  AVAHI_WATCH_OUT = POLLOUT,
45  AVAHI_WATCH_ERR = POLLERR,
46  AVAHI_WATCH_HUP = POLLHUP
48 
50 typedef void (*AvahiWatchCallback)(AvahiWatch *w, int fd, AvahiWatchEvent event, void *userdata);
51 
53 typedef void (*AvahiTimeoutCallback)(AvahiTimeout *t, void *userdata);
54 
60 struct AvahiPoll {
61 
63  void* userdata;
64 
68  AvahiWatch* (*watch_new)(const AvahiPoll *api, int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void *userdata);
69 
72 
75 
77  void (*watch_free)(AvahiWatch *w);
78 
84  AvahiTimeout* (*timeout_new)(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback callback, void *userdata);
85 
88  void (*timeout_update)(AvahiTimeout *, const struct timeval *tv);
89 
92 };
93 
94 AVAHI_C_DECL_END
95 
96 #endif
97 
void(* timeout_update)(AvahiTimeout *, const struct timeval *tv)
Update the absolute expiration time for a timeout, If tv is NULL, the timeout is disabled.
Definition: watch.h:88
Error event.
Definition: watch.h:45
struct AvahiTimeout AvahiTimeout
A timeout watch object.
Definition: watch.h:36
Input event.
Definition: watch.h:43
Output event.
Definition: watch.h:44
void * userdata
Some abstract user data usable by the provider of the API.
Definition: watch.h:63
Defines an abstracted event polling API.
Definition: watch.h:60
AvahiWatchEvent(* watch_get_events)(AvahiWatch *w)
Return the events that happened.
Definition: watch.h:74
struct AvahiWatch AvahiWatch
An I/O watch object.
Definition: watch.h:33
void(* timeout_free)(AvahiTimeout *t)
Free a timeout.
Definition: watch.h:91
void(* AvahiTimeoutCallback)(AvahiTimeout *t, void *userdata)
Called when the timeout is reached.
Definition: watch.h:53
AvahiWatchEvent
Type of watch events.
Definition: watch.h:42
void(* watch_free)(AvahiWatch *w)
Free a watch.
Definition: watch.h:77
Hangup event.
Definition: watch.h:46
void(* AvahiWatchCallback)(AvahiWatch *w, int fd, AvahiWatchEvent event, void *userdata)
Called whenever an I/O event happens on an I/O watch.
Definition: watch.h:50
void(* watch_update)(AvahiWatch *w, AvahiWatchEvent event)
Update the events to wait for.
Definition: watch.h:71