X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fclient.c;h=1b72adc8bb92a49db74855f611d94ed873545f80;hb=4e56e5341f632827af3810e26cd59ac0c15b642b;hp=6c4edd193160e7e18a72df04a2a7ae1cdc573dc6;hpb=018e3516303dacbf6aaf277fd0104e13bc9c8455;p=ngircd-alex.git diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 6c4edd19..1b72adc8 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -17,7 +17,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: client.c,v 1.93 2006/10/07 10:40:52 fw Exp $"; +static char UNUSED id[] = "$Id: client.c,v 1.98 2008/04/04 19:30:01 fw Exp $"; #include "imp.h" #include @@ -55,6 +55,7 @@ static char GetID_Buffer[GETID_LEN]; static WHOWAS My_Whowas[MAX_WHOWAS]; static int Last_Whowas = -1; +static long Max_Users, My_Max_Users; static unsigned long Count PARAMS(( CLIENT_TYPE Type )); @@ -68,13 +69,6 @@ static CLIENT *Init_New_Client PARAMS((CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer, int Type, char *ID, char *User, char *Hostname, char *Info, int Hops, int Token, char *Modes, bool Idented)); -#ifndef Client_DestroyNow -GLOBAL void Client_DestroyNow PARAMS((CLIENT *Client )); -#endif - - -long Max_Users = 0, My_Max_Users = 0; - GLOBAL void Client_Init( void ) @@ -98,9 +92,10 @@ Client_Init( void ) This_Server->hops = 0; gethostname( This_Server->host, CLIENT_HOST_LEN ); - h = gethostbyname( This_Server->host ); - if( h ) strlcpy( This_Server->host, h->h_name, sizeof( This_Server->host )); - + if (!Conf_NoDNS) { + h = gethostbyname( This_Server->host ); + if (h) strlcpy(This_Server->host, h->h_name, sizeof(This_Server->host)); + } Client_SetID( This_Server, Conf_ServerName ); Client_SetInfo( This_Server, Conf_ServerInfo ); @@ -336,43 +331,14 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit ) } /* Client_Destroy */ -GLOBAL void -Client_DestroyNow( CLIENT *Client ) -{ - /* Destroy client structure immediately. This function is only - * intended for the connection layer to remove client structures - * of connections that can't be established! */ - - CLIENT *last, *c; - - assert( Client != NULL ); - - last = NULL; - c = My_Clients; - while( c ) - { - if( c == Client ) - { - /* Wir haben den Client gefunden: entfernen */ - if( last ) last->next = c->next; - else My_Clients = (CLIENT *)c->next; - free( c ); - break; - } - last = c; - c = (CLIENT *)c->next; - } -} /* Client_DestroyNow */ - - GLOBAL void Client_SetHostname( CLIENT *Client, char *Hostname ) { /* Hostname eines Clients setzen */ - + assert( Client != NULL ); assert( Hostname != NULL ); - + strlcpy( Client->host, Hostname, sizeof( Client->host )); } /* Client_SetHostname */ @@ -564,7 +530,7 @@ Client_ModeDel( CLIENT *Client, char Mode ) GLOBAL CLIENT * -Client_Search( char *Nick ) +Client_Search( const char *Nick ) { /* return Client-Structure that has the corresponding Nick. * If none is found, return NULL. @@ -641,7 +607,8 @@ Client_ID( CLIENT *Client ) assert( Client != NULL ); #ifdef DEBUG - if( Client->type == CLIENT_USER ) assert( strlen( Client->id ) < CLIENT_NICK_LEN ); + if(Client->type == CLIENT_USER) + assert(strlen(Client->id) < Conf_MaxNickLength); #endif if( Client->id[0] ) return Client->id; @@ -661,8 +628,7 @@ GLOBAL char * Client_User( CLIENT *Client ) { assert( Client != NULL ); - if( Client->user[0] ) return Client->user; - else return "~"; + return Client->user[0] ? Client->user : "~"; } /* Client_User */ @@ -916,9 +882,8 @@ GLOBAL unsigned long Client_MyServerCount( void ) { CLIENT *c; - unsigned long cnt; + unsigned long cnt = 0; - cnt = 0; c = My_Clients; while( c ) { @@ -933,9 +898,8 @@ GLOBAL unsigned long Client_OperCount( void ) { CLIENT *c; - unsigned long cnt; + unsigned long cnt = 0; - cnt = 0; c = My_Clients; while( c ) { @@ -987,7 +951,7 @@ Client_IsValidNick( const char *Nick ) if( Nick[0] == '#' ) return false; if( strchr( goodchars, Nick[0] )) return false; - if( strlen( Nick ) >= CLIENT_NICK_LEN ) return false; + if( strlen( Nick ) >= Conf_MaxNickLength) return false; ptr = Nick; while( *ptr )