X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fclient.c;h=1aaabf609e2ebf9e9958078f489901cc0b0e890f;hb=fa7b3f0e4cbefdd51a499beabc4092bd3515ef42;hp=9cb472915bddaa19d98654604184fea33143e751;hpb=dadebb2196737dd553ca46cd6e1f8c5e5e9b0722;p=ngircd-alex.git diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 9cb47291..1aaabf60 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -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: client.c,v 1.57 2002/06/01 14:36:43 alex Exp $ + * $Id: client.c,v 1.64 2002/12/03 18:57:44 alex Exp $ * * client.c: Management aller Clients * @@ -53,12 +53,15 @@ #include +#define GETID_LEN (CLIENT_NICK_LEN-1) + 1 + (CLIENT_USER_LEN-1) + 1 + (CLIENT_HOST_LEN-1) + 1 + + LOCAL CLIENT *This_Server, *My_Clients; -LOCAL CHAR GetID_Buffer[CLIENT_ID_LEN]; +LOCAL CHAR GetID_Buffer[GETID_LEN]; -LOCAL INT Count PARAMS(( CLIENT_TYPE Type )); -LOCAL INT MyCount PARAMS(( CLIENT_TYPE Type )); +LOCAL LONG Count PARAMS(( CLIENT_TYPE Type )); +LOCAL LONG MyCount PARAMS(( CLIENT_TYPE Type )); LOCAL CLIENT *New_Client_Struct PARAMS(( VOID )); LOCAL VOID Generate_MyToken PARAMS(( CLIENT *Client )); @@ -102,7 +105,8 @@ Client_Exit( VOID ) CLIENT *c, *next; INT cnt; - Client_Destroy( This_Server, "Server going down.", NULL, FALSE ); + if( NGIRCd_Restart ) Client_Destroy( This_Server, "Server going down (restarting).", NULL, FALSE ); + else Client_Destroy( This_Server, "Server going down.", NULL, FALSE ); cnt = 0; c = My_Clients; @@ -352,7 +356,7 @@ Client_SetInfo( CLIENT *Client, CHAR *Info ) GLOBAL VOID Client_SetModes( CLIENT *Client, CHAR *Modes ) { - /* Hostname eines Clients setzen */ + /* Modes eines Clients setzen */ assert( Client != NULL ); assert( Modes != NULL ); @@ -362,6 +366,19 @@ Client_SetModes( CLIENT *Client, CHAR *Modes ) } /* Client_SetModes */ +GLOBAL VOID +Client_SetFlags( CLIENT *Client, CHAR *Flags ) +{ + /* Flags eines Clients setzen */ + + assert( Client != NULL ); + assert( Flags != NULL ); + + strncpy( Client->flags, Flags, CLIENT_FLAGS_LEN - 1 ); + Client->flags[CLIENT_FLAGS_LEN - 1] = '\0'; +} /* Client_SetFlags */ + + GLOBAL VOID Client_SetPassword( CLIENT *Client, CHAR *Pwd ) { @@ -636,6 +653,14 @@ Client_Modes( CLIENT *Client ) } /* Client_Modes */ +GLOBAL CHAR * +Client_Flags( CLIENT *Client ) +{ + assert( Client != NULL ); + return Client->flags; +} /* Client_Flags */ + + GLOBAL BOOLEAN Client_OperByMe( CLIENT *Client ) { @@ -691,7 +716,7 @@ Client_Mask( CLIENT *Client ) if( Client->type == CLIENT_SERVER ) return Client->id; - sprintf( GetID_Buffer, "%s!%s@%s", Client->id, Client->user, Client->host ); + snprintf( GetID_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, Client->host ); return GetID_Buffer; } /* Client_Mask */ @@ -783,8 +808,9 @@ Client_CheckID( CLIENT *Client, CHAR *ID ) if( strcasecmp( c->id, ID ) == 0 ) { /* die Server-ID gibt es bereits */ - sprintf( str, "ID \"%s\" already registered!", ID ); - Log( LOG_ERR, "%s (on connection %d)", str, Client->conn_id ); + sprintf( str, "ID \"%s\" already registered", ID ); + if( Client->conn_id != c->conn_id ) Log( LOG_ERR, "%s (on connection %d)!", str, c->conn_id ); + else Log( LOG_ERR, "%s (via network)!", str ); Conn_Close( Client->conn_id, str, str, TRUE ); return FALSE; } @@ -815,46 +841,46 @@ Client_Next( CLIENT *c ) } /* Client_Next */ -GLOBAL INT +GLOBAL LONG Client_UserCount( VOID ) { return Count( CLIENT_USER ); } /* Client_UserCount */ -GLOBAL INT +GLOBAL LONG Client_ServiceCount( VOID ) { return Count( CLIENT_SERVICE );; } /* Client_ServiceCount */ -GLOBAL INT +GLOBAL LONG Client_ServerCount( VOID ) { return Count( CLIENT_SERVER ); } /* Client_ServerCount */ -GLOBAL INT +GLOBAL LONG Client_MyUserCount( VOID ) { return MyCount( CLIENT_USER ); } /* Client_MyUserCount */ -GLOBAL INT +GLOBAL LONG Client_MyServiceCount( VOID ) { return MyCount( CLIENT_SERVICE ); } /* Client_MyServiceCount */ -GLOBAL INT +GLOBAL LONG Client_MyServerCount( VOID ) { CLIENT *c; - INT cnt; + LONG cnt; cnt = 0; c = My_Clients; @@ -867,11 +893,11 @@ Client_MyServerCount( VOID ) } /* Client_MyServerCount */ -GLOBAL INT +GLOBAL LONG Client_OperCount( VOID ) { CLIENT *c; - INT cnt; + LONG cnt; cnt = 0; c = My_Clients; @@ -884,11 +910,11 @@ Client_OperCount( VOID ) } /* Client_OperCount */ -GLOBAL INT +GLOBAL LONG Client_UnknownCount( VOID ) { CLIENT *c; - INT cnt; + LONG cnt; cnt = 0; c = My_Clients; @@ -928,11 +954,11 @@ Client_IsValidNick( CHAR *Nick ) } /* Client_IsValidNick */ -LOCAL INT +LOCAL LONG Count( CLIENT_TYPE Type ) { CLIENT *c; - INT cnt; + LONG cnt; cnt = 0; c = My_Clients; @@ -945,11 +971,11 @@ Count( CLIENT_TYPE Type ) } /* Count */ -LOCAL INT +LOCAL LONG MyCount( CLIENT_TYPE Type ) { CLIENT *c; - INT cnt; + LONG cnt; cnt = 0; c = My_Clients; @@ -972,7 +998,7 @@ New_Client_Struct( VOID ) c = malloc( sizeof( CLIENT )); if( ! c ) { - Log( LOG_EMERG, "Can't allocate memory!" ); + Log( LOG_EMERG, "Can't allocate memory! [New_Client_Struct]" ); return NULL; } @@ -993,6 +1019,7 @@ New_Client_Struct( VOID ) c->token = -1; c->mytoken = -1; strcpy( c->away, "" ); + strcpy( c->flags, "" ); return c; } /* New_Client */