From 50cbf7b711445bfb74a4aab3609dfaf73c593c9f Mon Sep 17 00:00:00 2001 From: pk910 Date: Sun, 23 Oct 2011 19:48:28 +0200 Subject: [PATCH] if we use multiple callbacks we also need to save the different data arguments for them --- src/WHOHandler.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/WHOHandler.c b/src/WHOHandler.c index 961cfab..3bf9158 100644 --- a/src/WHOHandler.c +++ b/src/WHOHandler.c @@ -37,7 +37,7 @@ struct WHOQueueEntry { struct UserNode *user; struct WHOQueueEntry *next; void *callback[MAXCALLBACKS]; - void *data; + void *data[MAXCALLBACKS]; }; static struct WHOQueueEntry *first_entry = NULL, *last_entry = NULL; @@ -108,7 +108,9 @@ void get_userlist(struct ChanNode *chan, userlist_callback_t callback, void *dat int i; for(i = 1; i < MAXCALLBACKS; i++) entry->callback[i] = NULL; - entry->data = data; + entry->data[0] = data; + for(i = 1; i < MAXCALLBACKS; i++) + entry->data[i] = NULL; putsock(bot, "WHO %s,%d %%tuhnaf,%d", chan->name, entry->type, entry->type); } else callback(bot, chan, data); @@ -141,7 +143,9 @@ void _get_userlist_with_invisible(struct ChanNode *chan, userlist_callback_t cal int i; for(i = 1; i < MAXCALLBACKS; i++) entry->callback[i] = NULL; - entry->data = data; + entry->data[0] = data; + for(i = 1; i < MAXCALLBACKS; i++) + entry->data[i] = NULL; putsock(bot, "WHO %s,%d d%%tuhnaf,%d", chan->name, entry->type, entry->type); } else callback(bot, chan, data); @@ -179,7 +183,9 @@ void get_userauth(struct UserNode *user, userauth_callback_t callback, void *dat int i; for(i = 1; i < MAXCALLBACKS; i++) entry->callback[i] = NULL; - entry->data = data; + entry->data[0] = data; + for(i = 1; i < MAXCALLBACKS; i++) + entry->data[i] = NULL; //WHO ".$user->getNick().",".$id." %tuhna,".$id putsock(bot, "WHO %s,%d %%tuhna,%d", user->nick, entry->type, entry->type); } @@ -257,7 +263,7 @@ void recv_whohandler_354(struct ClientSocket *client, char **argv, unsigned int for(i = 0; i < MAXCALLBACKS; i++) { userauth_callback_t *callback = entry->callback[i]; if(!callback) break; - callback(client, entry->user->nick, entry->user, entry->data); + callback(client, entry->user->nick, entry->user, entry->data[i]); } } } @@ -278,7 +284,7 @@ void recv_whohandler_315(struct ClientSocket *client, char **argv, unsigned int for(i = 0; i < MAXCALLBACKS; i++) { callback = entry->callback[i]; if(!callback) break; - callback(client, entry->chan, entry->data); + callback(client, entry->chan, entry->data[i]); } if(entry->chan->flags & CHANFLAG_HAVE_INVISIBLES) { //remove all invisible users again @@ -297,7 +303,7 @@ void recv_whohandler_315(struct ClientSocket *client, char **argv, unsigned int for(i = 0; i < MAXCALLBACKS; i++) { callback = entry->callback[i]; if(!callback) break; - callback(client, entry->user->nick, NULL, entry->data); + callback(client, entry->user->nick, NULL, entry->data[i]); } } } -- 2.20.1