aboutsummaryrefslogtreecommitdiff
path: root/src/pevent.h
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2018-05-07 11:04:58 +0200
committerToni Uhlig <matzeton@googlemail.com>2018-05-07 11:04:58 +0200
commitbe4352e2bb6ffcc1d548cf9e8cf9f497e2865af0 (patch)
treed692109ddb4b9304ecc65be09e9cd44481551580 /src/pevent.h
parent14d2b4d0134ac00a6262d5c8229ffe0d3b5ecd48 (diff)
POTD skeleton #44.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/pevent.h')
-rw-r--r--src/pevent.h30
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