diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/language.cpp | 10 | ||||
-rw-r--r-- | src/modulemanager.cpp | 47 |
2 files changed, 18 insertions, 39 deletions
diff --git a/src/language.cpp b/src/language.cpp index 8fd15a693..91b28e3df 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -2430,6 +2430,8 @@ Anope::string language_strings[LANG_STRING_COUNT] = { _("Module %s loaded"), /* OPER_MODULE_UNLOADED */ _("Module %s unloaded"), + /* OPER_MODULE_RELOADED */ + _("Module \002%s\002 reloaded"), /* OPER_MODULE_LOAD_FAIL */ _("Unable to load module %s"), /* OPER_MODULE_REMOVE_FAIL */ @@ -2444,6 +2446,8 @@ Anope::string language_strings[LANG_STRING_COUNT] = { _("MODLOAD FileName"), /* OPER_MODULE_UNLOAD_SYNTAX */ _("MODUNLOAD FileName"), + /* OPER_MODULE_RELOAD_SYNTAX */ + _("MODRELOAD \037FileName\037"), /* OPER_MODULE_LIST_HEADER */ _("Current Module list:"), /* OPER_MODULE_LIST */ @@ -4570,6 +4574,8 @@ Anope::string language_strings[LANG_STRING_COUNT] = { _(" MODLOAD Load a module"), /* OPER_HELP_CMD_MODUNLOAD */ _(" MODUNLOAD Un-Load a module"), + /* OPER_HELP_CMD_MODRELOAD */ + _(" MODRELOAD Reload a module"), /* OPER_HELP_CMD_MODINFO */ _(" MODINFO Info about a loaded module"), /* OPER_HELP_CMD_MODLIST */ @@ -4977,6 +4983,10 @@ Anope::string language_strings[LANG_STRING_COUNT] = { " \n" "This command unloads the module named FileName from the modules\n" "directory."), + /* OPER_HELP_MODRELOAD */ + _("Syntax: \002MODRELOAD\002 \002FileName\002\n" + " \n" + "This command reloads the module named FileName."), /* OPER_HELP_MODINFO */ _("Syntax: MODINFO FileName\n" " \n" diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index e637d32c6..2c716acf6 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -28,7 +28,7 @@ void ModuleManager::LoadModuleList(std::list<Anope::string> &ModuleList) * @param output the destination to copy the module to * @return MOD_ERR_OK on success */ -static int moduleCopyFile(const Anope::string &name, Anope::string &output) +static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &output) { Anope::string input = services_dir + "/modules/" + name + ".so"; FILE *source = fopen(input.c_str(), "rb"); @@ -107,7 +107,7 @@ template <class TYPE> TYPE function_cast(ano_module_t symbol) return cast.function; } -int ModuleManager::LoadModule(const Anope::string &modname, User *u) +ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) { if (modname.empty()) return MOD_ERR_PARAMS; @@ -121,7 +121,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) Anope::string pbuf = services_dir + "/modules/runtime/" + modname + ".so.XXXXXX"; /* Don't skip return value checking! -GD */ - int ret = moduleCopyFile(modname, pbuf); + ModuleReturn ret = moduleCopyFile(modname, pbuf); if (ret != MOD_ERR_OK) { /* XXX: This used to assign filename here, but I don't think that was correct.. @@ -167,7 +167,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) catch (const ModuleException &ex) { Log() << "Error while loading " << modname << ": " << ex.GetReason(); - return MOD_STOP; + return MOD_ERR_EXCEPTION; } m->filename = pbuf; @@ -178,13 +178,13 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) { Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR; DeleteModule(m); - return MOD_STOP; + return MOD_ERR_VERSION; } else if (v.GetMajor() > VERSION_MAJOR || (v.GetMajor() == VERSION_MAJOR && v.GetMinor() > VERSION_MINOR)) { Log() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << VERSION_MAJOR << "." << VERSION_MINOR; DeleteModule(m); - return MOD_STOP; + return MOD_ERR_VERSION; } else if (v.GetBuild() < VERSION_BUILD) Log() << "Module " << modname << " is compiled against an older revision of Anope " << v.GetBuild() << ", this is " << VERSION_BUILD; @@ -197,18 +197,7 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) { DeleteModule(m); Log() << "You cannot load two protocol modules"; - return MOD_STOP; - } - - if (u) - { - ircdproto->SendGlobops(OperServ, "%s loaded module %s", u->nick.c_str(), modname.c_str()); - u->SendMessage(OperServ, OPER_MODULE_LOADED, modname.c_str()); - - /* If a user is loading this module, then the core databases have already been loaded - * so trigger the event manually - */ - m->OnPostLoadDatabases(); + return MOD_ERR_UNKNOWN; } FOREACH_MOD(I_OnModuleLoad, OnModuleLoad(u, m)); @@ -216,28 +205,8 @@ int ModuleManager::LoadModule(const Anope::string &modname, User *u) return MOD_ERR_OK; } -int ModuleManager::UnloadModule(Module *m, User *u) +ModuleReturn ModuleManager::UnloadModule(Module *m, User *u) { - if (!m || !m->handle) - { - if (u) - u->SendMessage(OperServ, OPER_MODULE_REMOVE_FAIL, m->name.c_str()); - return MOD_ERR_PARAMS; - } - - if (m->GetPermanent() || m->type == PROTOCOL || m->type == ENCRYPTION || m->type == DATABASE) - { - if (u) - u->SendMessage(OperServ, OPER_MODULE_NO_UNLOAD); - return MOD_ERR_NOUNLOAD; - } - - if (u) - { - ircdproto->SendGlobops(OperServ, "%s unloaded module %s", u->nick.c_str(), m->name.c_str()); - u->SendMessage(OperServ, OPER_MODULE_UNLOADED, m->name.c_str()); - } - FOREACH_MOD(I_OnModuleUnload, OnModuleUnload(u, m)); if (DNSEngine) |