Commit Diff


commit - ae6a7e7c0be06a19d8a46bc4a90b076879db814d
commit + e17976a17287a9266740ebcdd22a4e2ececd72e1
blob - 3ce821a275e3d20205c659a141fcaa827c14cb95
blob + 2f1112e87be2ec86dd2e0fe35477fd0db61fab85
--- src/ngircd/irc-info.c
+++ src/ngircd/irc-info.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-info.c,v 1.13 2002/12/30 17:15:42 alex Exp $";
+static char UNUSED id[] = "$Id: irc-info.c,v 1.14 2003/01/01 13:30:35 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -63,7 +63,7 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req )
 	/* An anderen Server weiterleiten? */
 	if( target != Client_ThisServer( ))
 	{
-		if( ! target ) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
 
 		/* forwarden */
 		IRC_WriteStrClientPrefix( target, prefix, "ADMIN %s", Req->argv[0] );
@@ -142,7 +142,7 @@ IRC_LINKS( CLIENT *Client, REQUEST *Req )
 	if( Req->argc == 2 )
 	{
 		target = Client_Search( Req->argv[0] );
-		if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
 		else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LINKS %s %s", Req->argv[0], Req->argv[1] );
 	}
 
@@ -185,7 +185,7 @@ IRC_LUSERS( CLIENT *Client, REQUEST *Req )
 	if( Req->argc == 2 )
 	{
 		target = Client_Search( Req->argv[1] );
-		if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
 		else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LUSERS %s %s", Req->argv[0], Req->argv[1] );
 	}
 
@@ -220,7 +220,7 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req )
 	{
 		/* an anderen Server forwarden */
 		target = Client_Search( Req->argv[0] );
-		if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
 
 		if( target != Client_ThisServer( ))
 		{
@@ -255,7 +255,7 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req )
 	{
 		/* an anderen Server forwarden */
 		target = Client_Search( Req->argv[1] );
-		if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
 
 		if( target != Client_ThisServer( ))
 		{
@@ -350,7 +350,7 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
 	{
 		/* an anderen Server forwarden */
 		target = Client_Search( Req->argv[1] );
-		if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
 
 		if( target != Client_ThisServer( ))
 		{
@@ -427,7 +427,7 @@ IRC_TIME( CLIENT *Client, REQUEST *Req )
 	{
 		/* an anderen Server forwarden */
 		target = Client_Search( Req->argv[0] );
-		if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
 
 		if( target != Client_ThisServer( ))
 		{
@@ -505,7 +505,7 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req )
 	/* An anderen Server weiterleiten? */
 	if( target != Client_ThisServer( ))
 	{
-		if( ! target ) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
+		if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
 
 		/* forwarden */
 		IRC_WriteStrClientPrefix( target, prefix, "VERSION %s", Req->argv[0] );
@@ -597,40 +597,39 @@ GLOBAL BOOLEAN
 IRC_WHOIS( CLIENT *Client, REQUEST *Req )
 {
 	CLIENT *from, *target, *c;
-	CHAR str[LINE_LEN + 1], *ptr = NULL;
+	CHAR str[LINE_LEN + 1];
 	CL2CHAN *cl2chan;
 	CHANNEL *chan;
 
 	assert( Client != NULL );
 	assert( Req != NULL );
 
-	/* Falsche Anzahl Parameter? */
+	/* Bad number of parameters? */
 	if(( Req->argc < 1 ) || ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
 
-	/* Client suchen */
+	/* Search client */
 	c = Client_Search( Req->argv[Req->argc - 1] );
 	if(( ! c ) || ( Client_Type( c ) != CLIENT_USER )) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[Req->argc - 1] );
 
-	/* Empfaenger des WHOIS suchen */
+	/* Search sender of the WHOIS */
 	if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
 	else from = Client;
 	if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
 
-	/* Forwarden an anderen Server? */
+	/* Forward to other server? */
 	if( Req->argc > 1 )
 	{
-		/* angegebenen Ziel-Server suchen */
-		target = Client_Search( Req->argv[1] );
-		if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
-		ptr = Req->argv[1];
+		/* Search target server (can be specified as nick of that server!) */
+		target = Client_Search( Req->argv[0] );
+		if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
 	}
 	else target = Client_ThisServer( );
 
 	assert( target != NULL );
 
-	if(( Client_NextHop( target ) != Client_ThisServer( )) && ( Client_Type( Client_NextHop( target )) == CLIENT_SERVER )) return IRC_WriteStrClientPrefix( target, from, "WHOIS %s :%s", Req->argv[0], ptr );
+	if(( Client_NextHop( target ) != Client_ThisServer( )) && ( Client_Type( Client_NextHop( target )) == CLIENT_SERVER )) return IRC_WriteStrClientPrefix( target, from, "WHOIS %s :%s", Req->argv[0], Req->argv[1] );
 
-	/* Nick, User und Name */
+	/* Nick, user and name */
 	if( ! IRC_WriteStrClient( from, RPL_WHOISUSER_MSG, Client_ID( from ), Client_ID( c ), Client_User( c ), Client_Hostname( c ), Client_Info( c ))) return DISCONNECTED;
 
 	/* Server */
@@ -644,7 +643,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
 		chan = Channel_GetChannel( cl2chan );
 		assert( chan != NULL );
 
-		/* Channel-Name anhaengen */
+		/* Concatenate channel names */
 		if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str ));
 		if( strchr( Channel_UserModes( chan, c ), 'o' )) strlcat( str, "@", sizeof( str ));
 		else if( strchr( Channel_UserModes( chan, c ), 'v' )) strlcat( str, "+", sizeof( str ));
@@ -652,17 +651,17 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
 
 		if( strlen( str ) > ( LINE_LEN - CHANNEL_NAME_LEN - 4 ))
 		{
-			/* Zeile wird zu lang: senden! */
+			/* Line becomes too long: send it! */
 			if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
 			snprintf( str, sizeof( str ), RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c ));
 		}
 
-		/* naechstes Mitglied suchen */
+		/* next */
 		cl2chan = Channel_NextChannelOf( c, cl2chan );
 	}
 	if( str[strlen( str ) - 1] != ':')
 	{
-		/* Es sind noch Daten da, die gesendet werden muessen */
+		/* There is data left to send: */
 		if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
 	}
 
@@ -672,7 +671,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
 		if( ! IRC_WriteStrClient( from, RPL_WHOISOPERATOR_MSG, Client_ID( from ), Client_ID( c ))) return DISCONNECTED;
 	}
 
-	/* Idle (nur lokale Clients) */
+	/* Idle (only local clients) */
 	if( Client_Conn( c ) > NONE )
 	{
 		if( ! IRC_WriteStrClient( from, RPL_WHOISIDLE_MSG, Client_ID( from ), Client_ID( c ), Conn_GetIdle( Client_Conn ( c )))) return DISCONNECTED;