*/
-#define MODNAME "cmd_all"
+#define MODNAME "core_all"
#include "inspircd.h"
#include "exitcodes.h"
#include <iostream>
-#ifdef PURE_STATIC
+#ifdef INSPIRCD_STATIC
typedef std::map<std::string, AllModuleList*> modmap;
static std::vector<AllCommandList::fn>* cmdlist = NULL;
{
Command* c = (*i)(this);
cmds.push_back(c);
- ServerInstance->Modules->AddService(*c);
}
}
catch (...)
~AllModule()
{
- for(std::vector<Command*>::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);
}
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)();
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());
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());
return true;
}
-void ModuleManager::LoadCoreModules()
+void ModuleManager::LoadCoreModules(std::map<std::string, ServiceList>& 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