SASC
DVBSoftCAM

compat.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <dlfcn.h>
#include <dirent.h>
#include <fnmatch.h>
#include "data.h"
#include "sc.h"
#include "scsetup.h"
#include "opts.h"
#include "misc.h"
#include "system.h"
#include "smartcard.h"
#include "cam.h"
#include "log-core.h"
#include "version.h"
#include <vdr/sources.h>
#include <vdr/channels.h>

Go to the source code of this file.

Classes

class  cOptCap

Defines

#define LIBSC_PREFIX   "libsc-"
#define SO_INDICATOR   ".so."

Functions

static bool DllLoad (const char *fileName)
bool DllsLoad (const char *libdir)
void InitAll (const char *cfgdir)
void LogAll (void)
void LogNone (void)
void SDump (const unsigned char *buffer, int n)
int ReadRaw (const char *name, unsigned char *buff, int maxlen)
const char * I18nTranslate (const char *s, const char *Plugin)
int GetCaDescriptors (int Source, int Transponder, int ServiceId, const int *CaSystemIds, int BufSize, uchar *Data, bool &StreamFlag)

Variables

static struct LogModule lm_core
cScSetup ScSetup

Define Documentation

#define LIBSC_PREFIX   "libsc-"

Definition at line 20 of file compat.c.

Referenced by DllsLoad().

#define SO_INDICATOR   ".so."

Definition at line 21 of file compat.c.

Referenced by DllsLoad().


Function Documentation

static bool DllLoad ( const char *  fileName) [static]

Definition at line 23 of file compat.c.

References dlerror(), dlopen(), dlsym(), and SCAPIVERS.

Referenced by DllsLoad().

{
  const char *base=rindex(fileName,'/');
  if(base) base++; else base=fileName;
  void *handle=dlopen(fileName,RTLD_NOW|RTLD_LOCAL);
  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;
}
bool DllsLoad ( const char *  libdir)

Definition at line 40 of file compat.c.

References AddDirectory(), APIVERSION, DllLoad(), LIBSC_PREFIX, cReadDir::Next(), SCAPIVERS, and SO_INDICATOR.

{
  char pat[32];
  snprintf(pat,sizeof(pat),"%s*-%d%s%s",LIBSC_PREFIX,SCAPIVERS,SO_INDICATOR,APIVERSION);
  bool res=true;
  cReadDir dir(libdir);
  struct dirent *e;
  while((e=dir.Next())) {
    if(!fnmatch(pat,e->d_name,FNM_PATHNAME|FNM_NOESCAPE)) {
      if(!DllLoad(AddDirectory(libdir,e->d_name))) res=false;
      }
    }
  return res;
}
int GetCaDescriptors ( int  Source,
int  Transponder,
int  ServiceId,
const int *  CaSystemIds,
int  BufSize,
uchar *  Data,
bool &  StreamFlag 
)

Gets all CA descriptors for a given channel. Copies all available CA descriptors for the given Source, Transponder and ServiceId into the provided buffer at Data (at most BufSize bytes). Only those CA descriptors are copied that match one of the given CA system IDs.

Returns:
Returns the number of bytes copied into Data (0 if no CA descriptors are available), or -1 if BufSize was too small to hold all CA descriptors. The return value in StreamFlag tells whether these CA descriptors are to be used for the individual streams.

Definition at line 494 of file compat.c.

{
  return 0;
}
const char* I18nTranslate ( const char *  s,
const char *  Plugin 
)

Definition at line 132 of file compat.c.

{
  return s;
}
void LogAll ( void  )

Definition at line 73 of file compat.c.

References i, LCLASS, and cLogging::SetModuleOptions().

{
  for(int i=0; i<32; i++)
    cLogging::SetModuleOptions(LCLASS(i,0xFFFFFFFF));
}
void LogNone ( void  )

Definition at line 79 of file compat.c.

References i, LCLASS, and cLogging::SetModuleOptions().

{
  for(int i=0; i<32; i++)
    cLogging::SetModuleOptions(LCLASS(i,0));
}
int ReadRaw ( const char *  name,
unsigned char *  buff,
int  maxlen 
)

Definition at line 91 of file compat.c.

{
  FILE *f=fopen(name,"r");
  if(f) {
    char line[512];
    int len=0;
    while(len<maxlen && fgets(line,sizeof(line),f)) {
      if(strstr(line,"dump: n=")) continue;
      char *p=index(line,'#');
      if(p) *p=0;
      p=index(line,'[');
      if(p) {
        p=index(p,']');
        if(p) {
          strcpy(line,p+1);
          }
        }
      p=index(line,':');
      if(p) p++; else p=line;
      while(1) {
        char *np;
        int val=strtol(p,&np,16);
        if(p!=np) {
          buff[len++]=val;
          p=np;
          }
        else break;
        }
      }
    fclose(f);
//    printf("using raw from %s:\n",name);
//    HexDump(buff,len);
    return len;
    }
  printf("failed to open raw file %s: %s\n",name,strerror(errno));
  exit(1);
}
void SDump ( const unsigned char *  buffer,
int  n 
)

Definition at line 85 of file compat.c.

{
  for(int l=0 ; l<n ; l++) printf("%02x ",buffer[l]);
  printf("\n");
}

Variable Documentation

struct LogModule lm_core [static]
Initial value:
 {
  (LMOD_ENABLE|L_CORE_ALL)&LOPT_MASK,
  (LMOD_ENABLE|L_CORE_LOAD|L_CORE_ECM|L_CORE_PIDS|L_CORE_AU|L_CORE_AUSTATS|L_CORE_CAIDS|L_CORE_NET|L_CORE_CI|L_CORE_SC|L_CORE_HOOK|L_CORE_OVER)&LOPT_MASK,
  "core",
  { "load","action","ecm","ecmProc","pids","au","auStats","auExtra","auExtern",
    "caids","keys","dynamic","csa","ci","av7110","net","netData","msgcache",
    "serial","smartcard","hook","ciFull","csaVerb","override" }
  }

Definition at line 140 of file compat.c.

Definition at line 153 of file compat.c.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines