]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/client.c
- new Functions: Client_MaxUserCount(), Client_MyMaxUserCount, Adjust_Counters().
[ngircd.git] / src / ngircd / client.c
index a383e89783e02717b65e874b77820fb09d22a230..dee2ada5de29ad8834d7309e88c3e7aef1dafc48 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: client.c,v 1.65 2002/12/12 12:24:18 alex Exp $";
+static char UNUSED id[] = "$Id: client.c,v 1.67 2002/12/22 23:29:09 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -57,6 +57,10 @@ LOCAL LONG MyCount PARAMS(( CLIENT_TYPE Type ));
 
 LOCAL CLIENT *New_Client_Struct PARAMS(( VOID ));
 LOCAL VOID Generate_MyToken PARAMS(( CLIENT *Client ));
+LOCAL VOID Adjust_Counters PARAMS(( CLIENT *Client ));
+
+
+LONG Max_Users = 0, My_Max_Users = 0;
 
 
 GLOBAL VOID
@@ -97,7 +101,7 @@ Client_Exit( VOID )
        CLIENT *c, *next;
        INT cnt;
 
-       if( NGIRCd_Restart ) Client_Destroy( This_Server, "Server going down (restarting).", NULL, FALSE );
+       if( NGIRCd_SignalRestart ) Client_Destroy( This_Server, "Server going down (restarting).", NULL, FALSE );
        else Client_Destroy( This_Server, "Server going down.", NULL, FALSE );
        
        cnt = 0;
@@ -177,6 +181,9 @@ Client_New( CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer, INT Type, CHAR *
        client->next = (POINTER *)My_Clients;
        My_Clients = client;
 
+       /* Adjust counters */
+       Adjust_Counters( client );
+
        return client;
 } /* Client_New */
 
@@ -256,7 +263,7 @@ Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN SendQuit )
                                }
 
                                /* andere Server informieren */
-                               if( ! NGIRCd_Quit )
+                               if( ! NGIRCd_SignalQuit )
                                {
                                        if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
                                        else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :", c->id );
@@ -414,6 +421,7 @@ Client_SetType( CLIENT *Client, INT Type )
        assert( Client != NULL );
        Client->type = Type;
        if( Type == CLIENT_SERVER ) Generate_MyToken( Client );
+       Adjust_Counters( Client );
 } /* Client_SetType */
 
 
@@ -919,6 +927,20 @@ Client_UnknownCount( VOID )
 } /* Client_UnknownCount */
 
 
+GLOBAL LONG
+Client_MaxUserCount( VOID )
+{
+       return Max_Users;
+} /* Client_MaxUserCount */
+
+
+GLOBAL LONG
+Client_MyMaxUserCount( VOID )
+{
+       return My_Max_Users;
+} /* Client_MyMaxUserCount */
+
+
 GLOBAL BOOLEAN
 Client_IsValidNick( CHAR *Nick )
 {
@@ -1041,4 +1063,24 @@ Generate_MyToken( CLIENT *Client )
 } /* Generate_MyToken */
 
 
+LOCAL VOID
+Adjust_Counters( CLIENT *Client )
+{
+       LONG count;
+
+       assert( Client != NULL );
+
+       if( Client->type != CLIENT_USER ) return;
+       
+       if( Client->conn_id != NONE )
+       {
+               /* Local connection */
+               count = Client_MyUserCount( );
+               if( count > My_Max_Users ) My_Max_Users = count;
+       }
+       count = Client_UserCount( );
+       if( count > Max_Users ) Max_Users = count;
+} /* Adjust_Counters */
+
+
 /* -eof- */