]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configreader.cpp
More stuff
[user/henk/code/inspircd.git] / src / configreader.cpp
index 2138d0638baba6d00ffac7d6dfdb7c992d544a3e..ec5f1fe5481f88393cd2d639c97cefb8d2cae076 100644 (file)
@@ -1243,14 +1243,24 @@ void ServerConfig::Read(bool bail, User* user, int pass)
 
 bool ServerConfig::Downloading()
 {
-       ServerInstance->Log(DEBUG, "ServerConfig::Downloading() TotalDownloaded %u of %u", TotalDownloaded, IncludedFiles.size());
+       if (isatty(0) && isatty(1) && isatty(2))
+       {
+               printf(".");
+               fflush(stdout);
+       }
+
        /* Returns true if there are still files in the process of downloading */
        return (TotalDownloaded < IncludedFiles.size());
 }
 
 void ServerConfig::StartDownloads()
 {
+       if (isatty(0) && isatty(1) && isatty(2))
+               printf("Downloading configuration ");
+
        TotalDownloaded = 0;
+       FileErrors = 0;
+
        /* Reads all local files into the IncludedFiles map, then initiates sockets for the remote ones */
        for (std::map<std::string, std::istream*>::iterator x = IncludedFiles.begin(); x != IncludedFiles.end(); ++x)
        {
@@ -1258,7 +1268,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.
                         */
@@ -1271,6 +1281,12 @@ void ServerConfig::StartDownloads()
                                delete x->second;
                                x->second = conf;
                        }
+                       else
+                       {
+                               delete x->second;
+                               x->second = NULL;
+                               FileErrors++;
+                       }
 
                        TotalDownloaded++;
                }
@@ -1278,6 +1294,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, reinterpret_cast<std::istringstream*>(x->second)));
+                       if (MOD_RESULT == 0)
+                       {
+                               /* No module claimed this file */
+                               TotalDownloaded++;
+                               FileErrors++;
+                               delete x->second;
+                               x->second = NULL;
+                       }
                }
        }
 }
@@ -1309,8 +1337,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)
                        {
@@ -1328,7 +1356,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... */