summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/misc.cpp7
-rw-r--r--src/modulemanager.cpp86
-rw-r--r--src/regchannel.cpp29
-rw-r--r--src/version.sh6
4 files changed, 67 insertions, 61 deletions
diff --git a/src/misc.cpp b/src/misc.cpp
index 57314c53b..a6addbc3f 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -11,7 +11,7 @@
*/
#include "services.h"
-#include "version.h"
+#include "build.h"
#include "modules.h"
#include "lists.h"
#include "config.h"
@@ -617,11 +617,6 @@ const Anope::string Anope::LastError()
#endif
}
-ModuleVersion Module::GetVersion() const
-{
- return ModuleVersion(VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
-}
-
Anope::string Anope::Version()
{
#ifdef VERSION_GIT
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 2e7c624cd..98342b08e 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -166,6 +166,46 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
return MOD_ERR_NOLOAD;
}
+ try
+ {
+ ModuleVersion v = GetVersion(handle);
+
+ 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;
+ }
+
dlerror();
Module *(*func)(const Anope::string &, const Anope::string &) = function_cast<Module *(*)(const Anope::string &, const Anope::string &)>(dlsym(handle, "AnopeInit"));
err = dlerror();
@@ -206,34 +246,6 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
m->filename = pbuf;
m->handle = handle;
- 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
{
@@ -272,6 +284,24 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
return MOD_ERR_OK;
}
+ModuleVersion ModuleManager::GetVersion(void *handle)
+{
+ dlerror();
+ ModuleVersion (*func)() = function_cast<ModuleVersion (*)()>(dlsym(handle, "AnopeVersion"));;
+ if (!func)
+ {
+ Log() << "No version function found, not an Anope module";
+
+ const char *err = dlerror();
+ if (err && *err)
+ Log(LOG_DEBUG) << err;
+
+ throw ModuleException("No version");
+ }
+
+ return func();
+}
+
ModuleReturn ModuleManager::UnloadModule(Module *m, User *u)
{
if (!m)
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 37fca0528..397a6f28b 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -137,30 +137,6 @@ ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Serializable("ChannelInfo"),
this->access->clear();
this->akick->clear();
- for (unsigned i = 0; i < ci.GetAccessCount(); ++i)
- {
- const ChanAccess *taccess = ci.GetAccess(i);
- AccessProvider *provider = taccess->provider;
-
- ChanAccess *newaccess = provider->Create();
- newaccess->SetMask(taccess->Mask(), this);
- newaccess->creator = taccess->creator;
- newaccess->last_seen = taccess->last_seen;
- newaccess->created = taccess->created;
- newaccess->AccessUnserialize(taccess->AccessSerialize());
-
- this->AddAccess(newaccess);
- }
-
- for (unsigned i = 0; i < ci.GetAkickCount(); ++i)
- {
- const AutoKick *takick = ci.GetAkick(i);
- if (takick->nc)
- this->AddAkick(takick->creator, takick->nc, takick->reason, takick->addtime, takick->last_used);
- else
- this->AddAkick(takick->creator, takick->mask, takick->reason, takick->addtime, takick->last_used);
- }
-
FOREACH_MOD(OnCreateChan, (this));
}
@@ -575,6 +551,11 @@ void ChannelInfo::ClearAkick()
delete this->akick->back();
}
+const Anope::map<int16_t> &ChannelInfo::GetLevelEntries()
+{
+ return this->levels;
+}
+
int16_t ChannelInfo::GetLevel(const Anope::string &priv) const
{
if (PrivilegeManager::FindPrivilege(priv) == NULL)
diff --git a/src/version.sh b/src/version.sh
index a7046fa72..198556b24 100644
--- a/src/version.sh
+++ b/src/version.sh
@@ -1,7 +1,7 @@
#!/bin/sh
-VERSION_MAJOR="2"
-VERSION_MINOR="0"
-VERSION_PATCH="2"
+VERSION_MAJOR=2
+VERSION_MINOR=0
+VERSION_PATCH=2
VERSION_EXTRA="-git"