Commit Diff


commit - b3ccaa76b657566d6ba9f9f438e036a308af3beb
commit + b9d701dbeb5566a6d8f54ec15aaf0b2a4670edad
blob - e5f29e493d5d1e81703b49ce90ebd02c39b872a8
blob + 768445dc8f738c2de08ae03c6a067ef09913e453
--- src/ngircd/client.c
+++ src/ngircd/client.c
@@ -9,7 +9,7 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: client.c,v 1.28 2002/01/11 23:50:40 alex Exp $
+ * $Id: client.c,v 1.29 2002/01/16 22:10:35 alex Exp $
  *
  * client.c: Management aller Clients
  *
@@ -21,6 +21,9 @@
  * Server gewesen, so existiert eine entsprechende CONNECTION-Struktur.
  *
  * $Log: client.c,v $
+ * Revision 1.29  2002/01/16 22:10:35  alex
+ * - neue Funktionen Client_xxxCount().
+ *
  * Revision 1.28  2002/01/11 23:50:40  alex
  * - Hop-Count fuer den Server selber (0) wird korrekt initialisiert.
  *
@@ -147,6 +150,9 @@ LOCAL CLIENT *This_Server, *My_Clients;
 LOCAL CHAR GetID_Buffer[CLIENT_ID_LEN];
 
 
+LOCAL INT Count( CLIENT_TYPE Type );
+LOCAL INT MyCount( CLIENT_TYPE Type );
+
 LOCAL CLIENT *New_Client_Struct( VOID );
 LOCAL VOID Generate_MyToken( CLIENT *Client );
 
@@ -225,7 +231,7 @@ GLOBAL CLIENT *Client_NewRemoteServer( CLIENT *Introdu
 GLOBAL CLIENT *Client_NewRemoteUser( CLIENT *Introducer, CHAR *Nick, INT Hops, CHAR *User, CHAR *Hostname, INT Token, CHAR *Modes, CHAR *Info, BOOLEAN Idented )
 {
 	/* Neuen Remote-Client erzeugen: Wrapper-Funktion fuer Client_New (). */
-	return Client_New( NONE, Introducer, CLIENT_USER, Nick, User, Hostname, Info, Hops, Token, NULL, Idented );
+	return Client_New( NONE, Introducer, CLIENT_USER, Nick, User, Hostname, Info, Hops, Token, Modes, Idented );
 } /* Client_NewRemoteUser */
 
 
@@ -763,8 +769,108 @@ GLOBAL CLIENT *Client_Next( CLIENT *c )
 	assert( c != NULL );
 	return c->next;
 } /* Client_Next */
+
+
+GLOBAL INT Client_UserCount( VOID )
+{
+	return Count( CLIENT_USER );
+} /* Client_UserCount */
+
+
+GLOBAL INT Client_ServiceCount( VOID )
+{
+	return Count( CLIENT_SERVICE );;
+} /* Client_ServiceCount */
+
+
+GLOBAL INT Client_ServerCount( VOID )
+{
+	return Count( CLIENT_SERVER );
+} /* Client_ServerCount */
+
+
+GLOBAL INT Client_MyUserCount( VOID )
+{
+	return MyCount( CLIENT_USER );
+} /* Client_MyUserCount */
+
+
+GLOBAL INT Client_MyServiceCount( VOID )
+{
+	return MyCount( CLIENT_SERVICE );
+} /* Client_MyServiceCount */
+
+
+GLOBAL INT Client_MyServerCount( VOID )
+{
+	return MyCount( CLIENT_SERVER );
+} /* Client_MyServerCount */
+
+
+GLOBAL INT Client_OperCount( VOID )
+{
+	CLIENT *c;
+	INT cnt;
+
+	cnt = 0;
+	c = My_Clients;
+	while( c )
+	{
+		if( c && ( c->type == CLIENT_USER ) && ( strchr( c->modes, 'o' ))) cnt++;
+		c = c->next;
+	}
+	return cnt;
+} /* Client_OperCount */
 
 
+GLOBAL INT Client_UnknownCount( VOID )
+{
+	CLIENT *c;
+	INT cnt;
+
+	cnt = 0;
+	c = My_Clients;
+	while( c )
+	{
+		if( c && ( c->type != CLIENT_USER ) && ( c->type != CLIENT_SERVICE ) && ( c->type != CLIENT_SERVER )) cnt++;
+		c = c->next;
+	}
+	return cnt;
+} /* Client_UnknownCount */
+
+
+LOCAL INT Count( CLIENT_TYPE Type )
+{
+	CLIENT *c;
+	INT cnt;
+
+	cnt = 0;
+	c = My_Clients;
+	while( c )
+	{
+		if( c && ( c->type == Type )) cnt++;
+		c = c->next;
+	}
+	return cnt;
+} /* Count */
+
+
+LOCAL INT MyCount( CLIENT_TYPE Type )
+{
+	CLIENT *c;
+	INT cnt;
+
+	cnt = 0;
+	c = My_Clients;
+	while( c )
+	{
+		if( c && ( c->introducer == This_Server ) && ( c->type == Type )) cnt++;
+		c = c->next;
+	}
+	return cnt;
+} /* MyCount */
+
+
 LOCAL CLIENT *New_Client_Struct( VOID )
 {
 	/* Neue CLIENT-Struktur pre-initialisieren */
blob - 3989cd675fc0858dfe06fd7be3bf52599a3e7bd5
blob + 96c50d7d27eb04d664648910b0655d598d002cd2
--- src/ngircd/client.h
+++ src/ngircd/client.h
@@ -9,11 +9,14 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: client.h,v 1.18 2002/01/07 23:42:12 alex Exp $
+ * $Id: client.h,v 1.19 2002/01/16 22:10:35 alex Exp $
  *
  * client.h: Konfiguration des ngircd (Header)
  *
  * $Log: client.h,v $
+ * Revision 1.19  2002/01/16 22:10:35  alex
+ * - neue Funktionen Client_xxxCount().
+ *
  * Revision 1.18  2002/01/07 23:42:12  alex
  * - Es werden fuer alle Server eigene Token generiert,
  * - QUIT von einem Server fuer einen User wird an andere Server geforwarded,
@@ -176,6 +179,16 @@ GLOBAL BOOLEAN Client_ModeDel( CLIENT *Client, CHAR Mo
 GLOBAL BOOLEAN Client_CheckNick( CLIENT *Client, CHAR *Nick );
 GLOBAL BOOLEAN Client_CheckID( CLIENT *Client, CHAR *ID );
 
+GLOBAL INT Client_UserCount( VOID );
+GLOBAL INT Client_ServiceCount( VOID );
+GLOBAL INT Client_ServerCount( VOID );
+GLOBAL INT Client_OperCount( VOID );
+GLOBAL INT Client_UnknownCount( VOID );
+GLOBAL INT Client_MyUserCount( VOID );
+GLOBAL INT Client_MyServiceCount( VOID );
+GLOBAL INT Client_MyServerCount( VOID );
+
+
 #endif