repo: ngircd
action: commit
revision: 
path_from: 
revision_from: e708790566cd2874c8332cde7779ff6eef5f9c3c:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit e708790566cd2874c8332cde7779ff6eef5f9c3c
Author: Alexander Barton 
Date:   Fri Sep 2 15:46:49 2005 +0000

    JOIN now supports more than one channel key at a time.

diff --git a/ChangeLog b/ChangeLog
index 155bae9921674652e9ed5d342209617339f63ac4..
index ..4606d65b680bb245bbc4a3e5e875ac7190d1a06b 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 dbf26fe2bec01fe806e42962bb5cdf53d47610f9..
index ..f20ef1912818d258745191150d06def8e3ac06ae 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 */

-----END OF PAGE-----