mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
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:
20
Modules.cpp
20
Modules.cpp
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user