+LOCAL VOID Read_Config( VOID )
+{
+ /* Konfigurationsdatei einlesen. */
+
+ CHAR str[LINE_LEN], *var, *arg, *ptr;
+ BOOLEAN ok;
+ INT32 port;
+ INT line;
+ FILE *fd;
+
+ fd = fopen( Conf_File, "r" );
+ if( ! fd )
+ {
+ /* Keine Konfigurationsdatei gefunden */
+ Log( LOG_ALERT, "Can't read configuration \"%s\": %s", Conf_File, strerror( errno ));
+ Log( LOG_ALERT, PACKAGE" exiting due to fatal errors!" );
+ exit( 1 );
+ }
+
+ line = 0;
+ while( TRUE )
+ {
+ ok = FALSE;
+
+ if( ! fgets( str, LINE_LEN, fd )) break;
+ ngt_TrimStr( str );
+ line++;
+
+ /* Kommentarzeilen und leere Zeilen ueberspringen */
+ if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
+
+ ptr = strchr( str, '=' );
+ if( ! ptr )
+ {
+ Log( LOG_ERR, "%s, line %d: Syntax error!", Conf_File, line );
+ continue;
+ }
+ *ptr = '\0';
+
+ var = str; ngt_TrimStr( var );
+ arg = ptr + 1; ngt_TrimStr( arg );
+
+ if( strcasecmp( str, "ServerName" ) == 0 )
+ {
+ /* Der Server-Name */
+ strncpy( Conf_ServerName, arg, CLIENT_ID_LEN );
+ Conf_ServerName[CLIENT_ID_LEN - 1] = '\0';
+ ok = TRUE;
+ }
+ else if( strcasecmp( str, "ServerInfo" ) == 0 )
+ {
+ /* Server-Info-Text */
+ strncpy( Conf_ServerInfo, arg, CLIENT_INFO_LEN );
+ Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0';
+ ok = TRUE;
+ }
+ else if( strcasecmp( str, "Operator" ) == 0 )
+ {
+ /* Name des IRC Operator */
+ strncpy( Conf_Oper, arg, CLIENT_PASS_LEN );
+ Conf_Oper[CLIENT_PASS_LEN - 1] = '\0';
+ ok = TRUE;
+ }
+ else if( strcasecmp( str, "OperatorPwd" ) == 0 )
+ {
+ /* Passwort des IRC Operator */
+ strncpy( Conf_OperPwd, arg, CLIENT_PASS_LEN );
+ Conf_OperPwd[CLIENT_PASS_LEN - 1] = '\0';
+ ok = TRUE;
+ }
+ else if( strcasecmp( str, "ListenPorts" ) == 0 )
+ {
+ /* Ports, durch "," getrennt, auf denen der Server
+ * Verbindungen annehmen soll */
+ ptr = strtok( arg, "," );
+ while( ptr )
+ {
+ ngt_TrimStr( ptr );
+ port = atol( ptr );
+ if( Conf_ListenPorts_Count + 1 > LISTEN_PORTS ) Log( LOG_ERR, "Too many listen ports configured. Port %ld ignored.", port );
+ if( port > 0 && port < 0xFFFF ) Conf_ListenPorts[Conf_ListenPorts_Count++] = port;
+ else Log( LOG_ERR, "Illegal port number: %ld. Ignored.", port );
+ ptr = strtok( NULL, "," );
+ }
+ ok = TRUE;
+ }
+ else if( strcasecmp( str, "MotdFile" ) == 0 )
+ {
+ /* Datei mit der "message of the day" (MOTD) */
+ strncpy( Conf_MotdFile, arg, FNAME_LEN );
+ Conf_MotdFile[FNAME_LEN - 1] = '\0';
+ ok = TRUE;
+ }
+ else if( strcasecmp( str, "PingTimeout" ) == 0 )
+ {
+ /* PING-Timeout */
+ Conf_PingTimeout = atoi( arg );
+ if(( Conf_PingTimeout ) < 5 ) Conf_PingTimeout = 5;
+ ok = TRUE;
+ }
+ else if( strcasecmp( str, "PongTimeout" ) == 0 )
+ {
+ /* PONG-Timeout */
+ Conf_PongTimeout = atoi( arg );
+ if(( Conf_PongTimeout ) < 5 ) Conf_PongTimeout = 5;
+ ok = TRUE;
+ }
+
+ if( ! ok ) Log( LOG_ERR, "%s, line %d: Unknown variable \"%s\"!", Conf_File, line, var );
+ }
+
+ fclose( fd );
+} /* Read_Config */
+
+
+LOCAL VOID Validate_Config( VOID )
+{
+ /* Konfiguration ueberpruefen */
+
+ if( ! Conf_ServerName[0] )
+ {
+ /* Kein Servername konfiguriert */
+ Log( LOG_ALERT, "No server name configured (use \"ServerName\")!", Conf_File, strerror( errno ));
+ Log( LOG_ALERT, PACKAGE" exiting due to fatal errors!" );
+ exit( 1 );
+ }
+} /* Validate_Config */
+