echo -n "Unknown"; \
fi)
VERSION := $(RELEASE)-$(SUBREL)
-SCAPIVERS := $(shell sed -ne '/define SCAPIVERS/ s/^.[a-zA-Z ]*\([0-9]*\).*$$/\1/p' $(PLUGIN).c)
+SCAPIVERS := $(shell sed -ne '/define SCAPIVERS/ s/^.[a-zA-Z ]*\([0-9]*\).*$$/\1/p' version.h)
### The directory environment:
#error Your VDR API version is too old. See README.
#endif
-// SC API version number for loading shared libraries
-#define SCAPIVERS 24
-
static cPlugin *ScPlugin;
static cOpts *ScOpts, *LogOpts;
static const char * const cfgsub="sc";
bool cScDll::Load(void)
{
char *base=rindex(fileName,'/');
- if(!base) base=fileName;
+ if(base) base++; else base=fileName;
PRINTF(L_CORE_DYN,"loading library: %s",base);
if(!handle) {
handle=dlopen(fileName,RTLD_NOW|RTLD_LOCAL);
- if(handle) return true;
- PRINTF(L_GEN_ERROR,"dload: %s: %s",base,dlerror());
+ if(handle) {
+ dlerror();
+ int *libapivers=(int *)dlsym(handle,"ScLibApiVersion");
+ const char *error=dlerror();
+ if(!error && *libapivers==SCAPIVERS) return true;
+ else PRINTF(L_GEN_ERROR,"dload: %s: SCAPI version doesn't match (plugin=%d, library=%d)",base,SCAPIVERS,!error?*libapivers:0);
+ }
+ else PRINTF(L_GEN_ERROR,"dload: %s: %s",base,dlerror());
}
return false;
}
cScDlls dlls;
#endif
cScHousekeeper *keeper;
+ bool dllSuccess;
public:
cScPlugin(void);
virtual ~cScPlugin();
LogOpts->Add(new cOptBool ("LogSyslog" ,trNOOP("Log to syslog") ,&logcfg.logSys));
LogOpts->Add(new cOptBool ("LogUserMsg" ,trNOOP("Show user messages") ,&logcfg.logUser));
#ifndef STATICBUILD
- dlls.Load();
+ dllSuccess=dlls.Load();
+#else
+ dllSuccess=true;
#endif
- cScDvbDevice::Capture();
+ if(dllSuccess) cScDvbDevice::Capture();
keeper=0;
}
bool cScPlugin::Initialize(void)
{
PRINTF(L_GEN_INFO,"SC version %s initializing",ScVersion);
- return cScDvbDevice::Initialize();
+ return dllSuccess && cScDvbDevice::Initialize();
}
bool cScPlugin::Start(void)
#include "misc.h"
#include "opts.h"
#include "log-core.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_NAME "Cardclient"
#define SYSTEM_PRI -15
#include "data.h"
#include "misc.h"
#include "log-sys.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_CONAX 0x0B00
#include "system-common.h"
#include "data.h"
#include "misc.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_NAME "ConstCW"
#define SYSTEM_PRI -20
#include "crypto.h"
#include "misc.h"
#include "log-sys.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_CRYPTOWORKS 0x0D00
#include "irdeto.h"
#include "log-irdeto.h"
+#include "version.h"
+
+SCAPIVERSTAG();
static const struct LogModule lm_sys = {
(LMOD_ENABLE|L_SYS_ALL)&LOPT_MASK,
#include "nagra-def.h"
#include "log-nagra.h"
#include "log-core.h"
+#include "version.h"
+
+SCAPIVERSTAG();
static const struct LogModule lm_sys = {
(LMOD_ENABLE|L_SYS_ALL)&LOPT_MASK,
#include "nds.h"
#include "log-nds.h"
+#include "version.h"
+
+SCAPIVERSTAG();
static const struct LogModule lm_sys = {
(LMOD_ENABLE|L_SYS_ALL)&LOPT_MASK,
#include "parse.h"
#include "misc.h"
#include "log-sc.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_CONAX 0x0B00
#include "misc.h"
#include "log-sc.h"
#include "log-core.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_NAME "SC-Cryptoworks"
#define SYSTEM_PRI -5
#include "parse.h"
#include "log-sc.h"
#include "log-core.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_NAME "SC-Irdeto"
#define SYSTEM_PRI -5
#include "helper.h"
#include "log-sc.h"
#include "log-core.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_NAGRA 0x1801
#include "opts.h"
#include "parse.h"
#include "log-sc.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_SECA 0x0100
#include "misc.h"
#include "log-sc.h"
#include "log-core.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_VIACCESS 0x0500
#include "helper.h"
#include "log-sc.h"
#include "log-core.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_VIDEOGUARD2 0x0900
#include "misc.h"
#include "log-sys.h"
#include "log-core.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_SECA 0x0100
#include "filter.h"
#include "misc.h"
#include "log-sys.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_SHL 0x4A60
#include "viaccess.h"
#include "tps.h"
#include "log-viaccess.h"
+#include "version.h"
+
+SCAPIVERSTAG();
#define SYSTEM_NAME "Viaccess"
#define SYSTEM_PRI -10
### Includes and Defines
-SCAPIVERS = $(shell sed -ne '/define SCAPIVERS/ s/^.[a-zA-Z ]*\([0-9]*\).*$$/\1/p' ../sc.c)
APIVERSION = $(shell sed -ne '/define APIVERSION/ s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
APIVERSNUM = $(shell sed -ne '/define APIVERSNUM/ s/^.[a-zA-Z ]*\([0-9]*\) .*$$/\1/p' $(VDRDIR)/include/vdr/config.h)
INCLUDES = -I.. -I$(VDRDIR)/include
-DEFINES = -DAPIVERSNUM=$(APIVERSNUM) -DAPIVERSION='"$(APIVERSION)"' -DSCAPIVERS=$(SCAPIVERS) -D_GNU_SOURCE
+DEFINES = -DAPIVERSNUM=$(APIVERSNUM) -DAPIVERSION='"$(APIVERSION)"' -D_GNU_SOURCE
OBJS = misc.o log.o override.o data.o crypto.o parse.o system.o system-common.o smartcard.o network.o filter.o version.o
SHAREDOBJS = compat.o $(VDRDIR)/tools.o $(VDRDIR)/thread.o
static bool DllLoad(const char *fileName)
{
const char *base=rindex(fileName,'/');
- if(!base) base=fileName;
+ if(base) base++; else base=fileName;
void *handle=dlopen(fileName,RTLD_NOW|RTLD_LOCAL);
- if(handle) return true;
- printf("dload: %s: %s\n",base,dlerror());
+ if(handle) {
+ dlerror();
+ int *libapivers=(int *)dlsym(handle,"ScLibApiVersion");
+ const char *error=dlerror();
+ if(!error && *libapivers==SCAPIVERS)
+ return true;
+ else printf("dload: %s: SCAPI version doesn't match (plugin=%d, library=%d)\n",base,SCAPIVERS,!error?*libapivers:0);
+ }
+ else printf("dload: %s: %s\n",base,dlerror());
return false;
}
struct dirent *e;
while((e=dir.Next())) {
if(!fnmatch(pat,e->d_name,FNM_PATHNAME|FNM_NOESCAPE)) {
- DllLoad(AddDirectory(libdir,e->d_name));
+ if(!DllLoad(AddDirectory(libdir,e->d_name))) res=false;
}
}
return res;
extern const char *ScVersion;
+// SC API version number for loading shared libraries
+#define SCAPIVERS 24
+#define SCAPIVERSTAG() int ScLibApiVersion=SCAPIVERS
+
#endif