2 * libevent compatibility header, only core events supported
4 * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
46 struct event_base *ev_base;
50 void (*ev_callback)(int, short, void *arg);
55 #define EV_PERSIST 0x10
57 #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd)
58 #define EVENT_FD(ev) ((int) (ev)->ev_fd)
60 #define event_initialized(ev) 1
62 #define evtimer_add(ev,tv) event_add (ev, tv)
63 #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data)
64 #define evtimer_del(ev) event_del (ev)
65 #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv)
66 #define evtimer_initialized(ev) event_initialized (ev)
68 #define timeout_add(ev,tv) evtimer_add (ev, tv)
69 #define timeout_set(ev,cb,data) evtimer_set (ev, cb, data)
70 #define timeout_del(ev) evtimer_del (ev)
71 #define timeout_pending(ev,tv) evtimer_pending (ev, tv)
72 #define timeout_initialized(ev) evtimer_initialized (ev)
74 #define signal_add(ev,tv) event_add (ev, tv)
75 #define signal_set(ev,sig,cb,data) event_set (ev, sig, EV_SIGNAL | EV_PERSIST, cb, data)
76 #define signal_del(ev) event_del (ev)
77 #define signal_pending(ev,tv) event_pending (ev, EV_SIGNAL, tv)
78 #define signal_initialized(ev) event_initialized (ev)
80 const char *event_get_version (void);
81 const char *event_get_method (void);
83 void *event_init (void);
84 void event_base_free (struct event_base *base);
86 #define EVLOOP_ONCE EVLOOP_ONESHOT
88 int event_loopexit (struct timeval *tv);
89 int event_dispatch (void);
91 #define _EVENT_LOG_DEBUG 0
92 #define _EVENT_LOG_MSG 1
93 #define _EVENT_LOG_WARN 2
94 #define _EVENT_LOG_ERR 3
95 typedef void (*event_log_cb)(int severity, const char *msg);
96 void event_set_log_callback(event_log_cb cb);
98 void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg);
99 int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv);
101 int event_add (struct event *ev, struct timeval *tv);
102 int event_del (struct event *ev);
103 void event_active (struct event *ev, int fd, short events);
105 int event_pending (struct event *ev, short, struct timeval *tv);
107 int event_priority_init (int npri);
108 int event_priority_set (struct event *ev, int pri);
112 int event_base_set (struct event_base *base, struct event *ev);
113 int event_base_loop (struct event_base *base, int);
114 int event_base_loopexit (struct event_base *base, struct timeval *tv);
115 int event_base_dispatch (struct event_base *base);
116 int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv);
117 int event_base_priority_init (struct event_base *base, int fd);