-/* IRCEvents.c - NeonServ v5.2
- * Copyright (C) 2011 Philipp Kreil (pk910)
+/* IRCEvents.c - NeonServ v5.4
+ * Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
struct binding {
void *func;
+ int module_id;
struct binding *next;
};
#define BIND_TYPE_RAW 14
#define BIND_TYPE_BOT_READY 15
#define BIND_TYPE_REGISTERED 16
+#define BIND_TYPE_FREEUSER 17
+#define BIND_TYPE_FREECHAN 18
-#define TOTAL_BIND_TYPES 17
+#define TOTAL_BIND_TYPES 19
void init_bind() {
binds = calloc(TOTAL_BIND_TYPES, sizeof(*binds));
free(binds);
}
+void unregister_module_events(int module_id) {
+ struct binding *cbind, *next, *prev;
+ int i;
+ for(i = 0; i < TOTAL_BIND_TYPES; i++) {
+ prev = NULL;
+ for(cbind = binds[i]; cbind; cbind = next) {
+ next = cbind->next;
+ if(cbind->module_id == module_id) {
+ if(prev)
+ prev->next = next;
+ else
+ binds[i] = next;
+ free(cbind);
+ } else
+ prev = cbind;
+ }
+ }
+}
+
static int is_bound(unsigned char type, void *func) {
struct binding *cbind;
for(cbind = binds[type]; cbind; cbind = cbind->next) {
}
#define FUNC_BIND(NAME,FUNCTYPE,TYPE) \
-int bind_##NAME(FUNCTYPE *func) { \
+int bind_##NAME(FUNCTYPE *func, int module_id) { \
if(!is_bound(TYPE, func)) { \
struct binding *cbind = malloc(sizeof(*cbind)); \
if (!cbind) { \
return 0; \
} \
cbind->func = func; \
+ cbind->module_id = module_id; \
cbind->next = binds[TYPE]; \
binds[TYPE] = cbind; \
return 1; \
}
void post_event(UNUSED_ARG(int type)) {
- mysql_free();
+
}
//EVENTS
post_event(BIND_TYPE_REGISTERED);
return ret;
}
+
+FUNC_BIND(freeuser, freeuser_func_t, BIND_TYPE_FREEUSER)
+FUNC_UNBIND(freeuser, freeuser_func_t, BIND_TYPE_FREEUSER)
+FUNC_EVENT(freeuser, freeuser_func_t, BIND_TYPE_FREEUSER, (struct UserNode *user), (user))
+
+FUNC_BIND(freechan, freechan_func_t, BIND_TYPE_FREECHAN)
+FUNC_UNBIND(freechan, freechan_func_t, BIND_TYPE_FREECHAN)
+FUNC_EVENT(freechan, freechan_func_t, BIND_TYPE_FREECHAN, (struct ChanNode *chan), (chan))