about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2005-09-02 15:46:49 +0000
committerAlexander Barton <alex@barton.de>2005-09-02 15:46:49 +0000
commite708790566cd2874c8332cde7779ff6eef5f9c3c (patch)
tree423c316f4e2d3bbb07e949713443c3ca6345b112 /src
parent0dd0015d1606aebdf20c498ab9cd5b253b751ae0 (diff)
downloadngircd-e708790566cd2874c8332cde7779ff6eef5f9c3c.tar.gz
ngircd-e708790566cd2874c8332cde7779ff6eef5f9c3c.zip
JOIN now supports more than one channel key at a time.
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-channel.c37
1 files changed, 28 insertions, 9 deletions
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 <assert.h>
@@ -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 */