]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configreader.cpp
IT WORKS!
[user/henk/code/inspircd.git] / src / configreader.cpp
index e9301d70abefe27aab40af865d47fde8d1aacd17..06513253ce3e9aae91add9c00d54593b96fe6820 100644 (file)
@@ -1142,6 +1142,8 @@ void ServerConfig::Read(bool bail, User* user, int pass)
                 * at this point
                 */
 
+               if (!ServerInstance->Res)
+                       ServerInstance->Res = new DNS(ServerInstance);
                /** Note: This is safe, the method checks for user == NULL */
                ServerInstance->Parser->SetupCommandTable(user);
                ServerInstance->Modules->LoadAll();
@@ -1208,6 +1210,10 @@ void ServerConfig::Read(bool bail, User* user, int pass)
        {
                for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
                {
+                       /* Skip over modules that are aleready loaded for some reason */
+                       if (ServerInstance->Modules->Find(*adding))
+                               continue;
+
                        if (bail)
                                printf_c("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n", adding->c_str());
 
@@ -1253,6 +1259,24 @@ bool ServerConfig::Downloading()
        return (TotalDownloaded < IncludedFiles.size());
 }
 
+void ServerConfig::Complete(const std::string &filename, bool error)
+{
+       std::map<std::string, std::istream*>::iterator x = IncludedFiles.find(filename);
+
+       if (x != IncludedFiles.end())
+       {
+               TotalDownloaded++;
+               if (error)
+               {
+                       delete x->second;
+                       x->second = NULL;
+                       FileErrors++;
+               }
+       }
+
+       return;
+}
+
 void ServerConfig::StartDownloads()
 {
        if (isatty(0) && isatty(1) && isatty(2))
@@ -1268,7 +1292,7 @@ void ServerConfig::StartDownloads()
                ServerInstance->Log(DEBUG,"Begin download for %s", file.c_str());
                if ((file[0] == '/') || (file.substr(0, 7) == "file://"))
                {
-                       ServerInstance->Log(DEBUG,"Core-handled schema for %s %s", file.c_str(), file.substr(0,7).c_str());
+                       ServerInstance->Log(DEBUG,"Core-handled schema for %s", file.c_str());
                        /* For file:// schema files, we use std::ifstream which is a derivative of std::istream.
                         * For all other file schemas, we use a std::stringstream.
                         */
@@ -1282,7 +1306,11 @@ void ServerConfig::StartDownloads()
                                x->second = conf;
                        }
                        else
+                       {
+                               delete x->second;
+                               x->second = NULL;
                                FileErrors++;
+                       }
 
                        TotalDownloaded++;
                }
@@ -1290,6 +1318,18 @@ void ServerConfig::StartDownloads()
                {
                        /* Modules handle these */
                        ServerInstance->Log(DEBUG,"Module-handled schema for %s", x->first.c_str());
+
+                       /* For now, error it */
+                       int MOD_RESULT = 0;
+                       FOREACH_RESULT(I_OnDownloadFile, OnDownloadFile(file, x->second));
+                       if (MOD_RESULT == 0)
+                       {
+                               /* No module claimed this file */
+                               TotalDownloaded++;
+                               FileErrors++;
+                               delete x->second;
+                               x->second = NULL;
+                       }
                }
        }
 }
@@ -1321,8 +1361,8 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
        }
        else
        {
-               /* Check if the file open failed first */
-               if (IncludedFiles.find(filename) == IncludedFiles.end())
+               std::map<std::string, std::istream*>::iterator x = IncludedFiles.find(filename);
+               if (x == IncludedFiles.end())
                {
                        if (pass == 0)
                        {
@@ -1340,7 +1380,15 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
                        }
                }
                else
-                       conf = IncludedFiles.find(filename)->second;
+               {
+                       if (x->second)
+                               conf = IncludedFiles.find(filename)->second;
+                       else
+                       {
+                               errorstream << "File " << filename << " could not be opened." << std::endl;
+                               return false;
+                       }
+               }
        }
 
        /* Start reading characters... */