diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-14 18:17:08 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-14 18:17:08 +0000 |
commit | 601d67fd5f5a9e430a59a1930382eae67eb39fb4 (patch) | |
tree | 7dd07ff306540097f70b6689feca83f60ac002a5 | |
parent | 7866c42d8f80723d07cf38ed9413857164b55e00 (diff) |
Move revision information from Version object to a static symbol
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12256 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/dynamic.h | 5 | ||||
-rw-r--r-- | include/modules.h | 16 | ||||
-rw-r--r-- | src/commands/cmd_modules.cpp | 8 | ||||
-rw-r--r-- | src/dynamic.cpp | 13 | ||||
-rw-r--r-- | src/modmanager_dynamic.cpp | 4 | ||||
-rw-r--r-- | src/modules.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_httpd_stats.cpp | 2 |
7 files changed, 45 insertions, 13 deletions
diff --git a/include/dynamic.h b/include/dynamic.h index ccb22f8cc..01bdcdec5 100644 --- a/include/dynamic.h +++ b/include/dynamic.h @@ -45,7 +45,10 @@ class CoreExport DLLManager : public classbase /** Return a module by calling the init function */ - Module* callInit(); + Module* CallInit(); + + /** Get detailed version information from the module file */ + std::string GetVersion(); }; #endif diff --git a/include/modules.h b/include/modules.h index f980caf41..a3f596091 100644 --- a/include/modules.h +++ b/include/modules.h @@ -180,17 +180,22 @@ class CoreExport VersionBase /** Module description */ const std::string description; - /** Version information. - */ - const std::string version; /** Flags */ const int Flags; + /** Server linking description string */ + const std::string link_data; + /** Initialize version class */ - VersionBase(const std::string &desc, int flags = VF_NONE, const std::string& src_rev = VERSION " r" REVISION); + VersionBase(const std::string &desc, int flags = VF_NONE); + + virtual ~VersionBase() {} + + /** Return true if the module can link (default is identity comparison) */ + virtual bool CanLink(const std::string& other_data); }; typedef VersionBase<API_VERSION> Version; @@ -1690,7 +1695,8 @@ struct AllModuleList { extern "C" DllExport Module * MODULE_INIT_SYM() \ { \ return new y; \ - } + } \ + extern "C" const char inspircd_src_version[] = VERSION " r" REVISION; #endif #define COMMAND_INIT(c) MODULE_INIT(CommandModule<c>) diff --git a/src/commands/cmd_modules.cpp b/src/commands/cmd_modules.cpp index 27f8246ca..eb93d2927 100644 --- a/src/commands/cmd_modules.cpp +++ b/src/commands/cmd_modules.cpp @@ -58,8 +58,14 @@ CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user) if (!(V.Flags & mult)) flags[pos] = '-'; +#ifdef PURE_STATIC + user->SendText(":%s 702 %s :%p %s %s :%s", ServerInstance->Config->ServerName.c_str(), + user->nick.c_str(), (void*)m, module_names[i].c_str(), flags.c_str(), V.description.c_str()); +#else + std::string srcrev = m->ModuleDLLManager->GetVersion(); user->SendText(":%s 702 %s :%p %s %s :%s - %s", ServerInstance->Config->ServerName.c_str(), - user->nick.c_str(), (void*)m, module_names[i].c_str(), flags.c_str(), V.description.c_str(), V.version.c_str()); + user->nick.c_str(), (void*)m, module_names[i].c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str()); +#endif } else { diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 719046dbe..ebaaa5191 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -45,7 +45,7 @@ union init_t { Module* (*fptr)(); }; -Module* DLLManager::callInit() +Module* DLLManager::CallInit() { if (!h) return NULL; @@ -60,3 +60,14 @@ Module* DLLManager::callInit() return (*initfn.fptr)(); } + +std::string DLLManager::GetVersion() +{ + if (!h) + return ""; + + const char* srcver = (char*)dlsym(h, "inspircd_src_version"); + if (srcver) + return srcver; + return "Unversioned module"; +} diff --git a/src/modmanager_dynamic.cpp b/src/modmanager_dynamic.cpp index f6b4617a0..2f686ec96 100644 --- a/src/modmanager_dynamic.cpp +++ b/src/modmanager_dynamic.cpp @@ -82,7 +82,7 @@ bool ModuleManager::Load(const char* filename) try { - newmod = newhandle->callInit(); + newmod = newhandle->CallInit(); if (newmod) { @@ -91,7 +91,7 @@ bool ModuleManager::Load(const char* filename) Version v = newmod->GetVersion(); ServerInstance->Logs->Log("MODULE", DEFAULT,"New module introduced: %s (Module version %s)%s", - filename, v.version.c_str(), (!(v.Flags & VF_VENDOR) ? " [3rd Party]" : " [Vendor]")); + filename, newhandle->GetVersion().c_str(), (!(v.Flags & VF_VENDOR) ? " [3rd Party]" : " [Vendor]")); Modules[filename_str] = newmod; } diff --git a/src/modules.cpp b/src/modules.cpp index 46582fc79..f460a6a28 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -26,11 +26,17 @@ // Version is a simple class for holding a modules version number template<> -VersionBase<API_VERSION>::VersionBase(const std::string &modv, int flags, const std::string& rev) -: description(modv), version(rev), Flags(flags) +VersionBase<API_VERSION>::VersionBase(const std::string &modv, int flags) +: description(modv), Flags(flags) { } +template<> +bool VersionBase<API_VERSION>::CanLink(const std::string& other_data) +{ + return link_data == other_data; +} + Request::Request(Module* src, Module* dst, const char* idstr) : id(idstr), source(src), dest(dst) { diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index 23dee0c08..00c6a5d7f 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -135,7 +135,7 @@ class ModuleHttpStats : public Module { Module* m = ServerInstance->Modules->Find(i->c_str()); Version v = m->GetVersion(); - data << "<module><name>" << *i << "</name><version>" << v.version << "</version><description>" << Sanitize(v.description) << "</description></module>"; + data << "<module><name>" << *i << "</name><description>" << Sanitize(v.description) << "</description></module>"; } data << "</modulelist><channellist>"; |