* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
*
- * $Id: conf.c,v 1.21 2002/03/27 16:39:22 alex Exp $
+ * $Id: conf.c,v 1.25 2002/05/22 11:14:36 alex Exp $
*
* conf.h: Konfiguration des ngircd
*/
GLOBAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg );
GLOBAL VOID Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg );
GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg );
+GLOBAL VOID Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg );
LOCAL VOID Config_Error( CONST INT Level, CONST CHAR *Format, ... );
{
/* Konfiguration einlesen, ueberpruefen und ausgeben. */
- INT i;
+ UINT i;
Use_Log = FALSE;
Set_Defaults( );
for( i = 0; i < Conf_ListenPorts_Count; i++ )
{
if( i != 0 ) printf( ", " );
- printf( "%d", Conf_ListenPorts[i] );
+ printf( "%u", Conf_ListenPorts[i] );
}
- if( Conf_ListenPorts_Count < 1 ) puts( "<none>");
- else puts( "" );
+ puts( "" );
+ printf( " ServerUID = %ld\n", (INT32)Conf_UID );
+ printf( " ServerGID = %ld\n", (INT32)Conf_GID );
printf( " PingTimeout = %d\n", Conf_PingTimeout );
printf( " PongTimeout = %d\n", Conf_PongTimeout );
printf( " ConnectRetry = %d\n", Conf_ConnectRetry );
for( i = 0; i < Conf_Oper_Count; i++ )
{
+ if( ! Conf_Oper[i].name[0] ) continue;
+
+ /* gueltiger Operator-Block: ausgeben */
puts( "[OPERATOR]" );
printf( " Name = %s\n", Conf_Oper[i].name );
printf( " Password = %s\n", Conf_Oper[i].pwd );
for( i = 0; i < Conf_Server_Count; i++ )
{
+ if( ! Conf_Server[i].name[0] ) continue;
+ if( ! Conf_Server[i].host[0] ) continue;
+
+ /* gueltiger Server-Block: ausgeben */
puts( "[SERVER]" );
printf( " Name = %s\n", Conf_Server[i].name );
printf( " Host = %s\n", Conf_Server[i].host );
printf( " Group = %d\n", Conf_Server[i].group );
puts( "" );
}
+
+ for( i = 0; i < Conf_Channel_Count; i++ )
+ {
+ if( ! Conf_Channel[i].name[0] ) continue;
+
+ /* gueltiger Channel-Block: ausgeben */
+ 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 );
+ puts( "" );
+ }
return 0;
} /* Conf_Test */
strcpy( Conf_MotdFile, MOTD_FILE );
Conf_ListenPorts_Count = 0;
+
+ Conf_UID = Conf_GID = 0;
Conf_PingTimeout = 120;
Conf_PongTimeout = 20;
Conf_ConnectRetry = 60;
Conf_Oper_Count = 0;
-
Conf_Server_Count = 0;
+ Conf_Channel_Count = 0;
} /* Set_Defaults */
}
continue;
}
+ if( strcasecmp( section, "[CHANNEL]" ) == 0 )
+ {
+ if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
+ else
+ {
+ /* neuen vordefinierten Channel initialisieren */
+ strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
+ strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
+ strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
+ Conf_Channel_Count++;
+ }
+ continue;
+ }
Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
section[0] = 0x1;
}
if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
+ else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
}
fclose( fd );
+
+ /* Wenn kein Port definiert wurde, Port 6667 als Default benutzen */
+ if( Conf_ListenPorts_Count < 1 )
+ {
+ Conf_ListenPorts_Count = 1;
+ Conf_ListenPorts[0] = 6667;
+ }
} /* Read_Config */
if( Conf_ListenPorts_Count + 1 > MAX_LISTEN_PORTS ) Config_Error( LOG_ERR, "Too many listen ports configured. Port %ld ignored.", port );
else
{
- if( port > 0 && port < 0xFFFF ) Conf_ListenPorts[Conf_ListenPorts_Count++] = (INT)port;
+ if( port > 0 && port < 0xFFFF ) Conf_ListenPorts[Conf_ListenPorts_Count++] = (UINT)port;
else Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
}
ptr = strtok( NULL, "," );
Conf_MotdFile[FNAME_LEN - 1] = '\0';
return;
}
+ if( strcasecmp( Var, "ServerUID" ) == 0 )
+ {
+ /* UID, mit der der Daemon laufen soll */
+ Conf_UID = (UINT)atoi( Arg );
+ return;
+ }
+ if( strcasecmp( Var, "ServerGID" ) == 0 )
+ {
+ /* GID, mit der der Daemon laufen soll */
+ Conf_GID = (UINT)atoi( Arg );
+ return;
+ }
if( strcasecmp( Var, "PingTimeout" ) == 0 )
{
/* PING-Timeout */
} /* Handle_SERVER */
+GLOBAL VOID Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
+{
+ assert( Line > 0 );
+ assert( Var != NULL );
+ assert( Arg != NULL );
+
+ if( strcasecmp( Var, "Name" ) == 0 )
+ {
+ /* Hostname des Servers */
+ strncpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, CHANNEL_NAME_LEN - 1 );
+ Conf_Channel[Conf_Channel_Count - 1].name[CHANNEL_NAME_LEN - 1] = '\0';
+ return;
+ }
+ if( strcasecmp( Var, "Modes" ) == 0 )
+ {
+ /* Name des Servers ("Nick") */
+ strncpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, CHANNEL_MODE_LEN - 1 );
+ Conf_Channel[Conf_Channel_Count - 1].modes[CHANNEL_MODE_LEN - 1] = '\0';
+ return;
+ }
+ if( strcasecmp( Var, "Topic" ) == 0 )
+ {
+ /* Passwort des Servers */
+ strncpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, CHANNEL_TOPIC_LEN - 1 );
+ Conf_Channel[Conf_Channel_Count - 1].topic[CHANNEL_TOPIC_LEN - 1] = '\0';
+ return;
+ }
+
+ Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
+} /* Handle_CHANNEL */
+
+
LOCAL VOID Validate_Config( VOID )
{
/* Konfiguration ueberpruefen */