added .gitignore
[NeonServV5.git] / IRCEvents.c
index 51e0d326563a2db02cc68415976b7e5f1a474ea2..d85dff9b9027c49736d02c66d6fe1d2ec3a41dae 100644 (file)
@@ -4,6 +4,7 @@
 #include "ChanNode.h"
 #include "ChanUser.h"
 #include "ClientSocket.h"
+#include "mysqlConn.h"
 
 struct binding {
     void *func;
@@ -26,8 +27,9 @@ static void **binds;
 #define BIND_TYPE_PRIVCTCP   12
 #define BIND_TYPE_INVITE     13
 #define BIND_TYPE_RAW        14
+#define BIND_TYPE_BOT_READY  15
 
-#define TOTAL_BIND_TYPES     15
+#define TOTAL_BIND_TYPES     16
 
 void init_bind() {
     binds = calloc(TOTAL_BIND_TYPES, sizeof(*binds));
@@ -89,13 +91,23 @@ void unbind_##NAME(FUNCTYPE *func) { \
 #define FUNC_EVENT(NAME,FUNCTYPE,TYPE,PDECLARATION,PLIST) \
 int event_##NAME PDECLARATION { \
     struct binding *cbind; \
+    pre_event(TYPE); \
     for(cbind = binds[TYPE]; cbind; cbind = cbind->next) { \
         FUNCTYPE *func = cbind->func; \
         func PLIST; \
     } \
+    post_event(TYPE); \
     return 1; \
 }
 
+void pre_event(UNUSED_ARG(int type)) {
+
+}
+
+void post_event(UNUSED_ARG(int type)) {
+    mysql_free();
+}
+
 //EVENTS
 
 FUNC_BIND(join, join_func_t, BIND_TYPE_JOIN)
@@ -158,3 +170,6 @@ FUNC_BIND(raw, raw_func_t, BIND_TYPE_RAW)
 FUNC_UNBIND(raw, raw_func_t, BIND_TYPE_RAW)
 FUNC_EVENT(raw, raw_func_t, BIND_TYPE_RAW, (struct ClientSocket *client, char *from, char *cmd, char **argv, int argc), (client, from, cmd, argv, argc))
 
+FUNC_BIND(bot_ready, bot_ready_func_t, BIND_TYPE_BOT_READY)
+FUNC_UNBIND(bot_ready, bot_ready_func_t, BIND_TYPE_BOT_READY)
+FUNC_EVENT(bot_ready, bot_ready_func_t, BIND_TYPE_BOT_READY, (struct ClientSocket *client), (client))