#pragma once #include #include #include #include #include #include #include #include "net_tools.h" #define EVT_CORE_MAX_EVENTS 10 struct evt_core_ctx; struct evt_core_cat; typedef void (*evt_core_free_app_ctx)(void*); typedef void (*evt_core_cb)(struct evt_core_ctx*, struct evt_core_cat*, int fd); struct evt_core_cat { void* app_ctx; evt_core_free_app_ctx free_app_ctx; evt_core_cb cb; char* name; int flags; GHashTable* socklist; }; struct evt_core_ctx { int epollfd; GHashTable* catlist; GHashTable* socklist; }; void evt_core_init(struct evt_core_ctx* ctx); void evt_core_add_cat(struct evt_core_ctx* ctx, struct evt_core_cat* cat); void evt_core_add_fd(struct evt_core_ctx* ctx, char* name, int fd); void evt_core_free(struct evt_core_ctx* ctx); void evt_core_loop(struct evt_core_ctx* ctx);