if we use multiple callbacks we also need to save the different data arguments for...
authorpk910 <philipp@zoelle1.de>
Sun, 23 Oct 2011 17:48:28 +0000 (19:48 +0200)
committerpk910 <philipp@zoelle1.de>
Sun, 23 Oct 2011 18:28:06 +0000 (20:28 +0200)
src/WHOHandler.c

index 961cfab948d604e03f225b9ceb4980baaefe1a06..3bf9158c27a2adc9b29a79fe53419b0c3def77bd 100644 (file)
@@ -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]);
             }
         }
     }