* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: parse.c,v 1.13 2002/01/04 01:20:02 alex Exp $
+ * $Id: parse.c,v 1.18 2002/01/07 15:29:11 alex Exp $
*
* parse.c: Parsen der Client-Anfragen
*
* $Log: parse.c,v $
+ * Revision 1.18 2002/01/07 15:29:11 alex
+ * - Status-Codes an den Server selber werden ignoriert, besseres Logging.
+ *
+ * Revision 1.17 2002/01/06 17:41:44 alex
+ * - die Fehlermeldung "unbekannter Befehl" hatte ein falsches Format.
+ *
+ * Revision 1.16 2002/01/05 23:23:20 alex
+ * - generisches Forwarding von Zahlen-Statuscodes implementiert.
+ *
+ * Revision 1.15 2002/01/05 01:42:08 alex
+ * - an Server werden keine ERRORS mehr wegen unbekannter Befehle geschickt.
+ *
+ * Revision 1.14 2002/01/04 17:56:45 alex
+ * - neuer Befehl SQUIT.
+ *
* Revision 1.13 2002/01/04 01:20:02 alex
* - Client-Strukruren werden nur noch ueber Funktionen angesprochen.
*
#include <imp.h>
#include <assert.h>
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* Client-Request verarbeiten. Bei einem schwerwiegenden Fehler
* wird die Verbindung geschlossen und FALSE geliefert. */
- CLIENT *client;
+ CLIENT *client, *target, *prefix;
+ CHAR str[LINE_LEN];
+ INT i;
assert( Idx >= 0 );
assert( Req != NULL );
client = Client_GetFromConn( Idx );
assert( client != NULL );
+ /* Statuscode, der geforwarded werden muss? */
+ if(( strlen( Req->command ) == 3 ) && ( atoi( Req->command ) > 100 ))
+ {
+ /* Befehl ist ein Statuscode */
+
+ /* Zielserver ermitteln */
+ if(( Client_Type( client ) == CLIENT_SERVER ) && ( Req->argc > 0 )) target = Client_GetFromID( Req->argv[0] );
+ else target = NULL;
+ if( ! target )
+ {
+ if( target ) Log( LOG_WARNING, "Unknown target for status code: \"%s\"", Req->argv[0] );
+ else Log( LOG_WARNING, "Unknown target for status code!" );
+ return TRUE;
+ }
+ if( target == Client_ThisServer( ))
+ {
+ Log( LOG_DEBUG, "Ignored status code %s from \"%s\".", Req->command, Client_ID( client ));
+ return TRUE;
+ }
+
+ /* Quell-Client ermitteln */
+ if( ! Req->prefix[0] )
+ {
+ Log( LOG_WARNING, "Got status code without prefix!?" );
+ return TRUE;
+ }
+ else prefix = Client_GetFromID( Req->prefix );
+ if( ! prefix )
+ {
+ Log( LOG_WARNING, "Got status code from unknown source: \"%s\"", Req->prefix );
+ return TRUE;
+ }
+
+ /* Statuscode weiterleiten */
+ strcpy( str, Req->command );
+ for( i = 0; i < Req->argc; i++ )
+ {
+ if( i < Req->argc - 1 ) strcat( str, " " );
+ else strcat( str, " :" );
+ strcat( str, Req->argv[i] );
+ }
+ return IRC_WriteStrClientPrefix( target, prefix, str );
+ }
+
if( strcasecmp( Req->command, "PASS" ) == 0 ) return IRC_PASS( client, Req );
else if( strcasecmp( Req->command, "NICK" ) == 0 ) return IRC_NICK( client, Req );
else if( strcasecmp( Req->command, "USER" ) == 0 ) return IRC_USER( client, Req );
else if( strcasecmp( Req->command, "SERVER" ) == 0 ) return IRC_SERVER( client, Req );
else if( strcasecmp( Req->command, "NJOIN" ) == 0 ) return IRC_NJOIN( client, Req );
else if( strcasecmp( Req->command, "QUIT" ) == 0 ) return IRC_QUIT( client, Req );
+ else if( strcasecmp( Req->command, "SQUIT" ) == 0 ) return IRC_SQUIT( client, Req );
else if( strcasecmp( Req->command, "PING" ) == 0 ) return IRC_PING( client, Req );
else if( strcasecmp( Req->command, "PONG" ) == 0 ) return IRC_PONG( client, Req );
else if( strcasecmp( Req->command, "MOTD" ) == 0 ) return IRC_MOTD( client, Req );
else if( strcasecmp( Req->command, "ERROR" ) == 0 ) return IRC_ERROR( client, Req );
/* Unbekannter Befehl */
- IRC_WriteStrClient( client, Client_ThisServer( ), ERR_UNKNOWNCOMMAND_MSG, Client_ID( client ), Req->command );
- Log( LOG_DEBUG, "User \"%s\": Unknown command \"%s\", %d %s,%s prefix.", Client_Mask( client ), Req->command, Req->argc, Req->argc == 1 ? "parameter" : "parameters", Req->prefix ? "" : " no" );
+ if( Client_Type( client ) != CLIENT_SERVER ) IRC_WriteStrClient( client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( client ), Req->command );
+ Log( LOG_DEBUG, "Connection %d: Unknown command \"%s\", %d %s,%s prefix.", Client_Conn( client ), Req->command, Req->argc, Req->argc == 1 ? "parameter" : "parameters", Req->prefix ? "" : " no" );
return TRUE;
} /* Handle_Request */