X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=IRCEvents.c;h=58efd37cc8132351a8a2fbf9c283a88b764eb161;hb=795115bf680185ae01043bd1222b78bfed8c1d87;hp=d2e8ac907414f1adfa15049b889ec9e5d2809ec7;hpb=265713100dd412fdb963340f594f5e3b7e612531;p=NeonServV5.git diff --git a/IRCEvents.c b/IRCEvents.c index d2e8ac9..58efd37 100644 --- a/IRCEvents.c +++ b/IRCEvents.c @@ -4,6 +4,7 @@ #include "ChanNode.h" #include "ChanUser.h" #include "ClientSocket.h" +#include "mysqlConn.h" struct binding { void *func; @@ -26,13 +27,26 @@ 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)); } +void free_bind() { + struct binding *cbind, *next; + int i; + for(i = 0; i < TOTAL_BIND_TYPES; i++) { + for(cbind = binds[i]; cbind; cbind = next) { + next = cbind->next; + free(cbind); + } + } + free(binds); +} + static int is_bound(unsigned char type, void *func) { struct binding *cbind; for(cbind = binds[type]; cbind; cbind = cbind->next) { @@ -55,6 +69,7 @@ int bind_##NAME(FUNCTYPE *func) { \ binds[TYPE] = cbind; \ return 1; \ } \ + return 0; \ } #define FUNC_UNBIND(NAME,FUNCTYPE,TYPE) \ @@ -76,13 +91,23 @@ void unbind_##NAME(FUNCTYPE *func) { \ #define FUNC_EVENT(NAME,FUNCTYPE,TYPE,PDECLARATION,PLIST) \ int event_##NAME PDECLARATION { \ struct binding *cbind; \ - for(cbind = binds[TYPE]; cbind; cbind = next) { \ + 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) @@ -91,7 +116,7 @@ FUNC_EVENT(join, join_func_t, BIND_TYPE_JOIN, (struct ChanUser *chanuser), (chan FUNC_BIND(nick, nick_func_t, BIND_TYPE_NICK) FUNC_UNBIND(nick, nick_func_t, BIND_TYPE_NICK) -FUNC_EVENT(nick, nick_func_t, BIND_TYPE_NICK, (struct UserNode *user, char *new_nick), (user, newnick)) +FUNC_EVENT(nick, nick_func_t, BIND_TYPE_NICK, (struct UserNode *user, char *new_nick), (user, new_nick)) FUNC_BIND(part, part_func_t, BIND_TYPE_PART) FUNC_UNBIND(part, part_func_t, BIND_TYPE_PART) @@ -139,9 +164,12 @@ FUNC_EVENT(privctcp, privctcp_func_t, BIND_TYPE_PRIVCTCP, (struct UserNode *user FUNC_BIND(invite, invite_func_t, BIND_TYPE_INVITE) FUNC_UNBIND(invite, invite_func_t, BIND_TYPE_INVITE) -FUNC_EVENT(invite, invite_func_t, BIND_TYPE_INVITE, (struct UserNode *user, char *channel), (user, channel)) +FUNC_EVENT(invite, invite_func_t, BIND_TYPE_INVITE, (struct ClientSocket *client, struct UserNode *user, char *channel), (client, user, channel)) 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))