From e708790566cd2874c8332cde7779ff6eef5f9c3c Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Fri, 2 Sep 2005 15:46:49 +0000 Subject: [PATCH] JOIN now supports more than one channel key at a time. --- ChangeLog | 3 ++- src/ngircd/irc-channel.c | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 155bae99..4606d65b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ ngIRCd CVSHEAD + - JOIN now supports more than one channel key at a time. - Implementec numeric "333": Time and user name who set a channel topic. - Fixed server NOTICEs to users with "s" mode ("server messages"). - Enhanced the handler for PING and PONG commands: fix forwarding and enable @@ -638,4 +639,4 @@ ngIRCd 0.0.1, 31.12.2001 -- -$Id: ChangeLog,v 1.292 2005/09/02 12:50:25 alex Exp $ +$Id: ChangeLog,v 1.293 2005/09/02 15:46:49 alex Exp $ diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c index dbf26fe2..f20ef191 100644 --- a/src/ngircd/irc-channel.c +++ b/src/ngircd/irc-channel.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-channel.c,v 1.31 2005/09/02 12:50:25 alex Exp $"; +static char UNUSED id[] = "$Id: irc-channel.c,v 1.32 2005/09/02 15:46:49 alex Exp $"; #include "imp.h" #include @@ -43,7 +43,7 @@ static char UNUSED id[] = "$Id: irc-channel.c,v 1.31 2005/09/02 12:50:25 alex Ex GLOBAL bool IRC_JOIN( CLIENT *Client, REQUEST *Req ) { - char *channame, *key, *flags, *topic, modes[8]; + char *channame, *channame_ptr, *key, *key_ptr, *flags, *topic, modes[8]; bool is_new_chan, is_invited, is_banned; CLIENT *target; CHANNEL *chan; @@ -60,14 +60,22 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req ) if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); /* Are channel keys given? */ - if( Req->argc > 1 ) key = Req->argv[1]; - else key = NULL; + if (Req->argc > 1) { + key = Req->argv[1]; + key_ptr = strchr(key, ','); + if (key_ptr) *key_ptr = '\0'; + } + else + key = key_ptr = NULL; + + channame = Req->argv[0]; + channame_ptr = strchr(channame, ','); + if (channame_ptr) *channame_ptr = '\0'; /* Channel-Namen durchgehen */ - chan = NULL; - channame = strtok( Req->argv[0], "," ); - while( channame ) + while (channame) { + Log(LOG_INFO, "channame=%s, key=%s", channame, key ? key : "-"); chan = NULL; flags = NULL; /* wird der Channel neu angelegt? */ @@ -229,8 +237,19 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req ) IRC_WriteStrClient( Client, RPL_ENDOFNAMES_MSG, Client_ID( Client ), Channel_Name( chan )); } - /* naechsten Namen ermitteln */ - channame = strtok( NULL, "," ); + /* next channel? */ + channame = channame_ptr; + if (channame) { + channame++; + channame_ptr = strchr(channame, ','); + if (channame_ptr) *channame_ptr = '\0'; + + if (key_ptr) { + key = ++key_ptr; + key_ptr = strchr(key, ','); + if (key_ptr) *key_ptr = '\0'; + } + } } return CONNECTED; } /* IRC_JOIN */