]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/channel.c
- New functions Channel_[Set]Key(), Channel_[Set]MaxUsers.
[ngircd-alex.git] / src / ngircd / channel.c
index 5cd24128fe1e5449ad8ef258887ff24c80a2112d..aafb8bc0d91ddc249f1bca19265cbefd880f645f 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "portab.h"
 
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: channel.c,v 1.36 2002/12/13 17:22:57 alex Exp $";
+static char UNUSED id[] = "$Id: channel.c,v 1.38 2002/12/16 23:05:24 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
 
 #include "imp.h"
 #include <assert.h>
@@ -293,14 +293,13 @@ Channel_MemberCount( CHANNEL *Chan )
 
 
 GLOBAL INT
 
 
 GLOBAL INT
-Channel_CountForUser( CHANNEL *Chan, CLIENT *Client )
+Channel_CountForUser( CLIENT *Client )
 {
        /* Count number of channels a user is member of. */
 
        CL2CHAN *cl2chan;
        INT count;
        
 {
        /* Count number of channels a user is member of. */
 
        CL2CHAN *cl2chan;
        INT count;
        
-       assert( Chan != NULL );
        assert( Client != NULL );
        
        count = 0;
        assert( Client != NULL );
        
        count = 0;
@@ -315,6 +314,25 @@ Channel_CountForUser( CHANNEL *Chan, CLIENT *Client )
 } /* Channel_CountForUser */
 
 
 } /* 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 )
 
 GLOBAL CHAR *
 Channel_Name( CHANNEL *Chan )
@@ -332,6 +350,22 @@ Channel_Modes( CHANNEL *Chan )
 } /* Channel_Modes */
 
 
 } /* Channel_Modes */
 
 
+GLOBAL CHAR *
+Channel_Key( CHANNEL *Chan )
+{
+       assert( Chan != NULL );
+       return Chan->key;
+} /* Channel_Key */
+
+
+GLOBAL LONG
+Channel_MaxUsers( CHANNEL *Chan )
+{
+       assert( Chan != NULL );
+       return Chan->maxusers;
+} /* Channel_MaxUsers */
+
+
 GLOBAL CHANNEL *
 Channel_First( VOID )
 {
 GLOBAL CHANNEL *
 Channel_First( VOID )
 {
@@ -611,6 +645,27 @@ Channel_SetModes( CHANNEL *Chan, CHAR *Modes )
 } /* Channel_SetModes */
 
 
 } /* Channel_SetModes */
 
 
+GLOBAL VOID
+Channel_SetKey( CHANNEL *Chan, CHAR *Key )
+{
+       assert( Chan != NULL );
+       assert( Key != NULL );
+
+       strncpy( Chan->key, Key, CLIENT_PASS_LEN - 1 );
+       Chan->key[CLIENT_PASS_LEN - 1] = '\0';
+       Log( LOG_DEBUG, "Channel %s: Key is now \"%s\".", Chan->name, Chan->key );
+} /* Channel_SetKey */
+
+
+GLOBAL VOID
+Channel_SetMaxUsers( CHANNEL *Chan, LONG Count )
+{
+       assert( Chan != NULL );
+
+       Chan->maxusers = Count;
+       Log( LOG_DEBUG, "Channel %s: Member limit is now %ld.", Chan->name, Chan->maxusers );
+} /* Channel_SetMaxUsers */
+
 
 GLOBAL BOOLEAN
 Channel_Write( CHANNEL *Chan, CLIENT *From, CLIENT *Client, CHAR *Text )
 
 GLOBAL BOOLEAN
 Channel_Write( CHANNEL *Chan, CLIENT *From, CLIENT *Client, CHAR *Text )
@@ -660,6 +715,8 @@ Channel_Create( CHAR *Name )
        strcpy( c->modes, "" );
        strcpy( c->topic, "" );
        c->hash = Hash( c->name );
        strcpy( c->modes, "" );
        strcpy( c->topic, "" );
        c->hash = Hash( c->name );
+       strcpy( c->key, "" );
+       c->maxusers = 0;
 
        /* Verketten */
        c->next = My_Channels;
 
        /* Verketten */
        c->next = My_Channels;