summaryrefslogtreecommitdiff
path: root/src/modulemanager.cpp
diff options
context:
space:
mode:
authorAdam <Adam@drink-coca-cola.info>2010-05-14 20:35:38 -0400
committerAdam <Adam@anope.org>2010-06-18 21:01:53 -0400
commitf049124905bd9f53439293e873003cb027a17b91 (patch)
tree352ed9251fd47055dd770aa2d5eabb20247e4b43 /src/modulemanager.cpp
parent81a45520a773732c9f46785f27aa1956150775d7 (diff)
Rewrote the hashing system to use std::tr1::unordered_map
Diffstat (limited to 'src/modulemanager.cpp')
-rw-r--r--src/modulemanager.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 18ab2bda4..b11ad2829 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -18,7 +18,7 @@ void ModuleManager::LoadModuleList(std::list<std::string> &ModuleList)
{
for (std::list<std::string>::iterator it = ModuleList.begin(); it != ModuleList.end(); ++it)
{
- Module *m = findModule(it->c_str());
+ Module *m = FindModule(*it);
if (!m)
ModuleManager::LoadModule(*it, NULL);
}
@@ -79,16 +79,13 @@ static int moduleCopyFile(const char *name, const char *output)
static bool IsOneOfModuleTypeLoaded(MODType mt)
{
- int idx = 0;
- ModuleHash *current = NULL;
int pmods = 0;
- for (idx = 0; idx != MAX_CMD_HASH; idx++)
+ for (std::deque<Module *>::iterator it = Modules.begin(); it != Modules.end(); ++it)
{
- for (current = MODULE_HASH[idx]; current; current = current->next)
+ if ((*it)->type == mt)
{
- if (current->m->type == mt)
- pmods++;
+ ++pmods;
}
}
@@ -127,7 +124,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
if (modname.empty())
return MOD_ERR_PARAMS;
- if (findModule(modname.c_str()) != NULL)
+ if (FindModule(modname) != NULL)
return MOD_ERR_EXISTS;
Alog(LOG_DEBUG) << "trying to load [" << modname << "]";
@@ -235,7 +232,7 @@ int ModuleManager::LoadModule(const std::string &modname, User * u)
if (u)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s loaded module %s", u->nick.c_str(), modname.c_str());
+ ircdproto->SendGlobops(OperServ, "%s loaded module %s", u->nick.c_str(), modname.c_str());
notice_lang(Config.s_OperServ, u, OPER_MODULE_LOADED, modname.c_str());
/* If a user is loading this module, then the core databases have already been loaded
@@ -267,7 +264,7 @@ int ModuleManager::UnloadModule(Module *m, User *u)
if (u)
{
- ircdproto->SendGlobops(findbot(Config.s_OperServ), "%s unloaded module %s", u->nick.c_str(), m->name.c_str());
+ ircdproto->SendGlobops(OperServ, "%s unloaded module %s", u->nick.c_str(), m->name.c_str());
notice_lang(Config.s_OperServ, u, OPER_MODULE_UNLOADED, m->name.c_str());
}
@@ -468,3 +465,21 @@ void ModuleManager::ClearCallBacks(Module *m)
delete m->CallBacks.front();
}
+/** Unloading all modules, NEVER call this when Anope isn't shutting down.
+ * Ever.
+ * @param unload_proto true to unload the protocol module
+ */
+void ModuleManager::UnloadAll(bool unload_proto)
+{
+ for (std::deque<Module *>::iterator it = Modules.begin(); it != Modules.end();)
+ {
+ Module *m = *it++;
+
+ if (unload_proto || m->type != PROTOCOL)
+ DeleteModule(m);
+
+ if (Modules.empty())
+ break;
+ }
+}
+