X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodmanager_static.cpp;h=4de111b63ae44e303b906f069915e609a52f5d52;hb=7ece928bab20881d6fe24c4479f4ff9e0a8a7179;hp=7d6c89258852a6493fabda7965e64efc4024872b;hpb=8a64bd3a0ac72855b681b00f3a9a08cebee755ce;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp index 7d6c89258..4de111b63 100644 --- a/src/modmanager_static.cpp +++ b/src/modmanager_static.cpp @@ -17,13 +17,13 @@ */ -#define MODNAME "cmd_all" +#define MODNAME "core_all" #include "inspircd.h" #include "exitcodes.h" #include -#ifdef PURE_STATIC +#ifdef INSPIRCD_STATIC typedef std::map modmap; static std::vector* cmdlist = NULL; @@ -58,7 +58,6 @@ class AllModule : public Module { Command* c = (*i)(this); cmds.push_back(c); - ServerInstance->Modules->AddService(*c); } } catch (...) @@ -70,11 +69,10 @@ class AllModule : public Module ~AllModule() { - for(std::vector::iterator i = cmds.begin(); i != cmds.end(); ++i) - delete *i; + stdalgo::delete_all(cmds); } - Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("All commands", VF_VENDOR|VF_CORE); } @@ -82,12 +80,18 @@ class AllModule : public Module MODULE_INIT(AllModule) -bool ModuleManager::Load(const std::string& name, bool defer) +bool ModuleManager::Load(const std::string& inputname, bool defer) { + const std::string name = ExpandModName(inputname); modmap::iterator it = modlist->find(name); if (it == modlist->end()) return false; Module* mod = NULL; + + ServiceList newservices; + if (!defer) + this->NewServices = &newservices; + try { mod = (*it->second->init)(); @@ -95,6 +99,7 @@ bool ModuleManager::Load(const std::string& name, bool defer) mod->ModuleDLLManager = NULL; mod->dying = false; Modules[name] = mod; + this->NewServices = NULL; if (defer) { ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "New module introduced: %s", name.c_str()); @@ -105,12 +110,15 @@ bool ModuleManager::Load(const std::string& name, bool defer) ConfigStatus confstatus; AttachAll(mod); + AddServices(newservices); mod->init(); mod->ReadConfig(confstatus); } } catch (CoreException& modexcept) { + this->NewServices = NULL; + if (mod) DoSafeUnload(mod); ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Unable to load " + name + ": " + modexcept.GetReason()); @@ -123,12 +131,18 @@ bool ModuleManager::Load(const std::string& name, bool defer) return true; } -void ModuleManager::LoadCoreModules() +void ModuleManager::LoadCoreModules(std::map& servicemap) { - Load("cmd_all.so", true); - Load("cmd_whowas.so", true); - Load("cmd_lusers.so", true); - Load("cmd_privmsg.so", true); + for (modmap::const_iterator i = modlist->begin(); i != modlist->end(); ++i) + { + const std::string modname = i->first; + if (InspIRCd::Match(modname, "core_*.so", ascii_case_insensitive_map)) + { + this->NewServices = &servicemap[modname]; + Load(modname, true); + } + } + this->NewServices = NULL; } #endif