-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
event-old.h
48 lines (40 loc) · 1.68 KB
/
event-old.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef __EVENT_OLD_H__
#define __EVENT_OLD_H__
#include <assert.h>
#include <stdlib.h>
#define BEV_EVENT_READ EVBUFFER_READ
#define BEV_EVENT_WRITE EVBUFFER_WRITE
#define BEV_EVENT_EOF EVBUFFER_EOF
#define BEV_EVENT_ERROR EVBUFFER_ERROR
#define BEV_EVENT_TIMEOUT EVBUFFER_TIMEOUT
typedef int evutil_socket_t;
static inline struct event *event_new (struct event_base *base, int fd, int what, void(*callback)(int, short, void *), void *arg) __attribute__ ((unused));
static inline struct event *event_new (struct event_base *base, int fd, int what, void(*callback)(int, short, void *), void *arg) {
struct event *ev = malloc (sizeof (*ev));
event_set (ev, fd, what, callback, arg);
event_base_set (base, ev);
return ev;
}
static inline struct event *evtimer_new (struct event_base *base, void(*callback)(int, short, void *), void *arg) __attribute__ ((unused));
static inline struct event *evtimer_new (struct event_base *base, void(*callback)(int, short, void *), void *arg) {
struct event *ev = malloc (sizeof (*ev));
event_set (ev, -1, 0, callback, arg);
event_base_set (base, ev);
return ev;
}
static void event_free (struct event *ev) __attribute__ ((unused));
static void event_free (struct event *ev) {
event_del (ev);
free (ev);
}
static struct bufferevent *bufferevent_socket_new (struct event_base *base, int fd, int flags) __attribute__ ((unused));
static struct bufferevent *bufferevent_socket_new (struct event_base *base, int fd, int flags) {
assert (!flags);
struct bufferevent *bev = bufferevent_new(fd, 0, 0, 0, 0);
bufferevent_base_set (base, bev);
return bev;
}
static inline void *event_get_callback_arg(const struct event *ev) {
return ev->ev_arg;
}
#endif