Only export a single function from modules

This moves the version check into the function which loads the module info. That
way, we just need a single dlsym() call per module and thus can't get any errors
from the second dlsym() call. And IMHO this feels nicer anyway. ;-)

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter
2011-06-11 18:33:50 +02:00
parent ca97dca6dc
commit 25ce7de020
2 changed files with 10 additions and 19 deletions

View File

@@ -1080,16 +1080,7 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
return NULL;
}
typedef double (*dFP)();
dFP Version = (dFP) dlsym(p, "ZNCModVersion");
if (!Version) {
dlclose(p);
sRetMsg = "Could not find ZNCModVersion() in module [" + sModule + "]";
return NULL;
}
typedef void (*InfoFP)(CModInfo&);
typedef bool (*InfoFP)(double, CModInfo&);
InfoFP ZNCModInfo = (InfoFP) dlsym(p, "ZNCModInfo");
if (!ZNCModInfo) {
@@ -1098,13 +1089,12 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
return NULL;
}
if (CModule::GetCoreVersion() != Version()) {
bVersionMismatch = true;
sRetMsg = "Version mismatch, recompile this module.";
} else {
ZNCModInfo(Info);
if (ZNCModInfo(CModule::GetCoreVersion(), Info)) {
sRetMsg = "";
bVersionMismatch = false;
} else {
bVersionMismatch = true;
sRetMsg = "Version mismatch, recompile this module.";
}
return p;