-GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- /* Zumindest BitchX sendet NICK-USER in der falschen Reihenfolge. */
-#ifndef STRICT_RFC
- if( Client->type == CLIENT_UNKNOWN || Client->type == CLIENT_GOTPASS || Client->type == CLIENT_GOTNICK || Client->type == CLIENT_GOTUSER || Client->type == CLIENT_USER )
-#else
- if( Client->type == CLIENT_UNKNOWN || Client->type == CLIENT_GOTPASS || Client->type == CLIENT_GOTNICK || Client->type == CLIENT_USER )
-#endif
- {
- /* Falsche Anzahl Parameter? */
- if( Req->argc != 1 ) return IRC_WriteStrClient( Client, This_Server, ERR_NEEDMOREPARAMS_MSG, Client_Nick( Client ), Req->command );
-
- /* Ist der Client "restricted"? */
- if( strchr( Client->modes, 'r' )) return IRC_WriteStrClient( Client, This_Server, ERR_RESTRICTED_MSG, Client_Nick( Client ));
-
- /* Wenn der Client zu seinem eigenen Nick wechseln will, so machen
- * wir nichts. So macht es das Original und mind. Snak hat probleme,
- * wenn wir es nicht so machen. Ob es so okay ist? Hm ... */
-#ifndef STRICT_RFC
- if( strcmp( Client->nick, 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 :-) */
- if( strcasecmp( Client->nick, Req->argv[0] ) != 0 )
- {
- if( ! Client_CheckNick( Client, Req->argv[0] )) return CONNECTED;
- }
-
- if( Client->type == CLIENT_USER )
- {
- /* Nick-Aenderung: allen mitteilen! */
- Log( LOG_INFO, "User \"%s!%s@%s\" changed nick: \"%s\" -> \"%s\".", Client->nick, Client->user, Client->host, Client->nick, Req->argv[0] );
- IRC_WriteStrRelated( Client, "NICK :%s", Req->argv[0] );
- }
-
- /* Client-Nick registrieren */
- strcpy( Client->nick, Req->argv[0] );
-
- if( Client->type != CLIENT_USER )
- {
- /* Neuer Client */
- Log( LOG_DEBUG, "Connection %d: got NICK command ...", Client->conn_id );
- if( Client->type == CLIENT_GOTUSER ) return Hello_User( Client );
- else Client->type = CLIENT_GOTNICK;
- }
- return CONNECTED;
- }
- else return IRC_WriteStrClient( Client, This_Server, ERR_ALREADYREGISTRED_MSG, Client_Nick( Client ));
-} /* IRC_NICK */
-
-
-GLOBAL BOOLEAN IRC_USER( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
-#ifndef STRICT_RFC
- if( Client->type == CLIENT_GOTNICK || Client->type == CLIENT_GOTPASS || Client->type == CLIENT_UNKNOWN )
-#else
- if( Client->type == CLIENT_GOTNICK || Client->type == CLIENT_GOTPASS )
-#endif
- {
- /* Falsche Anzahl Parameter? */
- if( Req->argc != 4 ) return IRC_WriteStrClient( Client, This_Server, ERR_NEEDMOREPARAMS_MSG, Client_Nick( Client ), Req->command );
-
- strncpy( Client->user, Req->argv[0], CLIENT_USER_LEN );
- Client->user[CLIENT_USER_LEN - 1] = '\0';
- strncpy( Client->name, Req->argv[3], CLIENT_NAME_LEN );
- Client->name[CLIENT_NAME_LEN - 1] = '\0';
-
- Log( LOG_DEBUG, "Connection %d: got USER command ...", Client->conn_id );
- if( Client->type == CLIENT_GOTNICK ) return Hello_User( Client );
- else Client->type = CLIENT_GOTUSER;
- return CONNECTED;
- }
- else if( Client->type == CLIENT_USER || Client->type == CLIENT_SERVER || Client->type == CLIENT_SERVICE )
- {
- return IRC_WriteStrClient( Client, This_Server, ERR_ALREADYREGISTRED_MSG, Client_Nick( Client ));
- }
- else return IRC_WriteStrClient( Client, This_Server, ERR_NOTREGISTERED_MSG, Client_Nick( Client ));
-} /* IRC_USER */
-
-
-GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if( Client->type != CLIENT_SERVER && Client->type != CLIENT_SERVICE )
- {
- /* Falsche Anzahl Parameter? */
- if( Req->argc > 1 ) return IRC_WriteStrClient( Client, This_Server, ERR_NEEDMOREPARAMS_MSG, Client_Nick( Client ), Req->command );
-
- Conn_Close( Client->conn_id, "Client wants to quit." );
- return DISCONNECTED;
- }
- else return IRC_WriteStrClient( Client, This_Server, ERR_NOTREGISTERED_MSG, Client_Nick( Client ));
-} /* IRC_QUIT */
-
-
-GLOBAL BOOLEAN IRC_PING( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if( ! Check_Valid_User( Client )) return CONNECTED;
-
- /* Falsche Anzahl Parameter? */
- if( Req->argc < 1 ) return IRC_WriteStrClient( Client, This_Server, ERR_NOORIGIN_MSG, Client_Nick( Client ));
- if( Req->argc > 1 ) return IRC_WriteStrClient( Client, This_Server, ERR_NEEDMOREPARAMS_MSG, Client_Nick( Client ), Req->command );
-
- return IRC_WriteStrClient( Client, This_Server, "PONG %s :%s", Client_Nick( This_Server), Client_Nick( Client ));
-} /* IRC_PING */
-
-
-GLOBAL BOOLEAN IRC_PONG( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if( ! Check_Valid_User( Client )) return CONNECTED;
-
- /* Falsche Anzahl Parameter? */
- if( Req->argc < 1 ) return IRC_WriteStrClient( Client, This_Server, ERR_NOORIGIN_MSG, Client_Nick( Client ));
- if( Req->argc > 1 ) return IRC_WriteStrClient( Client, This_Server, ERR_NEEDMOREPARAMS_MSG, Client_Nick( 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_id );