… | |
… | |
73 | #define EVLIST_SIGNAL 0x04 |
73 | #define EVLIST_SIGNAL 0x04 |
74 | #define EVLIST_ACTIVE 0x08 |
74 | #define EVLIST_ACTIVE 0x08 |
75 | #define EVLIST_INTERNAL 0x10 |
75 | #define EVLIST_INTERNAL 0x10 |
76 | #define EVLIST_INIT 0x80 |
76 | #define EVLIST_INIT 0x80 |
77 | |
77 | |
|
|
78 | typedef void (*event_callback_fn)(int, short, void *); |
|
|
79 | |
78 | struct event |
80 | struct event |
79 | { |
81 | { |
80 | /* libev watchers we map onto */ |
82 | /* libev watchers we map onto */ |
81 | union { |
83 | union { |
82 | struct ev_io io; |
84 | struct ev_io io; |
… | |
… | |
84 | } iosig; |
86 | } iosig; |
85 | struct ev_timer to; |
87 | struct ev_timer to; |
86 | |
88 | |
87 | /* compatibility slots */ |
89 | /* compatibility slots */ |
88 | struct event_base *ev_base; |
90 | struct event_base *ev_base; |
89 | void (*ev_callback)(int, short, void *arg); |
91 | event_callback_fn ev_callback; |
90 | void *ev_arg; |
92 | void *ev_arg; |
91 | int ev_fd; |
93 | int ev_fd; |
92 | int ev_pri; |
94 | int ev_pri; |
93 | int ev_res; |
95 | int ev_res; |
94 | int ev_flags; |
96 | int ev_flags; |
95 | short ev_events; |
97 | short ev_events; |
96 | }; |
98 | }; |
|
|
99 | |
|
|
100 | event_callback_fn event_get_callback (const struct event *ev); |
97 | |
101 | |
98 | #define EV_READ EV_READ |
102 | #define EV_READ EV_READ |
99 | #define EV_WRITE EV_WRITE |
103 | #define EV_WRITE EV_WRITE |
100 | #define EV_PERSIST 0x10 |
104 | #define EV_PERSIST 0x10 |
101 | #define EV_ET 0x20 /* nop */ |
105 | #define EV_ET 0x20 /* nop */ |
… | |
… | |
139 | #define _EVENT_LOG_WARN 2 |
143 | #define _EVENT_LOG_WARN 2 |
140 | #define _EVENT_LOG_ERR 3 |
144 | #define _EVENT_LOG_ERR 3 |
141 | typedef void (*event_log_cb)(int severity, const char *msg); |
145 | typedef void (*event_log_cb)(int severity, const char *msg); |
142 | void event_set_log_callback(event_log_cb cb); |
146 | void event_set_log_callback(event_log_cb cb); |
143 | |
147 | |
144 | typedef void (*event_callback_fn)(int, short, void *); |
|
|
145 | event_callback_fn event_get_callback (const struct event *ev); |
|
|
146 | |
|
|
147 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); |
148 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); |
148 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
149 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
149 | |
150 | |
150 | int event_add (struct event *ev, struct timeval *tv); |
151 | int event_add (struct event *ev, struct timeval *tv); |
151 | int event_del (struct event *ev); |
152 | int event_del (struct event *ev); |