]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/channel.c
- fixed up Channel_PCount() and Channel_CountForUser().
[ngircd-alex.git] / src / ngircd / channel.c
index c30d4d555189b67a0bc895f8c69e9d929e0b8522..386aaa2a1ad7f5166a31490746b822356e32f56c 100644 (file)
@@ -2,16 +2,13 @@
  * ngIRCd -- The Next Generation IRC Daemon
  * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
  *
- * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
- * der GNU General Public License (GPL), wie von der Free Software Foundation
- * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
- * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
- * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
- * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: channel.c,v 1.34 2002/11/22 17:57:15 alex Exp $
- *
- * channel.c: Management der Channels
+ * Channel management
  */
 
 
@@ -20,6 +17,8 @@
 
 #include "portab.h"
 
+static char UNUSED id[] = "$Id: channel.c,v 1.37 2002/12/14 13:21:56 alex Exp $";
+
 #include "imp.h"
 #include <assert.h>
 #include <stdlib.h>
@@ -293,6 +292,48 @@ Channel_MemberCount( CHANNEL *Chan )
 } /* Channel_MemberCount */
 
 
+GLOBAL INT
+Channel_CountForUser( CLIENT *Client )
+{
+       /* Count number of channels a user is member of. */
+
+       CL2CHAN *cl2chan;
+       INT count;
+       
+       assert( Client != NULL );
+       
+       count = 0;
+       cl2chan = My_Cl2Chan;
+       while( cl2chan )
+       {
+               if( cl2chan->client == Client ) count++;
+               cl2chan = cl2chan->next;
+       }
+
+       return count;
+} /* Channel_CountForUser */
+
+
+GLOBAL INT
+Channel_PCount( VOID )
+{
+       /* Count the number of persistent (mode 'P') channels */
+
+       CHANNEL *chan;
+       INT count;
+
+       count = 0;
+       chan = My_Channels;
+       while( chan )
+       {
+               if( strchr( chan->modes, 'P' )) count++;
+               chan = chan->next;
+       }
+
+       return count;
+} /* Channel_PCount */
+
+
 GLOBAL CHAR *
 Channel_Name( CHANNEL *Chan )
 {