- /* Nick ueberpruefen */
- c = Client_GetFromID( Req->argv[0] );
- if( c )
- {
- /* Der neue Nick ist auf diesem Server bereits registriert:
- * sowohl der neue, als auch der alte Client muessen nun
- * disconnectiert werden. */
- Log( LOG_ALERT, "Server %s introduces already registered nick %s!", Client_ID( Client ), Req->argv[0] );
- Kill_Nick( Req->argv[0] );
- return CONNECTED;
- }
-
- /* Server, zu dem der Client connectiert ist, suchen */
- intr_c = Client_GetFromToken( Client, atoi( Req->argv[4] ));
- if( ! intr_c )
- {
- Log( LOG_ALERT, "Server %s introduces nick %s with unknown host server!?", Client_ID( Client ), Req->argv[0] );
- Kill_Nick( Req->argv[0] );
- return CONNECTED;
- }
-
- /* Neue Client-Struktur anlegen */
- c = Client_NewRemoteUser( intr_c, Req->argv[0], atoi( Req->argv[1] ), Req->argv[2], Req->argv[3], atoi( Req->argv[4] ), Req->argv[5], Req->argv[6] );
- if( ! c )
- {
- /* Eine neue Client-Struktur konnte nicht angelegt werden.
- * Der Client muss disconnectiert werden, damit der Netz-
- * status konsistent bleibt. */
- Log( LOG_ALERT, "Can't allocate client structure! (on connection %d)", Client_Conn( Client ));
- Kill_Nick( Req->argv[0] );
- return CONNECTED;
- }
-
- Log( LOG_NOTICE, "User \"%s\" registered (via %s, on %s, %d hop%s).", Client_ID( c ), Client_ID( Client ), Client_ID( intr_c ), Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
-
- return CONNECTED;
- }
- else return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
-} /* IRC_NICK */
-
-
-GLOBAL BOOLEAN IRC_USER( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
-#ifndef STRICT_RFC
- if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_UNKNOWN )
-#else
- if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS )
-#endif
- {
- /* Falsche Anzahl Parameter? */
- if( Req->argc != 4 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
- Client_SetUser( Client, Req->argv[0] );
- Client_SetInfo( Client, Req->argv[3] );
-
- Log( LOG_DEBUG, "Connection %d: got USER command ...", Client_Conn( Client ));
- if( Client_Type( Client ) == CLIENT_GOTNICK ) return Hello_User( Client );
- else Client_SetType( Client, CLIENT_GOTUSER );
- return CONNECTED;
- }
- else if( Client_Type( Client ) == CLIENT_USER || Client_Type( Client ) == CLIENT_SERVER || Client_Type( Client ) == CLIENT_SERVICE )
- {
- return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
- }
- else return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-} /* IRC_USER */
-
-
-GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if( Client_Type( Client ) != CLIENT_SERVER && Client_Type( Client ) != CLIENT_SERVICE )
- {
- /* Falsche Anzahl Parameter? */
- if( Req->argc > 1 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
- Conn_Close( Client_Conn( Client ), "Client wants to quit." );
- return DISCONNECTED;
- }
- else return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-} /* IRC_QUIT */
-
-
-GLOBAL BOOLEAN IRC_PING( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-
- /* Falsche Anzahl Parameter? */
- if( Req->argc < 1 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOORIGIN_MSG, Client_ID( Client ));
- if( Req->argc > 1 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
- return IRC_WriteStrClient( Client, Client_ThisServer( ), "PONG %s :%s", Client_ID( Client_ThisServer( )), Client_ID( Client ));
-} /* IRC_PING */
-
-
-GLOBAL BOOLEAN IRC_PONG( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-
- /* Falsche Anzahl Parameter? */
- if( Req->argc < 1 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOORIGIN_MSG, Client_ID( Client ));
- if( Req->argc > 2 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
- /* Der Connection-Timestamp wurde schon beim Lesen aus dem Socket
- * aktualisiert, daher muss das hier nicht mehr gemacht werden. */
-
- Log( LOG_DEBUG, "Connection %d: received PONG.", Client_Conn( Client ));
- return CONNECTED;
-} /* IRC_PONG */
-
-
-GLOBAL BOOLEAN IRC_MOTD( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-
- /* Falsche Anzahl Parameter? */
- if( Req->argc != 0 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
- return Show_MOTD( Client );
-} /* IRC_MOTD */
-
-
-GLOBAL BOOLEAN IRC_PRIVMSG( CLIENT *Client, REQUEST *Req )
-{
- CLIENT *to;
-
- assert( Client != NULL );
- assert( Req != NULL );
-
- if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOTREGISTERED_MSG, Client_ID( Client ));
-
- /* Falsche Anzahl Parameter? */
- if( Req->argc == 0 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NORECIPIENT_MSG, Client_ID( Client ), Req->command );
- if( Req->argc == 1 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NOTEXTTOSEND_MSG, Client_ID( Client ));
- if( Req->argc > 2 ) return IRC_WriteStrClient( Client, Client_ThisServer( ), ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
-
- to = Client_Search( Req->argv[0] );
- if( to )
- {
- /* Okay, Ziel ist ein User */
- if( Client_Conn( Client ) >= 0 ) Conn_UpdateIdle( Client_Conn( Client ));
- return IRC_WriteStrClient( to, Client, "PRIVMSG %s :%s", Client_ID( to ), Req->argv[1] );