]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configparser.cpp
Add requiresasl to connect block checks
[user/henk/code/inspircd.git] / src / configparser.cpp
index 0e77cbb3679deaf445bf9e4dd2c1fe29745ed8a0..558c49117dd69ff6343015205c354c8a27e04af2 100644 (file)
@@ -177,6 +177,20 @@ struct Parser
                {
                        stack.DoInclude(tag, flags);
                }
+               else if (name == "files")
+               {
+                       for(std::vector<KeyVal>::iterator i = items->begin(); i != items->end(); i++)
+                       {
+                               stack.DoReadFile(i->first, i->second, flags, false);
+                       }
+               }
+               else if (name == "execfiles")
+               {
+                       for(std::vector<KeyVal>::iterator i = items->begin(); i != items->end(); i++)
+                       {
+                               stack.DoReadFile(i->first, i->second, flags, true);
+                       }
+               }
                else if (name == "define")
                {
                        if (!(flags & FLAG_USE_XML))
@@ -275,6 +289,29 @@ void ParseStack::DoInclude(ConfigTag* tag, int flags)
        }
 }
 
+void ParseStack::DoReadFile(const std::string& key, const std::string& name, int flags, bool exec)
+{
+       if (flags & FLAG_NO_INC)
+               throw CoreException("Invalid <files> tag in file included with noinclude=\"yes\"");
+       if (exec && (flags & FLAG_NO_EXEC))
+               throw CoreException("Invalid <execfiles> tag in file included with noexec=\"yes\"");
+
+       FileWrapper file(exec ? popen(name.c_str(), "r") : fopen(name.c_str(), "r"));
+       if (!file)
+               throw CoreException("Could not read \"" + name + "\" for \"" + key + "\" file");
+
+       file_cache& cache = FilesOutput[key];
+       cache.clear();
+
+       char linebuf[MAXBUF*10];
+       while (fgets(linebuf, sizeof(linebuf), file))
+       {
+               int len = strlen(linebuf);
+               if (len)
+                       cache.push_back(std::string(linebuf, len - 1));
+       }
+}
+
 bool ParseStack::ParseFile(const std::string& name, int flags)
 {
        ServerInstance->Logs->Log("CONFIG", DEBUG, "Reading file %s", name.c_str());