-#define CONNECTED TRUE
-#define DISCONNECTED FALSE
-
-
-LOCAL BOOLEAN Check_Valid_User( CLIENT *Client );
-
-LOCAL BOOLEAN Hello_User( CLIENT *Client );
-LOCAL BOOLEAN Show_MOTD( CLIENT *Client );
-
-
-GLOBAL VOID IRC_Init( VOID )
-{
-} /* IRC_Init */
-
-
-GLOBAL VOID IRC_Exit( VOID )
-{
-} /* IRC_Exit */
-
-
-GLOBAL BOOLEAN IRC_WriteStrClient( CLIENT *Client, CLIENT *Prefix, CHAR *Format, ... )
-{
- /* Text an Clients, lokal bzw. remote, senden. */
-
- CHAR buffer[1000];
- BOOLEAN ok = CONNECTED;
- CONN_ID send_to;
- va_list ap;
-
- assert( Client != NULL );
- assert( Format != NULL );
-
- va_start( ap, Format );
- vsnprintf( buffer, 1000, Format, ap );
- va_end( ap );
-
- if( Client->conn_id != NONE ) send_to = Client->conn_id;
- else send_to = Client->introducer->conn_id;
-
- if( Prefix ) ok = Conn_WriteStr( Client->conn_id, ":%s %s", Client_GetID( Prefix ), buffer );
- else ok = Conn_WriteStr( Client->conn_id, buffer );
-
- return ok;
-} /* IRC_WriteStrClient */
-
-
-GLOBAL BOOLEAN IRC_WriteStrRelated( CLIENT *Client, CHAR *Format, ... )
-{
- CHAR buffer[1000];
- BOOLEAN ok = CONNECTED;
- va_list ap;
-
- assert( Client != NULL );
- assert( Format != NULL );
-
- va_start( ap, Format );
- vsnprintf( buffer, 1000, Format, ap );
- va_end( ap );
-
- /* an den Client selber */
- ok = IRC_WriteStrClient( Client, Client, buffer );
-
- return ok;
-} /* IRC_WriteStrRelated */
-
-
-GLOBAL BOOLEAN IRC_PASS( CLIENT *Client, REQUEST *Req )
-{
- assert( Client != NULL );
- assert( Req != NULL );
-
- if( Client->type == CLIENT_UNKNOWN )
- {
- Log( LOG_DEBUG, "Connection %d: got PASS command ...", Client->conn_id );
- return IRC_WriteStrClient( Client, This_Server, ERR_UNKNOWNCOMMAND_MSG, Client_Nick( Client ), Req->command );
- }
- else return IRC_WriteStrClient( Client, This_Server, ERR_ALREADYREGISTRED_MSG, Client_Nick( Client ));
-} /* IRC_PASS */
-
-
-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 )