diff options
-rw-r--r-- | include/modules.h | 8 | ||||
-rw-r--r-- | src/commands/cmd_modules.cpp | 12 | ||||
-rw-r--r-- | src/configreader.cpp | 21 | ||||
-rw-r--r-- | src/modules.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_httpd_stats.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_spanningtree/capab.cpp | 13 |
6 files changed, 27 insertions, 45 deletions
diff --git a/include/modules.h b/include/modules.h index 68044ae89..e81f9465c 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1347,14 +1347,6 @@ class CoreExport ModuleManager return static_cast<T*>(FindService(SERVICE_DATA, name)); } - /** Return a list of all modules matching the given filter - * @param filter This int is a bitmask of flags set in Module::Flags, - * such as VF_VENDOR or VF_STATIC. If you wish to receive a list of - * all modules with no filtering, set this to 0. - * @return The list of module names - */ - const std::vector<std::string> GetAllModuleNames(int filter); - /** Get a map of all loaded modules keyed by their name * @return A ModuleMap containing all loaded modules */ 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('='); |