diff options
author | Adam <Adam@anope.org> | 2015-10-27 18:57:37 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2015-10-27 18:58:48 -0400 |
commit | 64dac60071fab652745a6e7a06cf6b7bdbbd3625 (patch) | |
tree | f8f30161150451672b381f6370a8fdcab654bbb8 /src/modulemanager.cpp | |
parent | 162fdbe5815bbdf187f549fefac94ff476d72e62 (diff) | |
parent | 830361e97d03c74e54cb1cf1bbf329dffdeb66f7 (diff) |
Merge branch '2.0' into 2.1
Diffstat (limited to 'src/modulemanager.cpp')
-rw-r--r-- | src/modulemanager.cpp | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 9e70ab088..76cec0b57 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -162,7 +162,7 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) dlerror(); AnopeModule *module = static_cast<AnopeModule *>(dlsym(handle, "AnopeMod")); err = dlerror(); - if (!module || !module->init || !module->fini) + if (!module || module->api_version != ANOPE_MODAPI_VER) { Log() << "No module symbols function found, not an Anope module"; if (err && *err) @@ -171,6 +171,46 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) return MOD_ERR_NOLOAD; } + try + { + ModuleVersion v = module->version(); + + if (v.GetMajor() < Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() < Anope::VersionMinor())) + { + Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionShort(); + dlclose(handle); + return MOD_ERR_VERSION; + } + else if (v.GetMajor() > Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() > Anope::VersionMinor())) + { + Log() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionShort(); + dlclose(handle); + return MOD_ERR_VERSION; + } + else if (v.GetPatch() < Anope::VersionPatch()) + { + Log() << "Module " << modname << " is compiled against an older version of Anope, " << v.GetMajor() << "." << v.GetMinor() << "." << v.GetPatch() << ", this is " << Anope::VersionShort(); + dlclose(handle); + return MOD_ERR_VERSION; + } + else if (v.GetPatch() > Anope::VersionPatch()) + { + Log() << "Module " << modname << " is compiled against a newer version of Anope, " << v.GetMajor() << "." << v.GetMinor() << "." << v.GetPatch() << ", this is " << Anope::VersionShort(); + dlclose(handle); + return MOD_ERR_VERSION; + } + else + { + Log(LOG_DEBUG_2) << "Module " << modname << " is compiled against current version of Anope " << Anope::VersionShort(); + } + } + catch (const ModuleException &ex) + { + /* this error has already been logged */ + dlclose(handle); + return MOD_ERR_NOLOAD; + } + ModuleDef *def = module->init(); /* Create module. */ @@ -203,34 +243,6 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) m->def = def; m->module = module; - ModuleVersion v = m->GetVersion(); - if (v.GetMajor() < Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() < Anope::VersionMinor())) - { - Log() << "Module " << modname << " is compiled against an older version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionShort(); - DeleteModule(m); - return MOD_ERR_VERSION; - } - else if (v.GetMajor() > Anope::VersionMajor() || (v.GetMajor() == Anope::VersionMajor() && v.GetMinor() > Anope::VersionMinor())) - { - Log() << "Module " << modname << " is compiled against a newer version of Anope " << v.GetMajor() << "." << v.GetMinor() << ", this is " << Anope::VersionShort(); - DeleteModule(m); - return MOD_ERR_VERSION; - } - else if (v.GetPatch() < Anope::VersionPatch()) - { - Log() << "Module " << modname << " is compiled against an older version of Anope, " << v.GetMajor() << "." << v.GetMinor() << "." << v.GetPatch() << ", this is " << Anope::VersionShort(); - DeleteModule(m); - return MOD_ERR_VERSION; - } - else if (v.GetPatch() > Anope::VersionPatch()) - { - Log() << "Module " << modname << " is compiled against a newer version of Anope, " << v.GetMajor() << "." << v.GetMinor() << "." << v.GetPatch() << ", this is " << Anope::VersionShort(); - DeleteModule(m); - return MOD_ERR_VERSION; - } - else - Log(LOG_DEBUG_2) << "Module " << modname << " is compiled against current version of Anope " << Anope::VersionShort(); - /* Initialize config */ try { |