diff options
Diffstat (limited to 'src/pevent.h')
-rw-r--r-- | src/pevent.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/pevent.h b/src/pevent.h index b756505..0f387aa 100644 --- a/src/pevent.h +++ b/src/pevent.h @@ -40,12 +40,20 @@ #define POTD_MAXFD 32 #define POTD_MAXEVENTS 64 +#define POTD_EVENTBUF_REALLOCSIZ 5 typedef enum forward_state { CON_OK, CON_IN_TERMINATED, CON_OUT_TERMINATED, CON_IN_ERROR, CON_OUT_ERROR } forward_state; +typedef struct event_buf { + int fd; + + char buf[BUFSIZ]; + size_t buf_used; +} event_buf; + typedef struct event_ctx { int active; int has_error; @@ -53,9 +61,14 @@ typedef struct event_ctx { int epoll_fd; struct epoll_event events[POTD_MAXEVENTS]; int current_event; + + event_buf *buffer_array; + size_t buffer_size; + size_t buffer_used; } event_ctx; -typedef int (*on_event_cb) (event_ctx *ev_ctx, int fd, void *user_data); +typedef int (*on_event_cb) (event_ctx *ev_ctx, event_buf *buf, + void *user_data); typedef int (*on_data_cb) (event_ctx *ev_ctx, int src_fd, int dst_fd, char *buf, size_t siz, void *user_data); @@ -66,6 +79,8 @@ void event_free(event_ctx **ctx); int event_setup(event_ctx *ctx); +int event_validate_ctx(event_ctx *ctx); + int event_add_sock(event_ctx *ctx, psocket *sock); int event_add_fd(event_ctx *ctx, int fd); |