added stats module for neonserv.krypton-bouncer.de stats
[NeonServV5.git] / src / IRCParser.c
index da4f434e4cf19f8b2f1e41147e25d87ff1ae720e..220283e1408025789d54c1269c3900bbf8532e46 100644 (file)
@@ -721,10 +721,50 @@ static void client_renamed(struct ClientSocket *client) {
     }
 }
 
+static void raw_005_network(struct ClientSocket *client, char *value) {
+    if(!value) return;
+    //check all other networknames
+    //if they are NOT simular to value throw a warning
+    SYNCHRONIZE(cache_sync); //all bots connect to the same time so there is a higher chance that this code is running on multiple threads at the same time
+    if(client->network_name)
+        free(client->network_name);
+    client->network_name = strdup(value);
+    struct ClientSocket *bot;
+    for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
+        if(bot == client) continue;
+        if(!bot->network_name) continue;
+        if(stricmp(bot->network_name, value)) {
+            putlog(LOGLEVEL_ERROR, "WARNING: Network name '%s' (%s) differs from '%s' (%s)! Connecting to multiple IRC-Networks with one instance is NOT supported!\n", client->network_name, client->nick, bot->network_name, bot->nick);
+            break;
+        }
+    }
+    DESYNCHRONIZE(cache_sync);
+}
+
+static IRC_CMD(raw_005) {
+    char *ptr1 = merge_argv(argv, 1, argc);
+    char *ptr2, *name, *value;
+    do {
+        ptr2 = strchr(ptr1, ' ');
+        if(ptr2)
+            *ptr2 = '\0';
+        name = ptr1;
+        if((value = strchr(ptr1, '='))) {
+            *value = '\0';
+            value++;
+        }
+        if(!stricmp(name, "NETWORK")) raw_005_network(client, value);
+        if(ptr2)
+            ptr1 = ptr2 + 1;
+    } while(ptr2);
+    return 1;
+}
+
 void init_parser() {
     //all the raws we receive...
     register_irc_function("437", raw_437);
     register_irc_function("002", raw_002);
+    register_irc_function("005", raw_005);
     register_irc_function("251", raw_251);
     register_irc_function("254", raw_254);
     register_irc_function("324", raw_324);