diff options
Diffstat (limited to 'src/pevent.h')
-rw-r--r-- | src/pevent.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pevent.h b/src/pevent.h new file mode 100644 index 0000000..da09f59 --- /dev/null +++ b/src/pevent.h @@ -0,0 +1,30 @@ +#ifndef POTD_EVENT_H +#define POTD_EVENT_H 1 + +#include <sys/epoll.h> + +#include "socket.h" + +#define POTD_MAXFD 32 +#define POTD_MAXEVENTS 64 + +typedef struct event_ctx { + int epoll_fd; + int active; + struct epoll_event events[POTD_MAXEVENTS]; +} event_ctx; + +typedef int (*on_event_cb) (int fd, void *user_data); + + +void event_init(event_ctx **ctx); + +int event_setup(event_ctx *ctx); + +int event_add_sock(event_ctx *ctx, psocket *sock); + +int event_add_fd(event_ctx *ctx, int fd); + +int event_loop(event_ctx *ctx, on_event_cb on_event, void *user_data); + +#endif |