- /* Datentypen der portab-Library ueberpruefen */
- portab_check_types( );
-
- /* Globale Variablen initialisieren */
- NGIRCd_Start = time( NULL );
- strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start ));
- NGIRCd_Quit = FALSE;
-
- /* Module initialisieren */
- Log_Init( );
- Conf_Init( );
- Parse_Init( );
- IRC_Init( );
- Channel_Init( );
- Client_Init( );
- Conn_Init( );
-
- /* Signal-Handler initialisieren */
- Initialize_Signal_Handler( );
-
- if( ! Conn_NewListener( 6668 )) exit( 1 );
- if( ! Conn_NewListener( 6669 )) Log( LOG_WARNING, "Can't create second listening socket!" );
+ struct passwd *pwd;
+ struct group *grp;
+ BOOLEAN ok, configtest = FALSE;
+ LONG pid, n;
+ INT i;
+
+ umask( 0077 );
+
+ NGIRCd_SignalQuit = NGIRCd_SignalRestart = NGIRCd_SignalRehash = FALSE;
+ NGIRCd_NoDaemon = NGIRCd_Passive = FALSE;
+#ifdef DEBUG
+ NGIRCd_Debug = FALSE;
+#endif
+#ifdef SNIFFER
+ NGIRCd_Sniffer = FALSE;
+#endif
+ strlcpy( NGIRCd_ConfFile, SYSCONFDIR, sizeof( NGIRCd_ConfFile ));
+ strlcat( NGIRCd_ConfFile, CONFIG_FILE, sizeof( NGIRCd_ConfFile ));
+
+ /* Kommandozeile parsen */
+ for( i = 1; i < argc; i++ )
+ {
+ ok = FALSE;
+ if(( argv[i][0] == '-' ) && ( argv[i][1] == '-' ))
+ {
+ /* Lange Option */
+
+ if( strcmp( argv[i], "--config" ) == 0 )
+ {
+ if( i + 1 < argc )
+ {
+ /* Ok, there's an parameter left */
+ strlcpy( NGIRCd_ConfFile, argv[i + 1], sizeof( NGIRCd_ConfFile ));
+
+ /* next parameter */
+ i++; ok = TRUE;
+ }
+ }
+ if( strcmp( argv[i], "--configtest" ) == 0 )
+ {
+ configtest = TRUE;
+ ok = TRUE;
+ }
+#ifdef DEBUG
+ if( strcmp( argv[i], "--debug" ) == 0 )
+ {
+ NGIRCd_Debug = TRUE;
+ ok = TRUE;
+ }
+#endif
+ if( strcmp( argv[i], "--help" ) == 0 )
+ {
+ Show_Version( );
+ puts( "" ); Show_Help( ); puts( "" );
+ exit( 1 );
+ }
+ if( strcmp( argv[i], "--nodaemon" ) == 0 )
+ {
+ NGIRCd_NoDaemon = TRUE;
+ ok = TRUE;
+ }
+ if( strcmp( argv[i], "--passive" ) == 0 )
+ {
+ NGIRCd_Passive = TRUE;
+ ok = TRUE;
+ }
+#ifdef SNIFFER
+ if( strcmp( argv[i], "--sniffer" ) == 0 )
+ {
+ NGIRCd_Sniffer = TRUE;
+ ok = TRUE;
+ }
+#endif
+ if( strcmp( argv[i], "--version" ) == 0 )
+ {
+ Show_Version( );
+ exit( 1 );
+ }
+ }
+ else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' ))
+ {
+ /* Kurze Option */
+
+ for( n = 1; n < (LONG)strlen( argv[i] ); n++ )
+ {
+ ok = FALSE;
+#ifdef DEBUG
+ if( argv[i][n] == 'd' )
+ {
+ NGIRCd_Debug = TRUE;
+ ok = TRUE;
+ }
+#endif
+ if( argv[i][n] == 'f' )
+ {
+ if(( ! argv[i][n + 1] ) && ( i + 1 < argc ))
+ {
+ /* Ok, next character is a blank */
+ strlcpy( NGIRCd_ConfFile, argv[i + 1], sizeof( NGIRCd_ConfFile ));
+
+ /* go to the following parameter */
+ i++; n = (LONG)strlen( argv[i] );
+ ok = TRUE;
+ }
+ }
+ if( argv[i][n] == 'n' )
+ {
+ NGIRCd_NoDaemon = TRUE;
+ ok = TRUE;
+ }
+ if( argv[i][n] == 'p' )
+ {
+ NGIRCd_Passive = TRUE;
+ ok = TRUE;
+ }
+#ifdef SNIFFER
+ if( argv[i][n] == 's' )
+ {
+ NGIRCd_Sniffer = TRUE;
+ ok = TRUE;
+ }
+#endif
+
+ if( ! ok )
+ {
+ printf( "%s: invalid option \"-%c\"!\n", PACKAGE, argv[i][n] );
+ printf( "Try \"%s --help\" for more information.\n", PACKAGE );
+ exit( 1 );
+ }
+ }
+
+ }
+ if( ! ok )
+ {
+ printf( "%s: invalid option \"%s\"!\n", PACKAGE, argv[i] );
+ printf( "Try \"%s --help\" for more information.\n", PACKAGE );
+ exit( 1 );
+ }
+ }
+
+ /* Debug-Level (fuer IRC-Befehl "VERSION") ermitteln */
+ strcpy( NGIRCd_DebugLevel, "" );
+#ifdef DEBUG
+ if( NGIRCd_Debug ) strcpy( NGIRCd_DebugLevel, "1" );
+#endif
+#ifdef SNIFFER
+ if( NGIRCd_Sniffer )
+ {
+ NGIRCd_Debug = TRUE;
+ strcpy( NGIRCd_DebugLevel, "2" );
+ }
+#endif
+
+ /* Soll nur die Konfigurations ueberprueft und ausgegeben werden? */
+ if( configtest )
+ {
+ Show_Version( ); puts( "" );
+ exit( Conf_Test( ));
+ }