#include "../pkev.h" #include "../pkmacros.h" #include #include struct ev { bool handled; }; struct ev ev_one = {0}; struct ev ev_two = {0}; void handle_ev_one() { ev_one.handled = true; } void handle_ev_two() { ev_two.handled = true; } const pk_ev_mgr_id_T test_setup() { memset(&ev_one, 0, sizeof(struct ev)); memset(&ev_two, 0, sizeof(struct ev)); pk_ev_init(); const pk_ev_mgr_id_T evmgr = pk_ev_create_mgr(); if (evmgr >= 64) { PK_LOGV_ERR("%s: failed to create pk_ev_mgr\n", __FILE__); exit(1); } return evmgr; } int main(int argc, char *argv[]) { (void)argc; (void)argv; (void)stdout; pk_ev_id_T custom_ev_one = 1; pk_ev_id_T custom_ev_two = 2; // register, emit, catch { pk_ev_mgr_id_T evmgr = test_setup(); custom_ev_one = pk_ev_register_ev(evmgr); custom_ev_two = pk_ev_register_ev(evmgr); pk_ev_register_cb(evmgr, custom_ev_one, handle_ev_one); pk_ev_register_cb(evmgr, custom_ev_two, handle_ev_two); pk_ev_emit(evmgr, custom_ev_one); pk_ev_emit(evmgr, custom_ev_two); PK_LOGV_INF("%s: ev_one: %b, ev_two: %b\n", __FILE__, ev_one.handled, ev_two.handled); pk_ev_teardown(); if (ev_one.handled == false || ev_two.handled == false) exit(1); } return 0; }