summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-08-16 12:20:06 +0200
committerattilamolnar <attilamolnar@hush.com>2013-08-30 13:15:10 +0200
commitd349f981fbe70fb11e3db4c486f59749ffe74c2b (patch)
tree8de831914936c0af823fb4969193e58481275a48 /src
parentc202dea024542b9c6c6b771bb9a3a081d9eacdc5 (diff)
Remove ModuleManager::GetAllModuleNames(), use GetModules() instead
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_modules.cpp12
-rw-r--r--src/configreader.cpp21
-rw-r--r--src/modules.cpp9
-rw-r--r--src/modules/m_httpd_stats.cpp9
-rw-r--r--src/modules/m_spanningtree/capab.cpp13
5 files changed, 27 insertions, 37 deletions
diff --git a/src/commands/cmd_modules.cpp b/src/commands/cmd_modules.cpp
index b8a1805b0..c37008563 100644
--- a/src/commands/cmd_modules.cpp
+++ b/src/commands/cmd_modules.cpp
@@ -51,11 +51,11 @@ class CommandModules : public Command
*/
CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user)
{
- std::vector<std::string> module_names = ServerInstance->Modules->GetAllModuleNames(0);
+ const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
- for (unsigned int i = 0; i < module_names.size(); i++)
+ for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
{
- Module* m = ServerInstance->Modules->Find(module_names[i]);
+ Module* m = i->second;
Version V = m->GetVersion();
if (user->HasPrivPermission("servers/auspex"))
@@ -68,17 +68,17 @@ CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user)
#ifdef PURE_STATIC
user->SendText(":%s 702 %s :%p %s %s :%s", ServerInstance->Config->ServerName.c_str(),
- user->nick.c_str(), (void*)m, module_names[i].c_str(), flags.c_str(), V.description.c_str());
+ user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str());
#else
std::string srcrev = m->ModuleDLLManager->GetVersion();
user->SendText(":%s 702 %s :%p %s %s :%s - %s", ServerInstance->Config->ServerName.c_str(),
- user->nick.c_str(), (void*)m, module_names[i].c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str());
+ user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str());
#endif
}
else
{
user->SendText(":%s 702 %s :%s %s", ServerInstance->Config->ServerName.c_str(),
- user->nick.c_str(), module_names[i].c_str(), V.description.c_str());
+ user->nick.c_str(), m->ModuleSourceFile.c_str(), V.description.c_str());
}
}
user->SendText(":%s 703 %s :End of MODULES list", ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
diff --git a/src/configreader.cpp b/src/configreader.cpp
index a08047678..656bc338a 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -673,9 +673,8 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
void ServerConfig::ApplyModules(User* user)
{
- const std::vector<std::string> v = ServerInstance->Modules->GetAllModuleNames(0);
std::vector<std::string> added_modules;
- std::set<std::string> removed_modules(v.begin(), v.end());
+ ModuleManager::ModuleMap removed_modules = ServerInstance->Modules->GetModules();
ConfigTagList tags = ConfTags("module");
for(ConfigIter i = tags.first; i != tags.second; ++i)
@@ -691,27 +690,27 @@ void ServerConfig::ApplyModules(User* user)
}
}
- for (std::set<std::string>::iterator removing = removed_modules.begin(); removing != removed_modules.end(); removing++)
+ for (ModuleManager::ModuleMap::iterator i = removed_modules.begin(); i != removed_modules.end(); ++i)
{
+ const std::string& modname = i->first;
// Don't remove cmd_*.so, just remove m_*.so
- if (removing->c_str()[0] == 'c')
+ if (modname.c_str()[0] == 'c')
continue;
- Module* m = ServerInstance->Modules->Find(*removing);
- if (m && ServerInstance->Modules->Unload(m))
+ if (ServerInstance->Modules->Unload(i->second))
{
- ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s",removing->c_str());
+ ServerInstance->SNO->WriteGlobalSno('a', "*** REHASH UNLOADED MODULE: %s", modname.c_str());
if (user)
- user->WriteNumeric(RPL_UNLOADEDMODULE, "%s %s :Module %s successfully unloaded.",user->nick.c_str(), removing->c_str(), removing->c_str());
+ user->WriteNumeric(RPL_UNLOADEDMODULE, "%s %s :Module %s successfully unloaded.",user->nick.c_str(), modname.c_str(), modname.c_str());
else
- ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", removing->c_str());
+ ServerInstance->SNO->WriteGlobalSno('a', "Module %s successfully unloaded.", modname.c_str());
}
else
{
if (user)
- user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s %s :Failed to unload module %s: %s",user->nick.c_str(), removing->c_str(), removing->c_str(), ServerInstance->Modules->LastError().c_str());
+ user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s %s :Failed to unload module %s: %s",user->nick.c_str(), modname.c_str(), modname.c_str(), ServerInstance->Modules->LastError().c_str());
else
- ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", removing->c_str(), ServerInstance->Modules->LastError().c_str());
+ ServerInstance->SNO->WriteGlobalSno('a', "Failed to unload module %s: %s", modname.c_str(), ServerInstance->Modules->LastError().c_str());
}
}
diff --git a/src/modules.cpp b/src/modules.cpp
index d581b76a5..b6a28193a 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -560,15 +560,6 @@ Module* ModuleManager::Find(const std::string &name)
return modfind->second;
}
-const std::vector<std::string> ModuleManager::GetAllModuleNames(int filter)
-{
- std::vector<std::string> retval;
- for (std::map<std::string, Module*>::iterator x = Modules.begin(); x != Modules.end(); ++x)
- if (!filter || (x->second->GetVersion().Flags & filter))
- retval.push_back(x->first);
- return retval;
-}
-
FileReader::FileReader(const std::string& filename)
{
Load(filename);
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index 022d91f1e..5114b26d5 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -141,13 +141,12 @@ class ModuleHttpStats : public Module
}
data << "</xlines><modulelist>";
- std::vector<std::string> module_names = ServerInstance->Modules->GetAllModuleNames(0);
+ const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
- for (std::vector<std::string>::iterator i = module_names.begin(); i != module_names.end(); ++i)
+ for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
{
- Module* m = ServerInstance->Modules->Find(i->c_str());
- Version v = m->GetVersion();
- data << "<module><name>" << *i << "</name><description>" << Sanitize(v.description) << "</description></module>";
+ Version v = i->second->GetVersion();
+ data << "<module><name>" << i->first << "</name><description>" << Sanitize(v.description) << "</description></module>";
}
data << "</modulelist><channellist>";
diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp
index 1ca5b982c..f4f1e1ace 100644
--- a/src/modules/m_spanningtree/capab.cpp
+++ b/src/modules/m_spanningtree/capab.cpp
@@ -28,17 +28,18 @@
std::string TreeSocket::MyModules(int filter)
{
- std::vector<std::string> modlist = ServerInstance->Modules->GetAllModuleNames(filter);
+ const ModuleManager::ModuleMap& modlist = ServerInstance->Modules->GetModules();
std::string capabilities;
- sort(modlist.begin(),modlist.end());
- for (std::vector<std::string>::const_iterator i = modlist.begin(); i != modlist.end(); ++i)
+ for (ModuleManager::ModuleMap::const_iterator i = modlist.begin(); i != modlist.end(); ++i)
{
+ Version v = i->second->GetVersion();
+ if (!(v.Flags & filter))
+ continue;
+
if (i != modlist.begin())
capabilities.push_back(' ');
- capabilities.append(*i);
- Module* m = ServerInstance->Modules->Find(*i);
- Version v = m->GetVersion();
+ capabilities.append(i->first);
if (!v.link_data.empty())
{
capabilities.push_back('=');