repo: ngircd
action: commit
revision: 
path_from: 
revision_from: d0304b19a2aaab32df628637d6961a447078bbe3:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit d0304b19a2aaab32df628637d6961a447078bbe3
Author: Alexander Barton 
Date:   Sun Dec 22 23:29:09 2002 +0000

    - new Functions: Client_MaxUserCount(), Client_MyMaxUserCount, Adjust_Counters().

diff --git a/src/ngircd/client.c b/src/ngircd/client.c
index 420fc32e3d4859a19eb3ba9d7d093aaec8f80bc5..
index ..dee2ada5de29ad8834d7309e88c3e7aef1dafc48 100644
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -17,7 +17,7 @@

 #include "portab.h"

-static char UNUSED id[] = "$Id: client.c,v 1.66 2002/12/19 04:33:27 alex Exp $";
+static char UNUSED id[] = "$Id: client.c,v 1.67 2002/12/22 23:29:09 alex Exp $";

 #include "imp.h"
 #include 
@@ -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
@@ -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 */

@@ -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- */
diff --git a/src/ngircd/client.h b/src/ngircd/client.h
index edee38e4291dc6f1ff39641bcf1b3102b8fc1378..
index ..dc2c9924ffb9b0c2f4317ecfc1f8728e1b168886 100644
--- a/src/ngircd/client.h
+++ b/src/ngircd/client.h
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: client.h,v 1.32 2002/12/12 12:23:43 alex Exp $
+ * $Id: client.h,v 1.33 2002/12/22 23:29:09 alex Exp $
  *
  * Client management (header)
  */
@@ -130,6 +130,8 @@ GLOBAL LONG Client_UnknownCount PARAMS((VOID ));
 GLOBAL LONG Client_MyUserCount PARAMS((VOID ));
 GLOBAL LONG Client_MyServiceCount PARAMS((VOID ));
 GLOBAL LONG Client_MyServerCount PARAMS((VOID ));
+GLOBAL LONG Client_MaxUserCount PARAMS(( VOID ));
+GLOBAL LONG Client_MyMaxUserCount PARAMS(( VOID ));

 GLOBAL BOOLEAN Client_IsValidNick PARAMS((CHAR *Nick ));

-----END OF PAGE-----