about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2012-01-02 15:04:40 +0100
committerAlexander Barton <alex@barton.de>2012-01-02 15:04:40 +0100
commit408a74b86582a2fc315d61880f30d4ac050d8d8a (patch)
tree4765b60eb1e17dc70c2104249f734194b4ea3e21 /src
parentf47904bf954696803c0df8e756a57a3dabaa8845 (diff)
downloadngircd-408a74b86582a2fc315d61880f30d4ac050d8d8a.tar.gz
ngircd-408a74b86582a2fc315d61880f30d4ac050d8d8a.zip
IRC_ISON(): Code cleanup
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-info.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c
index ebb7be4a..48000bac 100644
--- a/src/ngircd/irc-info.c
+++ b/src/ngircd/irc-info.c
@@ -154,6 +154,15 @@ IRC_INFO(CLIENT * Client, REQUEST * Req)
 } /* IRC_INFO */
 
 
+/**
+ * Handler for the IRC "ISON" command.
+ *
+ * See RFC 2812, 4.9 "Ison message".
+ *
+ * @param Client The client from which this command has been received.
+ * @param Req Request structure with prefix and all parameters.
+ * @return CONNECTED or DISCONNECTED.
+ */
 GLOBAL bool
 IRC_ISON( CLIENT *Client, REQUEST *Req )
 {
@@ -162,32 +171,32 @@ IRC_ISON( CLIENT *Client, REQUEST *Req )
 	char *ptr;
 	int i;
 
-	assert( Client != NULL );
-	assert( Req != NULL );
+	assert(Client != NULL);
+	assert(Req != NULL);
 
-	/* Falsche Anzahl Parameter? */
-	if(( Req->argc < 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+	/* Bad number of arguments? */
+	if (Req->argc < 1)
+		return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+					  Client_ID(Client), Req->command);
 
-	strlcpy( rpl, RPL_ISON_MSG, sizeof rpl );
-	for( i = 0; i < Req->argc; i++ )
-	{
-		ptr = strtok( Req->argv[i], " " );
-		while( ptr )
-		{
-			ngt_TrimStr( ptr );
-			c = Client_Search( ptr );
-			if( c && ( Client_Type( c ) == CLIENT_USER ))
-			{
-				/* Dieser Nick ist "online" */
-				strlcat( rpl, ptr, sizeof( rpl ));
-				strlcat( rpl, " ", sizeof( rpl ));
+	strlcpy(rpl, RPL_ISON_MSG, sizeof rpl);
+	for (i = 0; i < Req->argc; i++) {
+		/* "All" ircd even parse ":<x> <y> ..." arguments and split
+		 * them up; so we do the same ... */
+		ptr = strtok(Req->argv[i], " ");
+		while (ptr) {
+			ngt_TrimStr(ptr);
+			c = Client_Search(ptr);
+			if (c && Client_Type(c) == CLIENT_USER) {
+				strlcat(rpl, ptr, sizeof(rpl));
+				strlcat(rpl, " ", sizeof(rpl));
 			}
-			ptr = strtok( NULL, " " );
+			ptr = strtok(NULL, " ");
 		}
 	}
 	ngt_TrimLastChr(rpl, ' ');
 
-	return IRC_WriteStrClient( Client, rpl, Client_ID( Client ) );
+	return IRC_WriteStrClient(Client, rpl, Client_ID(Client));
 } /* IRC_ISON */