]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-login.c
- Neue Funktion IRC_LIST() begonnen zu implementieren.
[ngircd-alex.git] / src / ngircd / irc-login.c
index 5333570fe0ea7311520564dbb93e463bec8ffa66..a23788c23ea41871a34d68d70e50f7029c5ae6cf 100644 (file)
@@ -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-login.c,v 1.8 2002/03/12 14:37:52 alex Exp $
+ * $Id: irc-login.c,v 1.13 2002/04/14 14:02:35 alex Exp $
  *
  * irc-login.c: Anmeldung und Abmeldung im IRC
  */
@@ -100,7 +100,7 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
                /* "Ziel-Client" ermitteln */
                if( Client_Type( Client ) == CLIENT_SERVER )
                {
-                       target = Client_GetFromID( Req->prefix );
+                       target = Client_Search( Req->prefix );
                        if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] );
                }
                else
@@ -116,7 +116,7 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
                 * wenn wir es nicht so machen. Ob es so okay ist? Hm ... */
                if( strcmp( Client_ID( target ), Req->argv[0] ) == 0 ) return CONNECTED;
 #endif
-               
+
                /* pruefen, ob Nick bereits vergeben. Speziallfall: der Client
                 * will nur die Gross- und Kleinschreibung aendern. Das darf
                 * er natuerlich machen :-) */
@@ -140,7 +140,16 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
                else
                {
                        /* Nick-Aenderung */
-                       Log( LOG_INFO, "User \"%s\" changed nick: \"%s\" -> \"%s\".", Client_Mask( target ), Client_ID( target ), Req->argv[0] );
+                       if( Client_Conn( target ) > NONE )
+                       {
+                               /* lokaler Client */
+                               Log( LOG_INFO, "User \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".", Client_Mask( target ), Client_Conn( target ), Client_ID( target ), Req->argv[0] );
+                       }
+                       else
+                       {
+                               /* Remote-Client */
+                               Log( LOG_DEBUG, "User \"%s\" changed nick: \"%s\" -> \"%s\".", Client_Mask( target ), Client_ID( target ), Req->argv[0] );
+                       }
 
                        /* alle betroffenen User und Server ueber Nick-Aenderung informieren */
                        if( Client_Type( Client ) == CLIENT_USER ) IRC_WriteStrClientPrefix( Client, Client, "NICK :%s", Req->argv[0] );
@@ -161,7 +170,7 @@ GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
                if( Req->argc != 7 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
 
                /* Nick ueberpruefen */
-               c = Client_GetFromID( Req->argv[0] );
+               c = Client_Search( Req->argv[0] );
                if( c )
                {
                        /* Der neue Nick ist auf diesem Server bereits registriert:
@@ -243,19 +252,7 @@ GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req )
        assert( Client != NULL );
        assert( Req != NULL );
 
-       if(( Client_Type( Client ) == CLIENT_USER ) || ( Client_Type( Client ) == CLIENT_SERVICE ))
-       {
-               /* User / Service */
-               
-               /* Falsche Anzahl Parameter? */
-               if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
-               if( Req->argc == 0 ) Conn_Close( Client_Conn( Client ), "Got QUIT command.", NULL, TRUE );
-               else Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argv[0], TRUE );
-               
-               return DISCONNECTED;
-       }
-       else if ( Client_Type( Client ) == CLIENT_SERVER )
+       if ( Client_Type( Client ) == CLIENT_SERVER )
        {
                /* Server */
 
@@ -275,7 +272,18 @@ GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req )
 
                return CONNECTED;
        }
-       else return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
+       else
+       {
+               /* User, Service, oder noch nicht registriert */
+               
+               /* Falsche Anzahl Parameter? */
+               if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+
+               if( Req->argc == 0 ) Conn_Close( Client_Conn( Client ), "Got QUIT command.", NULL, TRUE );
+               else Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argv[0], TRUE );
+               
+               return DISCONNECTED;
+       }
 } /* IRC_QUIT */
 
 
@@ -297,12 +305,12 @@ GLOBAL BOOLEAN IRC_PING( CLIENT *Client, REQUEST *Req )
        if( Req->argc > 1 )
        {
                /* es wurde ein Ziel-Client angegeben */
-               target = Client_GetFromID( Req->argv[1] );
+               target = Client_Search( Req->argv[1] );
                if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[1] );
                if( target != Client_ThisServer( ))
                {
                        /* ok, forwarden */
-                       if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_GetFromID( Req->prefix );
+                       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 );
                        return IRC_WriteStrClientPrefix( target, from, "PING %s :%s", Client_ID( from ), Req->argv[1] );
@@ -330,12 +338,12 @@ GLOBAL BOOLEAN IRC_PONG( CLIENT *Client, REQUEST *Req )
        /* forwarden? */
        if( Req->argc == 2 )
        {
-               target = Client_GetFromID( Req->argv[1] );
+               target = Client_Search( Req->argv[1] );
                if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[1] );
                if( target != Client_ThisServer( ))
                {
                        /* ok, forwarden */
-                       if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_GetFromID( Req->prefix );
+                       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 );
                        return IRC_WriteStrClientPrefix( target, from, "PONG %s :%s", Client_ID( from ), Req->argv[1] );
@@ -343,7 +351,7 @@ GLOBAL BOOLEAN IRC_PONG( CLIENT *Client, REQUEST *Req )
        }
 
        /* Der Connection-Timestamp wurde schon beim Lesen aus dem Socket
-               * aktualisiert, daher muss das hier nicht mehr gemacht werden. */
+        * aktualisiert, daher muss das hier nicht mehr gemacht werden. */
 
        if( Client_Conn( Client ) > NONE ) Log( LOG_DEBUG, "Connection %d: received PONG. Lag: %ld seconds.", Client_Conn( Client ), time( NULL ) - Conn_LastPing( Client_Conn( Client )));
        else Log( LOG_DEBUG, "Connection %d: received PONG.", Client_Conn( Client ));
@@ -397,7 +405,7 @@ LOCAL VOID Kill_Nick( CHAR *Nick, CHAR *Reason )
        IRC_WriteStrServers( NULL, "KILL %s :%s", Nick, Reason );
 
        /* Ggf. einen eigenen Client toeten */
-       c = Client_GetFromID( Nick );
+       c = Client_Search( Nick );
        if( c && ( Client_Conn( c ) != NONE )) Conn_Close( Client_Conn( c ), NULL, Reason, TRUE );
 } /* Kill_Nick */