]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
- ein sofortiger Re-Connect wird nur dann versucht, wenn die Vernindung
[ngircd-alex.git] / src / ngircd / conf.c
index e94dd2a16f36dcc93ee7108d9ad6b9bfce0c59de..6abad003837afcccc059eea58198816414b6a23c 100644 (file)
@@ -9,11 +9,23 @@
  * 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.13 2002/01/18 15:51:44 alex Exp $
+ * $Id: conf.c,v 1.17 2002/03/10 18:47:02 alex Exp $
  *
  * conf.h: Konfiguration des ngircd
  *
  * $Log: conf.c,v $
+ * Revision 1.17  2002/03/10 18:47:02  alex
+ * *** empty log message ***
+ *
+ * Revision 1.16  2002/03/10 17:50:48  alex
+ * - Server-Gruppen implementiert.
+ *
+ * Revision 1.15  2002/03/06 15:35:19  alex
+ * - Dateinamen und Pfad sind nun in Konstanten definiert.
+ *
+ * Revision 1.14  2002/03/03 17:17:01  alex
+ * - strncpy() und vsnprintf() kopieren nun etwas "optimierter" (1 Byte weniger) :-)
+ *
  * Revision 1.13  2002/01/18 15:51:44  alex
  * - Server-Verbinungen werden beim Start erst nach kurzer Pause aufgebaut.
  *
@@ -87,13 +99,13 @@ GLOBAL VOID Conf_Init( VOID )
        /* Konfigurationsvariablen initialisieren: zunaechst Default-
         * Werte setzen, dann Konfigurationsdtaei einlesen. */
 
-       strcpy( Conf_File, "/usr/local/etc/ngircd.conf" );
+       strcpy( Conf_File, CONFIG_FILE );
 
        strcpy( Conf_ServerName, "" );
        strcpy( Conf_ServerInfo, PACKAGE" "VERSION );
        strcpy( Conf_ServerPwd, "" );
 
-       strcpy( Conf_MotdFile, "/usr/local/etc/ngircd.motd" );
+       strcpy( Conf_MotdFile, MOTD_FILE );
 
        Conf_ListenPorts_Count = 0;
        
@@ -174,6 +186,7 @@ LOCAL VOID Read_Config( VOID )
                                        strcpy( Conf_Server[Conf_Server_Count].name, "" );
                                        strcpy( Conf_Server[Conf_Server_Count].pwd, "" );
                                        Conf_Server[Conf_Server_Count].port = 0;
+                                       Conf_Server[Conf_Server_Count].group = -1;
                                        Conf_Server[Conf_Server_Count].lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
                                        Conf_Server[Conf_Server_Count].res_stat = NULL;
                                        Conf_Server_Count++;
@@ -218,21 +231,21 @@ GLOBAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
        if( strcasecmp( Var, "Name" ) == 0 )
        {
                /* Der Server-Name */
-               strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN );
+               strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN - 1 );
                Conf_ServerName[CLIENT_ID_LEN - 1] = '\0';
                return;
        }
        if( strcasecmp( Var, "Info" ) == 0 )
        {
                /* Server-Info-Text */
-               strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN );
+               strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN - 1 );
                Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0';
                return;
        }
        if( strcasecmp( Var, "Password" ) == 0 )
        {
-               /* Der Server-Name */
-               strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN );
+               /* Server-Passwort */
+               strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN - 1 );
                Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0';
                return;
        }
@@ -258,7 +271,7 @@ GLOBAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
        if( strcasecmp( Var, "MotdFile" ) == 0 )
        {
                /* Datei mit der "message of the day" (MOTD) */
-               strncpy( Conf_MotdFile, Arg, FNAME_LEN );
+               strncpy( Conf_MotdFile, Arg, FNAME_LEN - 1 );
                Conf_MotdFile[FNAME_LEN - 1] = '\0';
                return;
        }
@@ -298,14 +311,14 @@ GLOBAL VOID Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
        if( strcasecmp( Var, "Name" ) == 0 )
        {
                /* Name des IRC Operator */
-               strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_ID_LEN );
+               strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_ID_LEN - 1 );
                Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
                return;
        }
        if( strcasecmp( Var, "Password" ) == 0 )
        {
                /* Passwort des IRC Operator */
-               strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN );
+               strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
                Conf_Oper[Conf_Oper_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
                return;
        }
@@ -316,7 +329,7 @@ GLOBAL VOID Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
 
 GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
 {
-       INT port;
+       INT32 port;
        
        assert( Line > 0 );
        assert( Var != NULL );
@@ -325,21 +338,21 @@ GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
        if( strcasecmp( Var, "Host" ) == 0 )
        {
                /* Hostname des Servers */
-               strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN );
+               strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN - 1 );
                Conf_Server[Conf_Server_Count - 1].host[HOST_LEN - 1] = '\0';
                return;
        }
        if( strcasecmp( Var, "Name" ) == 0 )
        {
                /* Name des Servers ("Nick") */
-               strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN );
+               strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN - 1 );
                Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
                return;
        }
        if( strcasecmp( Var, "Password" ) == 0 )
        {
                /* Passwort des Servers */
-               strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN );
+               strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
                Conf_Server[Conf_Server_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
                return;
        }
@@ -347,10 +360,16 @@ GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
        {
                /* Port, zu dem Verbunden werden soll */
                port = atol( Arg );
-               if( port > 0 && port < 0xFFFF ) Conf_Server[Conf_Server_Count - 1].port = port;
+               if( port > 0 && port < 0xFFFF ) Conf_Server[Conf_Server_Count - 1].port = (INT)port;
                else Log( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!", Conf_File, Line, port );
                return;
        }
+       if( strcasecmp( Var, "Group" ) == 0 )
+       {
+               /* Server-Gruppe */
+               Conf_Server[Conf_Server_Count - 1].group = atoi( Arg );
+               return;
+       }
        
        Log( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!", Conf_File, Line, Var );
 } /* Handle_SERVER */