*** VERSION 5.2.0 ***
[NeonServV5.git] / src / WHOHandler.c
index 961cfab948d604e03f225b9ceb4980baaefe1a06..2c46b25dce873a86a31cf51ba02a4ed72aeb5b71 100644 (file)
@@ -1,4 +1,4 @@
-/* WHOHandler.c - NeonServ v5.1
+/* WHOHandler.c - NeonServ v5.2
  * Copyright (C) 2011  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -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);
@@ -156,6 +160,7 @@ void get_userauth(struct UserNode *user, userauth_callback_t callback, void *dat
             for(i = 1; i < MAXCALLBACKS; i++) {
                 if(!entry->callback[i]) {
                     entry->callback[i] = callback;
+                    entry->data[i] = data;
                     return;
                 }
             }
@@ -179,7 +184,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,15 +264,16 @@ 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]);
         }
     }
 }
 
 void recv_whohandler_315(struct ClientSocket *client, char **argv, unsigned int argc) {
     if(argc < 2) return;
-    char *typestr = strstr(argv[1], ",") + 1;
+    char *typestr = strstr(argv[1], ",");
     if(!typestr) return;
+    typestr++;
     int type = atoi(typestr);
     if(!(type & WHOQUEUETYPE_ISONQUEUE)) return;
     struct WHOQueueEntry* entry = getNextWHOQueueEntry(client, 1);
@@ -278,7 +286,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 +305,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]);
             }
         }
     }