about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2002-11-24 16:36:03 +0000
committerAlexander Barton <alex@barton.de>2002-11-24 16:36:03 +0000
commit1fd9216ca453af260887db338131031c0ab73d24 (patch)
treeee93b5b5ac5992b22073ee099c12e86f843e2da0
parenta7eb18db4eb2511e9bc5169fab46cf3a291e4362 (diff)
downloadngircd-1fd9216ca453af260887db338131031c0ab73d24.tar.gz
ngircd-1fd9216ca453af260887db338131031c0ab73d24.zip
- MOTD kann nun auch an andere Server delegiert werden.
-rw-r--r--src/ngircd/irc.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c
index 197f2eaa..8c362ba6 100644
--- a/src/ngircd/irc.c
+++ b/src/ngircd/irc.c
@@ -9,7 +9,7 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: irc.c,v 1.100 2002/11/22 23:31:56 alex Exp $
+ * $Id: irc.c,v 1.101 2002/11/24 16:36:03 alex Exp $
  *
  * irc.c: IRC-Befehle
  */
@@ -44,15 +44,35 @@
 GLOBAL BOOLEAN
 IRC_MOTD( CLIENT *Client, REQUEST *Req )
 {
+	CLIENT *from, *target;
+
 	assert( Client != NULL );
 	assert( Req != NULL );
 
-	if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
+	if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
 
 	/* Falsche Anzahl Parameter? */
-	if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+	if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+	/* From aus Prefix ermitteln */
+	if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
+	else from = Client;
+	if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix );
+	
+	if( Req->argc == 1 )
+	{
+		/* 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_ThisServer( ))
+		{
+			/* Ok, anderer Server ist das Ziel: forwarden */
+			return IRC_WriteStrClientPrefix( target, from, "MOTD %s", Req->argv[0] );
+		}
+	}
 
-	return IRC_Show_MOTD( Client );
+	return IRC_Show_MOTD( from );
 } /* IRC_MOTD */