]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/client.c
- vergessene Variable bei Ping-Timeout-Logmeldung ergaenzt. Opsa.
[ngircd-alex.git] / src / ngircd / client.c
index fce073ac639606ba56c52c08d53cea93a0284c3f..15d83c0a56ac09bf7edbb9313ec0111d341b8e17 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.3 2001/12/24 01:31:14 alex Exp $
+ * $Id: client.c,v 1.7 2001/12/26 14:45:37 alex Exp $
  *
  * client.c: Management aller Clients
  *
  * Server gewesen, so existiert eine entsprechende CONNECTION-Struktur.
  *
  * $Log: client.c,v $
+ * Revision 1.7  2001/12/26 14:45:37  alex
+ * - "Code Cleanups".
+ *
+ * Revision 1.6  2001/12/26 03:19:16  alex
+ * - neue Funktion Client_Name().
+ *
+ * Revision 1.5  2001/12/25 22:04:26  alex
+ * - Aenderungen an den Debug- und Logging-Funktionen.
+ *
+ * Revision 1.4  2001/12/25 19:21:26  alex
+ * - Client-Typ ("Status") besser unterteilt, My_Clients ist zudem nun global.
+ *
  * Revision 1.3  2001/12/24 01:31:14  alex
  * - einige assert()'s eingestraeut.
  *
@@ -30,7 +42,6 @@
  *
  * Revision 1.1  2001/12/14 08:13:43  alex
  * - neues Modul begonnen :-)
- *
  */
 
 
 #include <unistd.h>
 #include <string.h>
 
+#include <exp.h>
+#include "client.h"
+
+#include <imp.h>
 #include "channel.h"
 #include "conn.h"
+#include "irc.h"
 #include "log.h"
+#include "messages.h"
 
 #include <exp.h>
-#include "client.h"
 
 
-LOCAL CLIENT *My_Clients;
+GLOBAL CLIENT *My_Clients;
 
 
 LOCAL CLIENT *New_Client_Struct( VOID );
@@ -93,11 +109,11 @@ GLOBAL VOID Client_Exit( VOID )
                free( c );
                c = next;
        }
-       if( cnt ) Log( LOG_DEBUG, "Freed %d client structure%s.", cnt, cnt == 1 ? "" : "s" );
+       if( cnt ) Log( LOG_INFO, "Freed %d client structure%s.", cnt, cnt == 1 ? "" : "s" );
 } /* Client Exit */
 
 
-GLOBAL CLIENT *Client_New_Local( CONN_ID Idx, CHAR *Hostname )
+GLOBAL CLIENT *Client_NewLocal( CONN_ID Idx, CHAR *Hostname )
 {
        /* Neuen lokalen Client erzeugen. */
        
@@ -120,7 +136,7 @@ GLOBAL CLIENT *Client_New_Local( CONN_ID Idx, CHAR *Hostname )
        My_Clients = client;
        
        return client;
-} /* Client_New_Local */
+} /* Client_NewLocal */
 
 
 GLOBAL VOID Client_Destroy( CLIENT *Client )
@@ -167,6 +183,44 @@ GLOBAL CLIENT *Client_GetFromConn( CONN_ID Idx )
 } /* Client_GetFromConn */
 
 
+GLOBAL CHAR *Client_Name( CLIENT *Client )
+{
+       assert( Client != NULL );
+
+       if( Client->nick[0] ) return Client->nick;
+       else return "*";
+} /* Client_Name */
+
+
+GLOBAL BOOLEAN Client_CheckNick( CLIENT *Client, CHAR *Nick )
+{
+       /* Nick ueberpruefen */
+
+       CLIENT *c;
+       
+       assert( Client != NULL );
+       assert( Nick != NULL );
+       
+       /* Nick zu lang? */
+       if( strlen( Nick ) > CLIENT_NICK_LEN ) return IRC_WriteStrClient( Client, This_Server, ERR_ERRONEUSNICKNAME_MSG, Client_Name( Client ), Nick );
+
+       /* Nick bereits vergeben? */
+       c = My_Clients;
+       while( c )
+       {
+               if( strcasecmp( c->nick, Nick ) == 0 )
+               {
+                       /* den Nick gibt es bereits */
+                       IRC_WriteStrClient( Client, This_Server, ERR_NICKNAMEINUSE_MSG, Client_Name( Client ), Nick );
+                       return FALSE;
+               }
+               c = c->next;
+       }
+
+       return TRUE;
+} /* Client_CheckNick */
+
+
 LOCAL CLIENT *New_Client_Struct( VOID )
 {
        /* Neue CLIENT-Struktur pre-initialisieren */