]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/parse.c
- der Sniffer wird nun nur noch aktiviert, wenn auf Kommandozeile angegeben.
[ngircd-alex.git] / src / ngircd / parse.c
index 5329e3c331a2c7b9b8e8bb376f42b056d10d1185..8629d51712c30e9d7144e44c3e8747cf1dedbf3f 100644 (file)
@@ -9,11 +9,26 @@
  * 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.16 2002/01/05 23:23:20 alex Exp $
+ * $Id: parse.c,v 1.21 2002/01/18 11:12:11 alex Exp $
  *
  * parse.c: Parsen der Client-Anfragen
  *
  * $Log: parse.c,v $
+ * Revision 1.21  2002/01/18 11:12:11  alex
+ * - der Sniffer wird nun nur noch aktiviert, wenn auf Kommandozeile angegeben.
+ *
+ * Revision 1.20  2002/01/11 23:50:55  alex
+ * - LINKS implementiert, LUSERS begonnen.
+ *
+ * Revision 1.19  2002/01/09 01:08:42  alex
+ * - Parses handhabt Leerzeichen zw. Parametern nun etwas "lockerer".
+ *
+ * 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.
  *
@@ -82,6 +97,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "ngircd.h"
 #include "client.h"
 #include "conn.h"
 #include "irc.h"
@@ -127,7 +143,7 @@ GLOBAL BOOLEAN Parse_Request( CONN_ID Idx, CHAR *Request )
        assert( Request != NULL );
 
 #ifdef SNIFFER
-       Log( LOG_DEBUG, " <- connection %d: '%s'.", Idx, Request );
+       if( NGIRCd_Sniffer ) Log( LOG_DEBUG, " <- connection %d: '%s'.", Idx, Request );
 #endif
        
        Init_Request( &req );
@@ -143,6 +159,11 @@ GLOBAL BOOLEAN Parse_Request( CONN_ID Idx, CHAR *Request )
                ptr = strchr( Request, ' ' );
                if( ! ptr ) return Parse_Error( Idx, "Prefix without command!?" );
                *ptr = '\0';
+#ifndef STRICT_RFC
+               /* multiple Leerzeichen als Trenner zwischen
+                * Prefix und Befehl ignorieren */
+               while( *(ptr + 1) == ' ' ) ptr++;
+#endif
                start = ptr + 1;
        }
        else start = Request;
@@ -151,7 +172,15 @@ GLOBAL BOOLEAN Parse_Request( CONN_ID Idx, CHAR *Request )
 
        /* Befehl */
        ptr = strchr( start, ' ' );
-       if( ptr ) *ptr = '\0';
+       if( ptr )
+       {
+               *ptr = '\0';
+#ifndef STRICT_RFC
+               /* multiple Leerzeichen als Trenner vor
+               *Parametertrennern ignorieren */
+               while( *(ptr + 1) == ' ' ) ptr++;
+#endif
+       }
        req.command = start;
 
        if( ! Validate_Command( &req )) return Parse_Error( Idx, "Invalid command" );
@@ -173,7 +202,15 @@ GLOBAL BOOLEAN Parse_Request( CONN_ID Idx, CHAR *Request )
                        {
                                req.argv[req.argc] = start;
                                ptr = strchr( start, ' ' );
-                               if( ptr ) *ptr = '\0';
+                               if( ptr )
+                               {
+                                       *ptr = '\0';
+#ifndef STRICT_RFC
+                                       /* multiple Leerzeichen als
+                                        * Parametertrenner ignorieren */
+                                       while( *(ptr + 1) == ' ' ) ptr++;
+#endif
+                               }
                        }
                        
                        req.argc++;
@@ -266,12 +303,30 @@ LOCAL BOOLEAN Handle_Request( CONN_ID Idx, REQUEST *Req )
                /* Zielserver ermitteln */
                if(( Client_Type( client ) == CLIENT_SERVER ) && ( Req->argc > 0 )) target = Client_GetFromID( Req->argv[0] );
                else target = NULL;
-               if( ! target ) return TRUE;
+               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] ) return TRUE;
+               if( ! Req->prefix[0] )
+               {
+                       Log( LOG_WARNING, "Got status code without prefix!?" );
+                       return TRUE;
+               }
                else prefix = Client_GetFromID( Req->prefix );
-               if( ! prefix ) return TRUE;
+               if( ! prefix )
+               {
+                       Log( LOG_WARNING, "Got status code from unknown source: \"%s\"", Req->prefix );
+                       return TRUE;
+               }
 
                /* Statuscode weiterleiten */
                strcpy( str, Req->command );
@@ -305,9 +360,11 @@ LOCAL BOOLEAN Handle_Request( CONN_ID Idx, REQUEST *Req )
        else if( strcasecmp( Req->command, "DIE" ) == 0 ) return IRC_DIE( client, Req );
        else if( strcasecmp( Req->command, "RESTART" ) == 0 ) return IRC_RESTART( client, Req );
        else if( strcasecmp( Req->command, "ERROR" ) == 0 ) return IRC_ERROR( client, Req );
+       else if( strcasecmp( Req->command, "LUSERS" ) == 0 ) return IRC_LUSERS( client, Req );
+       else if( strcasecmp( Req->command, "LINKS" ) == 0 ) return IRC_LINKS( client, Req );
        
        /* Unbekannter Befehl */
-       if( Client_Type( client ) != CLIENT_SERVER ) IRC_WriteStrClient( client, Client_ThisServer( ), ERR_UNKNOWNCOMMAND_MSG, Client_ID( client ), Req->command );
+       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;