#if !defined(__HOOK_H__) #define __HOOK_H__ 1 #include #include #include #include "xlist.h" #define HOOK_BEFORE_EVENT (0) #define HOOK_AFTER_EVENT (1) typedef int (*hook_fn_t)(int, int, int, void*, va_list); typedef struct { _Atomic hook_fn_t fn; void* data; } hook_item_t; typedef struct { int maxtypes; xlist_t* hooks; } hooksys_t; extern int xce_hook_init(hooksys_t*, int); extern int xce_add_hook(hooksys_t*, int, hook_fn_t, void*); extern int xce_disable_hook(hooksys_t*, int, hook_fn_t); extern int xce_run_hooks(hooksys_t*, int, int, int, ...); extern void xce_hook_fini(hooksys_t*); #endif