]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/client.c
- Unterstuetzung fuer die Konfigurationsdatei eingebaut.
[ngircd-alex.git] / src / ngircd / client.c
index 6ce42397790d628edcb500aa5c84c75ecc5a30a3..5b8e6547ce75f06570f8f606189c994a6e40cd66 100644 (file)
@@ -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.10 2001/12/27 19:13:47 alex Exp $
+ * $Id: client.c,v 1.13 2001/12/30 19:26:11 alex Exp $
  *
  * client.c: Management aller Clients
  *
  * Server gewesen, so existiert eine entsprechende CONNECTION-Struktur.
  *
  * $Log: client.c,v $
+ * Revision 1.13  2001/12/30 19:26:11  alex
+ * - Unterstuetzung fuer die Konfigurationsdatei eingebaut.
+ *
+ * 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.
  *
@@ -69,6 +78,7 @@
 
 #include <imp.h>
 #include "channel.h"
+#include "conf.h"
 #include "conn.h"
 #include "irc.h"
 #include "log.h"
@@ -92,6 +102,7 @@ GLOBAL VOID Client_Init( VOID )
        if( ! This_Server )
        {
                Log( LOG_EMERG, "Can't allocate client structure for server! Going down." );
+               Log( LOG_ALERT, PACKAGE" exiting due to fatal errors!" );
                exit( 1 );
        }
 
@@ -105,7 +116,7 @@ GLOBAL VOID Client_Init( VOID )
        h = gethostbyname( This_Server->host );
        if( h ) strcpy( This_Server->host, h->h_name );
 
-       strcpy( This_Server->nick, This_Server->host );
+       strcpy( This_Server->nick, Conf_ServerName );
 
        My_Clients = This_Server;
 } /* Client_Init */
@@ -143,11 +154,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;
@@ -174,7 +184,7 @@ GLOBAL VOID Client_Destroy( CLIENT *Client )
                        if( last ) last->next = c->next;
                        else My_Clients = c->next;
 
-                       if( c->type == CLIENT_USER ) Log( LOG_INFO, "User \"%s!%s@%s\" (%s) exited.", c->nick, c->user, c->host, c->name );
+                       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;
@@ -185,6 +195,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
@@ -249,7 +269,7 @@ GLOBAL CHAR *Client_GetID( CLIENT *Client )
 
        assert( Client != NULL );
        
-       if( Client->type == CLIENT_SERVER ) return Client->host;
+       if( Client->type == CLIENT_SERVER ) return Client->nick;
 
        sprintf( GetID_Buffer, "%s!%s@%s", Client->nick, Client->user, Client->host );
        return GetID_Buffer;
@@ -299,6 +319,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 */