X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2FIRCParser.c;h=220283e1408025789d54c1269c3900bbf8532e46;hp=da4f434e4cf19f8b2f1e41147e25d87ff1ae720e;hb=406c308308e4d131475a692cd425cb156e0776f1;hpb=7d9422966272d2d0998280521a8347d42bd8e1cb diff --git a/src/IRCParser.c b/src/IRCParser.c index da4f434..220283e 100644 --- a/src/IRCParser.c +++ b/src/IRCParser.c @@ -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);