X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fclient.c;h=913370c806f458503a52302b3f24e21c00942546;hb=ac9da09e87b16c8e24e78f95947eadc62e314ea3;hp=8767c55f43f8811a0c2644dee7529e3b172e1826;hpb=118adda8d8b5ade51a495511a64998c9fc0d73f5;p=ngircd-alex.git diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 8767c55f..913370c8 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 comBase beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: client.c,v 1.8 2001/12/27 16:54:51 alex Exp $ + * $Id: client.c,v 1.12 2001/12/29 20:18:18 alex Exp $ * * client.c: Management aller Clients * @@ -21,6 +21,18 @@ * Server gewesen, so existiert eine entsprechende CONNECTION-Struktur. * * $Log: client.c,v $ + * Revision 1.12 2001/12/29 20:18:18 alex + * - neue Funktion Client_SetHostname(). + * + * Revision 1.11 2001/12/29 03:10:47 alex + * - Client-Modes implementiert; Loglevel mal wieder angepasst. + * + * Revision 1.10 2001/12/27 19:13:47 alex + * - neue Funktion Client_Search(), besseres Logging. + * + * Revision 1.9 2001/12/27 17:15:29 alex + * - der eigene Hostname wird nun komplet (als FQDN) ermittelt. + * * Revision 1.8 2001/12/27 16:54:51 alex * - neue Funktion Client_GetID(), liefert die "Client ID". * @@ -56,6 +68,7 @@ #include #include #include +#include #include #include "client.h" @@ -79,6 +92,8 @@ LOCAL CLIENT *New_Client_Struct( VOID ); GLOBAL VOID Client_Init( VOID ) { + struct hostent *h; + This_Server = New_Client_Struct( ); if( ! This_Server ) { @@ -91,7 +106,11 @@ GLOBAL VOID Client_Init( VOID ) This_Server->type = CLIENT_SERVER; This_Server->conn_id = NONE; This_Server->introducer = This_Server; + gethostname( This_Server->host, CLIENT_HOST_LEN ); + h = gethostbyname( This_Server->host ); + if( h ) strcpy( This_Server->host, h->h_name ); + strcpy( This_Server->nick, This_Server->host ); My_Clients = This_Server; @@ -130,11 +149,10 @@ GLOBAL CLIENT *Client_NewLocal( CONN_ID Idx, CHAR *Hostname ) client = New_Client_Struct( ); if( ! client ) return NULL; - /* Initgialisieren */ + /* Initialisieren */ client->conn_id = Idx; client->introducer = This_Server; - strncpy( client->host, Hostname, CLIENT_HOST_LEN ); - client->host[CLIENT_HOST_LEN] = '\0'; + Client_SetHostname( client, Hostname ); /* Verketten */ client->next = My_Clients; @@ -160,6 +178,9 @@ GLOBAL VOID Client_Destroy( CLIENT *Client ) { if( last ) last->next = c->next; else My_Clients = c->next; + + if( c->type == CLIENT_USER ) Log( LOG_NOTICE, "User \"%s!%s@%s\" (%s) exited (connection %d).", c->nick, c->user, c->host, c->name, c->conn_id ); + free( c ); break; } @@ -169,6 +190,16 @@ GLOBAL VOID Client_Destroy( CLIENT *Client ) } /* Client_Destroy */ +GLOBAL VOID Client_SetHostname( CLIENT *Client, CHAR *Hostname ) +{ + /* Hostname eines Clients setzen */ + + assert( Client != NULL ); + strncpy( Client->host, Hostname, CLIENT_HOST_LEN ); + Client->host[CLIENT_HOST_LEN] = '\0'; +} /* Client_SetHostname */ + + GLOBAL CLIENT *Client_GetFromConn( CONN_ID Idx ) { /* Client-Struktur, die zur lokalen Verbindung Idx gehoert @@ -240,6 +271,25 @@ GLOBAL CHAR *Client_GetID( CLIENT *Client ) } /* Client_GetID */ +GLOBAL CLIENT *Client_Search( CHAR *ID ) +{ + /* Client suchen, auf den ID passt */ + + CLIENT *c; + + assert( ID != NULL ); + + c = My_Clients; + while( c ) + { + if( strcasecmp( c->nick, ID ) == 0 ) return c; + c = c->next; + } + + return NULL; +} /* Client_Search */ + + LOCAL CLIENT *New_Client_Struct( VOID ) { /* Neue CLIENT-Struktur pre-initialisieren */ @@ -264,6 +314,7 @@ LOCAL CLIENT *New_Client_Struct( VOID ) strcpy( c->user, "" ); strcpy( c->name, "" ); for( i = 0; i < MAX_CHANNELS; c->channels[i++] = NULL ); + strcpy( c->modes, "" ); return c; } /* New_Client */