]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspircd_io.cpp
Made <disabled> non-manditory, added check for when singular tags arent defined at all
[user/henk/code/inspircd.git] / src / inspircd_io.cpp
index 67baa11ad73755d63f285310066569a4e8ed801e..3716057aff3bb559a1088c65891f421e7f33fef9 100644 (file)
@@ -37,6 +37,9 @@ extern InspIRCd* ServerInstance;
 extern int openSockfd[MAXSOCKS];
 extern time_t TIME;
 
+extern int MODCOUNT;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
 
 ServerConfig::ServerConfig()
 {
@@ -91,9 +94,10 @@ bool ServerConfig::DelIOHook(int port)
        return false;
 }
 
-bool ServerConfig::CheckOnce(char* tag,bool bail)
+bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user)
 {
-       if (ConfValueEnum(tag,&Config->config_f) > 1)
+       int count = ConfValueEnum(tag,&Config->config_f);
+       if (count > 1)
        {
                if (bail)
                {
@@ -115,6 +119,28 @@ bool ServerConfig::CheckOnce(char* tag,bool bail)
                }
                return false;
        }
+       if (count < 1)
+       {
+               if (bail)
+               {
+                       printf("There were errors in your configuration:\nYou have not defined a <%s> tag, this is required.",tag);
+                       Exit(0);
+               }
+               else
+               {
+                       if (user)
+                       {
+                               WriteServ(user->fd,"There were errors in your configuration:");
+                               WriteServ(user->fd,"You have not defined a <%s> tag, this is required.",tag);
+                       }
+                       else
+                       {
+                               WriteOpers("There were errors in the configuration file:");
+                               WriteOpers("You have not defined a <%s> tag, this is required.",tag);
+                       }
+               }
+               return false;
+       }
        return true;
 }
 
@@ -162,8 +188,9 @@ void ServerConfig::Read(bool bail, userrec* user)
 
        /* Check we dont have more than one of singular tags
         */
-       if (!CheckOnce("server") || !CheckOnce("admin") || !CheckOnce("files") || !CheckOnce("power") || !CheckOnce("options")
-               || !CheckOnce("dns") || !CheckOnce("options") || !CheckOnce("disabled") || !CheckOnce("pid"))
+       if (!CheckOnce("server",bail,user) || !CheckOnce("admin",bail,user) || !CheckOnce("files",bail,user)
+               || !CheckOnce("power",bail,user) || !CheckOnce("options",bail,user)
+               || !CheckOnce("dns",bail,user) || !CheckOnce("pid",bail,user))
        {
                return;
        }
@@ -408,12 +435,21 @@ void Killed(int status)
        exit(status);
 }
 
+char* CleanFilename(char* name)
+{
+       char* p = name + strlen(name);
+       while ((p != name) && (*p != '/')) p--;
+       return (p != name ? ++p : p);
+}
+
+
 void Rehash(int status)
 {
-       WriteOpers("Rehashing config file %s due to SIGHUP",CONFIG_FILE);
+       WriteOpers("Rehashing config file %s due to SIGHUP",CleanFilename(CONFIG_FILE));
        fclose(Config->log_file);
        OpenLog(NULL,0);
        Config->Read(false,NULL);
+       FOREACH_MOD(I_OnRehash,OnRehash(""));
 }