tg/event-old.h

44 lines
1.6 KiB
C
Raw Normal View History

2014-09-07 15:12:39 -04:00
#ifndef __EVENT_OLD_H__
#define __EVENT_OLD_H__
2014-09-21 05:25:46 -04:00
#include <assert.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
2014-09-07 17:50:19 -04:00
typedef int evutil_socket_t;
2014-09-07 15:12:39 -04:00
2014-09-08 09:02:59 -04:00
static inline struct event *event_new (struct event_base *base, int fd, int what, void(*callback)(int, short, void *), void *arg) __attribute__ ((unused));
2014-09-07 15:12:39 -04:00
static inline struct event *event_new (struct event_base *base, int fd, int what, void(*callback)(int, short, void *), void *arg) {
2014-09-08 08:40:35 -04:00
struct event *ev = malloc (sizeof (*ev));
event_set (ev, fd, what, callback, arg);
event_base_set (base, ev);
return ev;
2014-09-07 15:12:39 -04:00
}
2014-09-08 09:02:59 -04:00
static inline struct event *evtimer_new (struct event_base *base, void(*callback)(int, short, void *), void *arg) __attribute__ ((unused));
2014-09-07 15:12:39 -04:00
static inline struct event *evtimer_new (struct event_base *base, void(*callback)(int, short, void *), void *arg) {
2014-09-08 08:40:35 -04:00
struct event *ev = malloc (sizeof (*ev));
event_set (ev, -1, 0, callback, arg);
event_base_set (base, ev);
return ev;
2014-09-07 15:12:39 -04:00
}
2014-09-08 09:02:59 -04:00
static void event_free (struct event *ev) __attribute__ ((unused));
2014-09-07 15:12:39 -04:00
static void event_free (struct event *ev) {
event_del (ev);
free (ev);
}
2014-09-21 05:25:46 -04:00
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;
}
2014-09-07 15:12:39 -04:00
#endif