]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
Fixed spelling mistake :-)
[ngircd-alex.git] / src / ngircd / conf.c
index 011dffec691d3f3ce287305f7d4a1bd157c09a47..9d6071e1e5c165c90a535b42450329a754e0dab3 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.53 2002/12/31 16:12:50 alex Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.56 2003/04/20 23:09:43 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -210,7 +210,6 @@ Conf_UnsetServer( CONN_ID Idx )
                                Conf_Server[i].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
                        }
                }
-               break;
        }
 } /* Conf_UnsetServer */
 
@@ -330,7 +329,7 @@ Set_Defaults( BOOLEAN InitServers )
        INT i;
 
        strcpy( Conf_ServerName, "" );
-       sprintf( Conf_ServerInfo, "%s %s", PACKAGEVERSION );
+       sprintf( Conf_ServerInfo, "%s %s", PACKAGE_NAME, PACKAGE_VERSION );
        strcpy( Conf_ServerPwd, "" );
 
        strcpy( Conf_ServerAdmin1, "" );
@@ -368,7 +367,7 @@ Read_Config( VOID )
        /* Read configuration file. */
 
        CHAR section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
-       INT line, i;
+       INT line, i, n;
        FILE *fd;
 
        /* Open configuration file */
@@ -377,7 +376,7 @@ Read_Config( VOID )
        {
                /* No configuration file found! */
                Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s", NGIRCd_ConfFile, strerror( errno ));
-               Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+               Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                exit( 1 );
        }
 
@@ -385,11 +384,37 @@ Read_Config( VOID )
 
        /* Clean up server configuration structure: mark all already
         * configured servers as "once" so that they are deleted
-        * after the next disconnect and delete all unused servers. */
+        * after the next disconnect and delete all unused servers.
+        * And delete all servers which are "duplicates" of servers
+        * that are already marked as "once" (such servers have been
+        * created by the last rehash but are now useless). */
        for( i = 0; i < MAX_SERVERS; i++ )
        {
                if( Conf_Server[i].conn_id == NONE ) Init_Server_Struct( &Conf_Server[i] );
-               else Conf_Server[i].flags |= CONF_SFLAG_ONCE;
+               else
+               {
+                       /* This structure is in use ... */
+                       if( Conf_Server[i].flags & CONF_SFLAG_ONCE )
+                       {
+                               /* Check for duplicates */
+                               for( n = 0; n < MAX_SERVERS; n++ )
+                               {
+                                       if( n == i ) continue;
+
+                                       if( Conf_Server[i].conn_id == Conf_Server[n].conn_id )
+                                       {
+                                               Init_Server_Struct( &Conf_Server[n] );
+                                               Log( LOG_DEBUG, "Deleted unused duplicate server %d (kept %d).", n, i );
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               /* Mark server as "once" */
+                               Conf_Server[i].flags |= CONF_SFLAG_ONCE;
+                               Log( LOG_DEBUG, "Marked server %d as \"once\"", i );
+                       }
+               }
        }
 
        /* Initialize variables */
@@ -808,7 +833,7 @@ Validate_Config( BOOLEAN Configtest )
                Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile );
                if( ! Configtest )
                {
-                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                        exit( 1 );
                }
        }
@@ -820,7 +845,7 @@ Validate_Config( BOOLEAN Configtest )
                Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile );
                if( ! Configtest )
                {
-                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+                       Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                        exit( 1 );
                }
        }