Commit Diff


commit - 0dd0015d1606aebdf20c498ab9cd5b253b751ae0
commit + e708790566cd2874c8332cde7779ff6eef5f9c3c
blob - 155bae9921674652e9ed5d342209617339f63ac4
blob + 4606d65b680bb245bbc4a3e5e875ac7190d1a06b
--- ChangeLog
+++ 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 $
blob - dbf26fe2bec01fe806e42962bb5cdf53d47610f9
blob + f20ef1912818d258745191150d06def8e3ac06ae
--- src/ngircd/irc-channel.c
+++ 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 <assert.h>
@@ -43,7 +43,7 @@ static char UNUSED id[] = "$Id: irc-channel.c,v 1.31 2
 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;
 
-	/* Channel-Namen durchgehen */
-	chan = NULL;
-	channame = strtok( Req->argv[0], "," );
-	while( channame )
+	channame = Req->argv[0];
+	channame_ptr = strchr(channame, ',');
+	if (channame_ptr) *channame_ptr = '\0';
+
+	/* Channel-Namen durchgehen */
+	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 */