… | |
… | |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | */ |
30 | */ |
31 | #ifndef _EVENT_H_ |
31 | #ifndef _EVENT_H_ |
32 | #define _EVENT_H_ |
32 | #define _EVENT_H_ |
33 | |
33 | |
|
|
34 | #ifndef EV_EMBED |
|
|
35 | # include "ev.h" |
|
|
36 | #endif |
|
|
37 | |
34 | #ifdef __cplusplus |
38 | #ifdef __cplusplus |
35 | extern "C" { |
39 | extern "C" { |
36 | #endif |
40 | #endif |
37 | |
41 | |
38 | #include "ev.h" |
|
|
39 | |
|
|
40 | struct event |
42 | struct event |
41 | { |
43 | { |
42 | /* lib watchers we map to */ |
44 | /* libev watchers we map onto */ |
43 | union { |
45 | union { |
44 | struct ev_io io; |
46 | struct ev_io io; |
45 | struct ev_signal sig; |
47 | struct ev_signal sig; |
46 | } iosig; |
48 | } iosig; |
47 | struct ev_timer to; |
49 | struct ev_timer to; |
… | |
… | |
52 | void *ev_arg; |
54 | void *ev_arg; |
53 | int ev_fd; |
55 | int ev_fd; |
54 | int ev_pri; |
56 | int ev_pri; |
55 | int ev_res; |
57 | int ev_res; |
56 | short ev_events; |
58 | short ev_events; |
|
|
59 | |
|
|
60 | char initialised; /* flag to work around some idiosynchrasies in the API */ |
57 | }; |
61 | }; |
58 | |
62 | |
59 | #define EV_PERSIST 0x10 |
63 | #define EV_PERSIST 0x10 |
60 | |
64 | |
61 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
65 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
62 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) |
66 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) |
63 | |
67 | |
64 | #define event_initialized(ev) 1 |
68 | #define event_initialized(ev) ((ev)->initialised) |
65 | |
69 | |
66 | #define evtimer_add(ev,tv) event_add (ev, tv) |
70 | #define evtimer_add(ev,tv) event_add (ev, tv) |
67 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) |
71 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) |
68 | #define evtimer_del(ev) event_del (ev) |
72 | #define evtimer_del(ev) event_del (ev) |
69 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) |
73 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) |
… | |
… | |
117 | int event_base_loopexit (struct event_base *base, struct timeval *tv); |
121 | int event_base_loopexit (struct event_base *base, struct timeval *tv); |
118 | int event_base_dispatch (struct event_base *base); |
122 | int event_base_dispatch (struct event_base *base); |
119 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
123 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
120 | int event_base_priority_init (struct event_base *base, int fd); |
124 | int event_base_priority_init (struct event_base *base, int fd); |
121 | |
125 | |
|
|
126 | #ifndef EV_EMBED |
|
|
127 | # include "event_compat.h" |
122 | #endif |
128 | #endif |
|
|
129 | |
|
|
130 | #ifdef __cplusplus |
|
|
131 | } |
|
|
132 | #endif |
|
|
133 | |
|
|
134 | #endif |
|
|
135 | |