aboutsummaryrefslogtreecommitdiffstats
path: root/include/dbs/event.h
diff options
context:
space:
mode:
authorturret <turret@duck.com>2024-03-30 20:35:30 -0500
committerturret <turret@duck.com>2024-03-30 20:35:30 -0500
commit2fb619ed6eac19afd7ed3b2c7baa4adc253f418e (patch)
tree521d3ec070fa39c398ec2d5835cac22bcd95190a /include/dbs/event.h
parent80a67b7d20393a29aa5d2cb92197f3381be7fd96 (diff)
downloaddiscord-bot-skeleton-2fb619ed6eac19afd7ed3b2c7baa4adc253f418e.tar.gz
discord-bot-skeleton-2fb619ed6eac19afd7ed3b2c7baa4adc253f418e.tar.bz2
discord-bot-skeleton-2fb619ed6eac19afd7ed3b2c7baa4adc253f418e.zip
net: event handler
in subsys.h: include init.h to ensure l5_initcall availability also: add example/ directory to provide some user-code in the skeleton (will likely be made defunct as i make the remainder of the skeleton, such as a /ping command and user action and maybe some buttons, which will require more organisation)
Diffstat (limited to 'include/dbs/event.h')
-rw-r--r--include/dbs/event.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/dbs/event.h b/include/dbs/event.h
new file mode 100644
index 0000000..6be3378
--- /dev/null
+++ b/include/dbs/event.h
@@ -0,0 +1,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