… | |
… | |
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 | #ifdef EV_H |
|
|
35 | # include EV_H |
|
|
36 | #else |
34 | #include <ev.h> |
37 | # include <ev.h> |
|
|
38 | #endif |
35 | |
39 | |
36 | #ifdef __cplusplus |
40 | #ifdef __cplusplus |
37 | extern "C" { |
41 | extern "C" { |
38 | #endif |
42 | #endif |
|
|
43 | |
|
|
44 | struct event_base; |
39 | |
45 | |
40 | struct event |
46 | struct event |
41 | { |
47 | { |
42 | /* libev watchers we map onto */ |
48 | /* libev watchers we map onto */ |
43 | union { |
49 | union { |
… | |
… | |
52 | void *ev_arg; |
58 | void *ev_arg; |
53 | int ev_fd; |
59 | int ev_fd; |
54 | int ev_pri; |
60 | int ev_pri; |
55 | int ev_res; |
61 | int ev_res; |
56 | short ev_events; |
62 | short ev_events; |
57 | |
|
|
58 | char initialised; /* flag to work around some idiosynchrasies in the API */ |
|
|
59 | }; |
63 | }; |
60 | |
64 | |
61 | #define EV_PERSIST 0x10 |
65 | #define EV_PERSIST 0x10 |
62 | |
66 | |
63 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
67 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
64 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) |
68 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) |
65 | |
69 | |
66 | #define event_initialized(ev) ((ev)->initialised) |
70 | #define event_initialized(ev) 1 |
67 | |
71 | |
68 | #define evtimer_add(ev,tv) event_add (ev, tv) |
72 | #define evtimer_add(ev,tv) event_add (ev, tv) |
69 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) |
73 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) |
70 | #define evtimer_del(ev) event_del (ev) |
74 | #define evtimer_del(ev) event_del (ev) |
71 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) |
75 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) |
… | |
… | |
104 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); |
108 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); |
105 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
109 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
106 | |
110 | |
107 | int event_add (struct event *ev, struct timeval *tv); |
111 | int event_add (struct event *ev, struct timeval *tv); |
108 | int event_del (struct event *ev); |
112 | int event_del (struct event *ev); |
|
|
113 | void event_active (struct event *ev, int res, short ncalls); /* ncalls is being ignored */ |
109 | |
114 | |
110 | int event_pending (struct event *ev, short, struct timeval *tv); |
115 | int event_pending (struct event *ev, short, struct timeval *tv); |
111 | |
116 | |
112 | int event_priority_init (int npri); |
117 | int event_priority_init (int npri); |
113 | int event_priority_set (struct event *ev, int pri); |
118 | int event_priority_set (struct event *ev, int pri); |
114 | |
|
|
115 | struct event_base; |
|
|
116 | |
119 | |
117 | int event_base_set (struct event_base *base, struct event *ev); |
120 | int event_base_set (struct event_base *base, struct event *ev); |
118 | int event_base_loop (struct event_base *base, int); |
121 | int event_base_loop (struct event_base *base, int); |
119 | int event_base_loopexit (struct event_base *base, struct timeval *tv); |
122 | int event_base_loopexit (struct event_base *base, struct timeval *tv); |
120 | int event_base_dispatch (struct event_base *base); |
123 | int event_base_dispatch (struct event_base *base); |
121 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
124 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
122 | int event_base_priority_init (struct event_base *base, int fd); |
125 | int event_base_priority_init (struct event_base *base, int fd); |
123 | |
126 | |
124 | #ifndef EV_STANDALONE |
127 | #ifndef EV_STANDALONE |
125 | # include "event_compat.h" |
128 | # include <event_compat.h> |
126 | #endif |
129 | #endif |
127 | |
130 | |
128 | #ifdef __cplusplus |
131 | #ifdef __cplusplus |
129 | } |
132 | } |
130 | #endif |
133 | #endif |