1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#ifndef __EVENT_H #define __EVENT_H #include <dbs/init.h> enum Event { #define E(ev_name, _) ev_name, #include <dbs/bits/events.h> #undef E }; int ev_set_handler(enum Event event, int (*ev_handler)(cJSON*)); #define declare_event(event, handler) \ void __decl_##event_##handler() { \ ev_set_handler(event, handler); \ } \ l3_initcall(__decl_##event_##handler) #endif