+LOCAL BOOLEAN Use_Log = TRUE;
+LOCAL CONF_SERVER New_Server;
+LOCAL INT New_Server_Idx;
+
+
+LOCAL VOID Set_Defaults PARAMS(( BOOLEAN InitServers ));
+LOCAL VOID Read_Config PARAMS(( VOID ));
+LOCAL VOID Validate_Config PARAMS(( BOOLEAN TestOnly ));
+
+LOCAL VOID Handle_GLOBAL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
+LOCAL VOID Handle_OPERATOR PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
+LOCAL VOID Handle_SERVER PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
+LOCAL VOID Handle_CHANNEL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
+
+LOCAL VOID Config_Error PARAMS(( CONST INT Level, CONST CHAR *Format, ... ));
+
+LOCAL VOID Config_Error_NaN PARAMS(( INT LINE, CONST CHAR *Value ));
+LOCAL VOID Config_Error_TooLong PARAMS(( INT LINE, CONST CHAR *Value ));
+
+LOCAL VOID Init_Server_Struct PARAMS(( CONF_SERVER *Server ));
+
+
+GLOBAL VOID
+Conf_Init( VOID )
+{
+ Set_Defaults( TRUE );
+ Read_Config( );
+ Validate_Config( FALSE );
+} /* Config_Init */
+
+
+GLOBAL VOID
+Conf_Rehash( VOID )
+{
+ Set_Defaults( FALSE );
+ Read_Config( );
+ Validate_Config( FALSE );
+} /* Config_Rehash */
+
+
+GLOBAL INT
+Conf_Test( VOID )
+{
+ /* Read configuration, validate and output it. */
+
+ struct passwd *pwd;
+ struct group *grp;
+ INT i;
+
+ Use_Log = FALSE;
+ Set_Defaults( TRUE );
+
+ Read_Config( );
+ Validate_Config( TRUE );
+
+ /* If stdin is a valid tty wait for a key: */
+ if( isatty( fileno( stdout )))
+ {
+ puts( "OK, press enter to see a dump of your service configuration ..." );
+ getchar( );
+ }
+ else puts( "Ok, dump of your server configuration follows:\n" );
+
+ puts( "[GLOBAL]" );
+ printf( " Name = %s\n", Conf_ServerName );
+ printf( " Info = %s\n", Conf_ServerInfo );
+ printf( " Password = %s\n", Conf_ServerPwd );
+ printf( " AdminInfo1 = %s\n", Conf_ServerAdmin1 );
+ printf( " AdminInfo2 = %s\n", Conf_ServerAdmin2 );
+ printf( " AdminEMail = %s\n", Conf_ServerAdminMail );
+ printf( " MotdFile = %s\n", Conf_MotdFile );
+ printf( " MotdPhrase = %s\n", Conf_MotdPhrase );
+ printf( " ChrootDir = %s\n", Conf_Chroot );
+ printf( " PidFile = %s\n", Conf_PidFile);
+ printf( " Ports = " );
+ for( i = 0; i < Conf_ListenPorts_Count; i++ )
+ {
+ if( i != 0 ) printf( ", " );
+ printf( "%u", Conf_ListenPorts[i] );
+ }
+ puts( "" );
+ printf( " Listen = %s\n", Conf_ListenAddress );
+ pwd = getpwuid( Conf_UID );
+ if( pwd ) printf( " ServerUID = %s\n", pwd->pw_name );
+ else printf( " ServerUID = %ld\n", (LONG)Conf_UID );
+ grp = getgrgid( Conf_GID );
+ if( grp ) printf( " ServerGID = %s\n", grp->gr_name );
+ else printf( " ServerGID = %ld\n", (LONG)Conf_GID );
+ printf( " PingTimeout = %d\n", Conf_PingTimeout );
+ printf( " PongTimeout = %d\n", Conf_PongTimeout );
+ printf( " ConnectRetry = %d\n", Conf_ConnectRetry );
+ printf( " OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
+ if( Conf_MaxConnections > 0 ) printf( " MaxConnections = %ld\n", Conf_MaxConnections );
+ else printf( " MaxConnections = -1\n" );
+ if( Conf_MaxConnectionsIP > 0 ) printf( " MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP );
+ else printf( " MaxConnectionsIP = -1\n" );
+ if( Conf_MaxJoins > 0 ) printf( " MaxJoins = %d\n", Conf_MaxJoins );
+ else printf( " MaxJoins = -1\n" );
+ puts( "" );
+
+ for( i = 0; i < Conf_Oper_Count; i++ )
+ {
+ if( ! Conf_Oper[i].name[0] ) continue;
+
+ /* Valid "Operator" section */
+ puts( "[OPERATOR]" );
+ printf( " Name = %s\n", Conf_Oper[i].name );
+ printf( " Password = %s\n", Conf_Oper[i].pwd );
+ if ( Conf_Oper[i].mask ) printf( " Mask = %s\n", Conf_Oper[i].mask );
+ puts( "" );
+ }
+
+ for( i = 0; i < MAX_SERVERS; i++ )
+ {
+ if( ! Conf_Server[i].name[0] ) continue;
+
+ /* Valid "Server" section */
+ puts( "[SERVER]" );
+ printf( " Name = %s\n", Conf_Server[i].name );
+ printf( " Host = %s\n", Conf_Server[i].host );
+ printf( " Port = %d\n", Conf_Server[i].port );
+ printf( " MyPassword = %s\n", Conf_Server[i].pwd_in );
+ printf( " PeerPassword = %s\n", Conf_Server[i].pwd_out );
+ printf( " Group = %d\n", Conf_Server[i].group );
+ puts( "" );
+ }
+
+ for( i = 0; i < Conf_Channel_Count; i++ )
+ {
+ if( ! Conf_Channel[i].name[0] ) continue;
+
+ /* Valid "Channel" section */
+ 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 */
+