]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Match USERINPUT/USEROUTPUT identifiers
[user/henk/code/inspircd.git] / src / modules.cpp
index a4b9e05fa7a13d04fbe41ca47bbcc16c536f79af..b3aabf284c10f6fb6f111987df5f1bade731378a 100644 (file)
@@ -51,15 +51,13 @@ void Event::Send()
 
 // These declarations define the behavours of the base class Module (which does nothing at all)
 
-Module::Module() : refcount(1) { }
+Module::Module() { }
 CullResult Module::cull()
 {
        return classbase::cull();
 }
 Module::~Module()
 {
-       if (refcount != 1)
-               ServerInstance->Logs->Log("MODULE", DEFAULT, "References remain to destructed module " + ModuleSourceFile);
 }
 
 ModResult      Module::OnSendSnotice(char &snomask, std::string &type, const std::string &message) { return MOD_RES_PASSTHRU; }
@@ -149,7 +147,8 @@ void                Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
 void           Module::OnRunTestSuite() { }
 void           Module::OnNamesListItem(User*, Membership*, std::string&, std::string&) { }
 ModResult      Module::OnNumeric(User*, unsigned int, const std::string&) { return MOD_RES_PASSTHRU; }
-void           Module::OnHookIO(StreamSocket*, ListenSocketBase*) { }
+void           Module::OnHookIO(StreamSocket*, ListenSocket*) { }
+ModResult   Module::OnAcceptConnection(int, ListenSocket*, irc::sockets::sockaddrs*, irc::sockets::sockaddrs*) { return MOD_RES_PASSTHRU; }
 void           Module::OnSendWhoLine(User*, User*, Channel*, std::string&) { }
 ModResult      Module::OnChannelRestrictionApply(User*, Channel*, const char*) { return MOD_RES_PASSTHRU; }
 
@@ -588,11 +587,10 @@ void ModuleManager::LoadAll()
                printf("\n");
        }
 
-       for(int count = 0;; count++)
+       ConfigTagList tags = ServerInstance->Config->ConfTags("module");
+       for(ConfigIter i = tags.first; i != tags.second; ++i)
        {
-               ConfigTag* tag = ServerInstance->Config->ConfValue("module", count);
-               if (!tag)
-                       break;
+               ConfigTag* tag = i->second;
                std::string name = tag->getString("name");
                printf_c("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n",name.c_str());
 
@@ -825,12 +823,23 @@ ConfigReader::~ConfigReader()
 {
 }
 
+static ConfigTag* SlowGetTag(const std::string &tag, int index)
+{
+       ConfigTagList tags = ServerInstance->Config->ConfTags(tag);
+       while (tags.first != tags.second)
+       {
+               if (!index)
+                       return tags.first->second;
+               tags.first++;
+               index--;
+       }
+       return NULL;
+}
 
 std::string ConfigReader::ReadValue(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool allow_linefeeds)
 {
-       /* Don't need to strlcpy() tag and name anymore, ReadConf() takes const char* */
        std::string result = default_value;
-       if (!ServerInstance->Config->ConfValue(tag, index)->readString(name, result, allow_linefeeds))
+       if (!SlowGetTag(tag, index)->readString(name, result, allow_linefeeds))
        {
                this->error = CONF_VALUE_NOT_FOUND;
        }
@@ -845,7 +854,7 @@ std::string ConfigReader::ReadValue(const std::string &tag, const std::string &n
 bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, const std::string &default_value, int index)
 {
        bool def = (default_value == "yes");
-       return ServerInstance->Config->ConfValue(tag, index)->getBool(name, def);
+       return SlowGetTag(tag, index)->getBool(name, def);
 }
 
 bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int index)
@@ -857,7 +866,7 @@ bool ConfigReader::ReadFlag(const std::string &tag, const std::string &name, int
 int ConfigReader::ReadInteger(const std::string &tag, const std::string &name, const std::string &default_value, int index, bool need_positive)
 {
        int v = atoi(default_value.c_str());
-       int result = ServerInstance->Config->ConfValue(tag, index)->getInt(name, v);
+       int result = SlowGetTag(tag, index)->getInt(name, v);
 
        if ((need_positive) && (result < 0))
        {
@@ -885,7 +894,7 @@ int ConfigReader::Enumerate(const std::string &tag)
        ServerInstance->Logs->Log("MODULE", DEBUG, "Module is using ConfigReader::Enumerate on %s; this is slow!",
                tag.c_str());
        int i=0;
-       while (ServerInstance->Config->ConfValue(tag, i)) i++;
+       while (SlowGetTag(tag, i)) i++;
        return i;
 }