163 #ifdef HAVE_SYS_TYPES_H
164 #include <sys/types.h>
166 #ifdef HAVE_SYS_TIME_H
167 #include <sys/time.h>
178 #define WIN32_LEAN_AND_MEAN
180 #undef WIN32_LEAN_AND_MEAN
181 typedef unsigned char u_char;
182 typedef unsigned short u_short;
185 #define EVLIST_TIMEOUT 0x01
186 #define EVLIST_INSERTED 0x02
187 #define EVLIST_SIGNAL 0x04
188 #define EVLIST_ACTIVE 0x08
189 #define EVLIST_INTERNAL 0x10
190 #define EVLIST_INIT 0x80
193 #define EVLIST_ALL (0xf000 | 0x9f)
195 #define EV_TIMEOUT 0x01
197 #define EV_WRITE 0x04
198 #define EV_SIGNAL 0x08
199 #define EV_PERSIST 0x10
203 #define _EVENT_DEFINED_TQENTRY
204 #define TAILQ_ENTRY(type) \
206 struct type *tqe_next; \
207 struct type **tqe_prev; \
213 TAILQ_ENTRY (
event) ev_next;
214 TAILQ_ENTRY (
event) ev_active_next;
215 TAILQ_ENTRY (
event) ev_signal_next;
216 unsigned int min_heap_idx;
229 void (*ev_callback)(int, short,
void *arg);
236 #define EVENT_SIGNAL(ev) (int)(ev)->ev_fd
237 #define EVENT_FD(ev) (int)(ev)->ev_fd
250 #ifdef _EVENT_DEFINED_TQENTRY
254 #undef _EVENT_DEFINED_TQENTRY
256 TAILQ_HEAD (event_list,
event);
303 int event_dispatch(
void);
321 const char *event_base_get_method(
struct event_base *);
335 #define _EVENT_LOG_DEBUG 0
336 #define _EVENT_LOG_MSG 1
337 #define _EVENT_LOG_WARN 2
338 #define _EVENT_LOG_ERR 3
339 typedef void (*event_log_cb)(
int severity,
const char *
msg);
361 #define EVLOOP_ONCE 0x01
362 #define EVLOOP_NONBLOCK 0x02
388 int event_base_loop(
struct event_base *,
int);
403 int event_loopexit(
const struct timeval *);
434 int event_loopbreak(
void);
449 int event_base_loopbreak(
struct event_base *);
458 #define evtimer_add(ev, tv) event_add(ev, tv)
468 #define evtimer_set(ev, cb, arg) event_set(ev, -1, 0, cb, arg)
476 #define evtimer_del(ev) event_del(ev)
477 #define evtimer_pending(ev, tv) event_pending(ev, EV_TIMEOUT, tv)
478 #define evtimer_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
486 #define timeout_add(ev, tv) event_add(ev, tv)
496 #define timeout_set(ev, cb, arg) event_set(ev, -1, 0, cb, arg)
504 #define timeout_del(ev) event_del(ev)
506 #define timeout_pending(ev, tv) event_pending(ev, EV_TIMEOUT, tv)
507 #define timeout_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
509 #define signal_add(ev, tv) event_add(ev, tv)
510 #define signal_set(ev, x, cb, arg) \
511 event_set(ev, x, EV_SIGNAL|EV_PERSIST, cb, arg)
512 #define signal_del(ev) event_del(ev)
513 #define signal_pending(ev, tv) event_pending(ev, EV_SIGNAL, tv)
514 #define signal_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
542 void event_set(
struct event *,
int,
short,
void (*)(
int,
short,
void *),
void *);
562 int event_once(
int,
short,
void (*)(
int,
short,
void *),
void *,
584 int event_base_once(
struct event_base *base,
int fd,
short events,
585 void (*callback)(
int,
short,
void *),
void *arg,
586 const struct timeval *timeout);
607 int event_add(
struct event *ev,
const struct timeval *timeout);
621 int event_del(
struct event *);
623 void event_active(
struct event *,
int,
short);
651 #define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT && (ev)->ev_fd != (int)INVALID_HANDLE_VALUE)
653 #define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT)
662 const char *event_get_version(
void);
670 const char *event_get_method(
void);
693 int event_priority_init(
int);
706 int event_base_priority_init(
struct event_base *,
int);
717 int event_priority_set(
struct event *,
int);
730 void (*cb)(
struct evbuffer *, size_t, size_t,
void *);
735 #define EVBUFFER_READ 0x01
736 #define EVBUFFER_WRITE 0x02
737 #define EVBUFFER_EOF 0x10
738 #define EVBUFFER_ERROR 0x20
739 #define EVBUFFER_TIMEOUT 0x40
742 typedef void (*evbuffercb)(
struct bufferevent *,
void *);
743 typedef void (*everrorcb)(
struct bufferevent *,
short what,
void *);
753 struct event ev_read;
754 struct event ev_write;
809 evbuffercb readcb, evbuffercb writecb, everrorcb errorcb,
void *cbarg);
830 int bufferevent_priority_set(
struct bufferevent *bufev,
int pri);
856 evbuffercb readcb, evbuffercb writecb, everrorcb errorcb,
void *cbarg);
864 void bufferevent_setfd(
struct bufferevent *bufev,
int fd);
880 const void *data,
size_t size);
905 size_t bufferevent_read(
struct bufferevent *bufev,
void *data,
size_t size);
936 void bufferevent_settimeout(
struct bufferevent *bufev,
937 int timeout_read,
int timeout_write);
956 void bufferevent_setwatermark(
struct bufferevent *bufev,
short events,
957 size_t lowmark,
size_t highmark);
959 #define EVBUFFER_LENGTH(x) (x)->off
960 #define EVBUFFER_DATA(x) (x)->buffer
961 #define EVBUFFER_INPUT(x) (x)->input
962 #define EVBUFFER_OUTPUT(x) (x)->output
971 struct evbuffer *evbuffer_new(
void);
979 void evbuffer_free(
struct evbuffer *);
991 int evbuffer_expand(
struct evbuffer *,
size_t);
1001 int evbuffer_add(
struct evbuffer *,
const void *,
size_t);
1013 int evbuffer_remove(
struct evbuffer *,
void *,
size_t);
1025 char *evbuffer_readline(
struct evbuffer *);
1049 int evbuffer_add_printf(
struct evbuffer *,
const char *
fmt, ...)
1051 __attribute__((format(printf, 2, 3)))
1064 int evbuffer_add_vprintf(
struct evbuffer *,
const char *fmt, va_list ap);
1073 void evbuffer_drain(
struct evbuffer *,
size_t);
1086 int evbuffer_write(
struct evbuffer *,
int);
1098 int evbuffer_read(
struct evbuffer *,
int,
int);
1109 u_char *evbuffer_find(
struct evbuffer *,
const u_char *,
size_t);
1118 void evbuffer_setcb(
struct evbuffer *,
void (*)(
struct evbuffer *,
size_t,
size_t,
void *),
void *);
1126 void evtag_init(
void);
1128 void evtag_marshal(
struct evbuffer *evbuf, ev_uint32_t tag,
const void *data,
1143 void evtag_marshal_int(
struct evbuffer *evbuf, ev_uint32_t tag,
1144 ev_uint32_t integer);
1146 void evtag_marshal_string(
struct evbuffer *
buf, ev_uint32_t tag,
1147 const char *
string);
1149 void evtag_marshal_timeval(
struct evbuffer *evbuf, ev_uint32_t tag,
1152 int evtag_unmarshal(
struct evbuffer *src, ev_uint32_t *ptag,
1154 int evtag_peek(
struct evbuffer *evbuf, ev_uint32_t *ptag);
1155 int evtag_peek_length(
struct evbuffer *evbuf, ev_uint32_t *plength);
1156 int evtag_payload_length(
struct evbuffer *evbuf, ev_uint32_t *plength);
1157 int evtag_consume(
struct evbuffer *evbuf);
1159 int evtag_unmarshal_int(
struct evbuffer *evbuf, ev_uint32_t need_tag,
1160 ev_uint32_t *pinteger);
1162 int evtag_unmarshal_fixed(
struct evbuffer *src, ev_uint32_t need_tag,
1163 void *data,
size_t len);
1165 int evtag_unmarshal_string(
struct evbuffer *evbuf, ev_uint32_t need_tag,
1168 int evtag_unmarshal_timeval(
struct evbuffer *evbuf, ev_uint32_t need_tag,