#include "portab.h"
-static char UNUSED id[] = "$Id: conf.c,v 1.78 2005/07/07 18:46:46 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.81 2005/07/28 16:23:55 fw Exp $";
#include "imp.h"
#include <assert.h>
struct passwd *pwd;
struct group *grp;
- int i;
+ unsigned int i;
+ char *topic;
Use_Log = false;
Set_Defaults( true );
puts( "[CHANNEL]" );
printf( " Name = %s\n", Conf_Channel[i].name );
printf( " Modes = %s\n", Conf_Channel[i].modes );
- printf( " Topic = %s\n", Conf_Channel[i].topic );
+ topic = (char*)array_start(&Conf_Channel[i].topic);
+ printf( " Topic = %s\n", topic ? topic : "");
puts( "" );
}
else New_Server_Idx = i;
continue;
}
- if( strcasecmp( section, "[CHANNEL]" ) == 0 )
- {
- if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
- else
- {
+ if( strcasecmp( section, "[CHANNEL]" ) == 0 ) {
+ if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) {
+ Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
+ } else {
/* Initialize new channel structure */
strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
- strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
+ array_free(&Conf_Channel[Conf_Channel_Count].topic);
Conf_Channel_Count++;
}
continue;
LOCAL void
Handle_OPERATOR( int Line, char *Var, char *Arg )
{
+ unsigned int opercount;
+ size_t len;
assert( Line > 0 );
assert( Var != NULL );
assert( Arg != NULL );
assert( Conf_Oper_Count > 0 );
- if( strcasecmp( Var, "Name" ) == 0 )
- {
+ if ( Conf_Oper_Count == 0 )
+ return;
+
+ opercount = Conf_Oper_Count - 1;
+
+ if( strcasecmp( Var, "Name" ) == 0 ) {
/* Name of IRC operator */
- if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) Config_Error_TooLong( Line, Var );
+ len = strlcpy( Conf_Oper[opercount].name, Arg, sizeof( Conf_Oper[opercount].name ));
+ if (len >= sizeof( Conf_Oper[opercount].name ))
+ Config_Error_TooLong( Line, Var );
+
return;
}
- if( strcasecmp( Var, "Password" ) == 0 )
- {
+ if( strcasecmp( Var, "Password" ) == 0 ) {
/* Password of IRC operator */
- if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) Config_Error_TooLong( Line, Var );
+ len = strlcpy( Conf_Oper[opercount].pwd, Arg, sizeof( Conf_Oper[opercount].pwd ));
+ if (len >= sizeof( Conf_Oper[opercount].pwd ))
+ Config_Error_TooLong( Line, Var );
return;
}
- if( strcasecmp( Var, "Mask" ) == 0 )
- {
- if (Conf_Oper[Conf_Oper_Count - 1].mask) return; /* Hostname already configured */
- Conf_Oper[Conf_Oper_Count - 1].mask = strdup( Arg );
- if (! Conf_Oper[Conf_Oper_Count - 1].mask) {
- Config_Error( LOG_ERR, "%s, line %d: Cannot allocate memory for operator mask: %s", NGIRCd_ConfFile, Line, strerror(errno) );
+ if( strcasecmp( Var, "Mask" ) == 0 ) {
+ if (Conf_Oper[opercount].mask) return; /* Hostname already configured */
+
+ Conf_Oper[opercount].mask = strdup( Arg );
+ if (! Conf_Oper[opercount].mask) {
+ Config_Error( LOG_ERR, "%s, line %d: Cannot allocate memory for operator mask: %s",
+ NGIRCd_ConfFile, Line, strerror(errno) );
return;
}
return;
}
- Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
+ Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!",
+ NGIRCd_ConfFile, Line, Var );
} /* Handle_OPERATOR */
if( strcasecmp( Var, "Topic" ) == 0 )
{
/* Initial topic */
- if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].topic ))
+ if (!array_copys( &Conf_Channel[Conf_Channel_Count - 1].topic, Arg))
Config_Error_TooLong( Line, Var );
return;