diff options
| author | Florian Westphal <fw@strlen.de> | 2006-12-29 14:09:48 +0000 |
|---|---|---|
| committer | Florian Westphal <fw@strlen.de> | 2006-12-29 14:09:48 +0000 |
| commit | 1b852fce72a87f3cce2049fde59ab66b6bbda6ca (patch) | |
| tree | 39c907530631cfefd60b221d6ec4218306c51811 /src | |
| parent | 82aaffe55d6ed82465517a2f93a2d9e9a92b1f28 (diff) | |
| download | ngircd-1b852fce72a87f3cce2049fde59ab66b6bbda6ca.tar.gz ngircd-1b852fce72a87f3cce2049fde59ab66b6bbda6ca.zip | |
add support for predefined-channel configuration of k and l modes
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngircd/channel.c | 7 | ||||
| -rw-r--r-- | src/ngircd/conf.c | 22 | ||||
| -rw-r--r-- | src/ngircd/conf.h | 4 |
3 files changed, 29 insertions, 4 deletions
diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c index e31b268f..12b287c8 100644 --- a/src/ngircd/channel.c +++ b/src/ngircd/channel.c @@ -17,7 +17,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: channel.c,v 1.61 2006/12/07 22:23:39 fw Exp $"; +static char UNUSED id[] = "$Id: channel.c,v 1.62 2006/12/29 14:09:50 fw Exp $"; #include "imp.h" #include <assert.h> @@ -131,6 +131,9 @@ Channel_InitPredefined( void ) while (*c) Channel_ModeAdd(chan, *c++); + Channel_SetKey(chan, Conf_Channel[i].key); + Channel_SetMaxUsers(chan, Conf_Channel[i].maxusers); + Log(LOG_INFO, "Created pre-defined channel \"%s\".", Conf_Channel[i].name ); } @@ -145,7 +148,7 @@ Channel_Exit( void ) { CHANNEL *c, *c_next; CL2CHAN *cl2chan, *cl2chan_next; - + /* Channel-Strukturen freigeben */ c = My_Channels; while( c ) diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 7390f224..05750f1f 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: conf.c,v 1.96 2006/11/20 19:32:07 fw Exp $"; +static char UNUSED id[] = "$Id: conf.c,v 1.97 2006/12/29 14:09:50 fw Exp $"; #include "imp.h" #include <assert.h> @@ -240,6 +240,8 @@ Conf_Test( void ) puts( "[CHANNEL]" ); printf( " Name = %s\n", Conf_Channel[i].name ); printf( " Modes = %s\n", Conf_Channel[i].modes ); + printf( " Key = %s\n", Conf_Channel[i].key ); + printf( " MaxUsers = %lu\n", Conf_Channel[i].maxusers ); topic = (char*)array_start(&Conf_Channel[i].topic); printf( " Topic = %s\n\n", topic ? topic : ""); @@ -555,6 +557,8 @@ Read_Config( void ) /* Initialize new channel structure */ strcpy( Conf_Channel[Conf_Channel_Count].name, "" ); strcpy( Conf_Channel[Conf_Channel_Count].modes, "" ); + strcpy( Conf_Channel[Conf_Channel_Count].key, "" ); + Conf_Channel[Conf_Channel_Count].maxusers = 0; array_free(&Conf_Channel[Conf_Channel_Count].topic); Conf_Channel_Count++; } @@ -968,6 +972,22 @@ Handle_CHANNEL( int Line, char *Var, char *Arg ) return; } + if( strcasecmp( Var, "Key" ) == 0 ) { + /* Initial Channel Key (mode k) */ + len = strlcpy(Conf_Channel[chancount].key, Arg, sizeof(Conf_Channel[chancount].key)); + if (len >= sizeof( Conf_Channel[chancount].key )) + Config_Error_TooLong(Line, Var); + return; + } + + if( strcasecmp( Var, "MaxUsers" ) == 0 ) { + /* maximum user limit, mode l */ + Conf_Channel[chancount].maxusers = (unsigned long) atol(Arg); + if (Conf_Channel[chancount].maxusers == 0) + Config_Error_NaN(Line, Var); + return; + } + Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var ); } /* Handle_CHANNEL */ diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h index bb9a00b3..1f21b4b5 100644 --- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -8,7 +8,7 @@ * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: conf.h,v 1.41 2006/11/05 13:03:48 fw Exp $ + * $Id: conf.h,v 1.42 2006/12/29 14:09:50 fw Exp $ * * Configuration management (header) */ @@ -49,6 +49,8 @@ typedef struct _Conf_Channel { char name[CHANNEL_NAME_LEN]; /* Name of the channel */ char modes[CHANNEL_MODE_LEN]; /* Initial channel modes */ + char key[CLIENT_PASS_LEN]; /* Channel key ("password", mode "k" ) */ + unsigned long maxusers; /* maximum usercount for this channel, mode "l" */ array topic; /* Initial topic */ } CONF_CHANNEL; |