]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Allow opermotd to specify its file in <files> without also requiring an <opermotd...
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 2 Feb 2010 19:03:07 +0000 (19:03 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Tue, 2 Feb 2010 19:03:07 +0000 (19:03 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12355 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules.cpp
src/modules/m_httpd_acl.cpp
src/modules/m_httpd_config.cpp
src/modules/m_httpd_stats.cpp
src/modules/m_opermotd.cpp

index d4ba9145a6b527491d86cb805d4a47a1cce94c85..52a25d37cc8e0a43001776e402675eaf450364a1 100644 (file)
@@ -693,6 +693,7 @@ void FileReader::LoadFile(const std::string &filename)
        }
        else
        {
+               fc.clear();
                FILE* f = fopen(filename.c_str(), "r");
                if (!f)
                        return;
index 0086cdd0fb9436fbf157c55a317d8f0b751361cf..94cc4045f0b86869342708d2e7df9ecab2ff2723 100644 (file)
@@ -46,12 +46,12 @@ class ModuleHTTPAccessList : public Module
        void ReadConfig()
        {
                acl_list.clear();
-               ConfigReader c;
-               int n_items = c.Enumerate("httpdacl");
-               for (int i = 0; i < n_items; ++i)
+               ConfigTagList acls = ServerInstance->Config->ConfTags("httpdacl");
+               for (ConfigIter i = acls.first; i != acls.second; i++)
                {
-                       std::string path = c.ReadValue("httpdacl", "path", i);
-                       std::string types = c.ReadValue("httpdacl", "types", i);
+                       ConfigTag* c = i->second;
+                       std::string path = c->getString("path");
+                       std::string types = c->getString("types");
                        irc::commasepstream sep(types);
                        std::string type;
                        std::string username;
@@ -63,16 +63,16 @@ class ModuleHTTPAccessList : public Module
                        {
                                if (type == "password")
                                {
-                                       username = c.ReadValue("httpdacl", "username", i);
-                                       password = c.ReadValue("httpdacl", "password", i);
+                                       username = c->getString("username");
+                                       password = c->getString("password");
                                }
                                else if (type == "whitelist")
                                {
-                                       whitelist = c.ReadValue("httpdacl", "whitelist", i);
+                                       whitelist = c->getString("whitelist");
                                }
                                else if (type == "blacklist")
                                {
-                                       blacklist = c.ReadValue("httpdacl", "blacklist", i);
+                                       blacklist = c->getString("blacklist");
                                }
                                else
                                {
index 2183f0aed13586cb6aee2e9a0d767f5f2646a386..f79f0c2a4a1f0cb7e4496b7987aaa02806990eeb 100644 (file)
 #include "protocol.h"
 
 /* $ModDesc: Provides statistics over HTTP via m_httpd.so */
-/* $ModDep: httpd.h */
 
-class ModuleHttpStats : public Module
+class ModuleHttpConfig : public Module
 {
-
-       std::string stylesheet;
-       bool changed;
-
  public:
-
-       void ReadConfig()
-       {
-               ConfigReader c;
-               this->stylesheet = c.ReadValue("httpstats", "stylesheet", 0);
-       }
-
-       ModuleHttpStats()       {
-               ReadConfig();
-               this->changed = true;
+       ModuleHttpConfig()      {
                Implementation eventlist[] = { I_OnEvent };
                ServerInstance->Modules->Attach(eventlist, this, 1);
        }
@@ -108,14 +94,14 @@ class ModuleHttpStats : public Module
                }
        }
 
-       virtual ~ModuleHttpStats()
+       virtual ~ModuleHttpConfig()
        {
        }
 
        virtual Version GetVersion()
        {
-               return Version("Provides statistics over HTTP via m_httpd.so", VF_VENDOR);
+               return Version("Provides configuration over HTTP via m_httpd.so", VF_VENDOR);
        }
 };
 
-MODULE_INIT(ModuleHttpStats)
+MODULE_INIT(ModuleHttpConfig)
index 00c6a5d7f7669f615803a37159ea5ce18d58337f..a682cd14c71b50a5019e76c6d173668283f02161 100644 (file)
 class ModuleHttpStats : public Module
 {
        static std::map<char, char const*> const &entities;
-       std::string stylesheet;
-       bool changed;
 
  public:
 
-       void ReadConfig()
-       {
-               ConfigReader c;
-               this->stylesheet = c.ReadValue("httpstats", "stylesheet", 0);
-       }
-
        ModuleHttpStats()       {
-               ReadConfig();
-               this->changed = true;
                Implementation eventlist[] = { I_OnEvent };
                ServerInstance->Modules->Attach(eventlist, this, 1);
        }
index be832e28934086f573cb070ccfde965cf2adea2f..7b4584db9c52fdd0a0c05553f49a875809f94017 100644 (file)
@@ -63,12 +63,9 @@ class ModuleOpermotd : public Module
 
        void LoadOperMOTD()
        {
-               ConfigReader conf;
-               std::string filename;
-               filename = conf.ReadValue("opermotd","file",0);
-               delete opermotd;
-               opermotd = new FileReader(filename);
-               onoper = conf.ReadFlag("opermotd","onoper","yes",0);
+               ConfigTag* conf = ServerInstance->Config->ConfValue("opermotd");
+               opermotd->LoadFile(conf->getString("file","opermotd"));
+               onoper = conf->getBool("onoper", true);
        }
 
        ModuleOpermotd()
@@ -84,6 +81,8 @@ class ModuleOpermotd : public Module
 
        virtual ~ModuleOpermotd()
        {
+               delete opermotd;
+               opermotd = NULL;
        }
 
        virtual Version GetVersion()
@@ -91,7 +90,6 @@ class ModuleOpermotd : public Module
                return Version("Shows a message to opers after oper-up, adds /opermotd", VF_VENDOR);
        }
 
-
        virtual void OnOper(User* user, const std::string &opertype)
        {
                if (onoper)