SASC
DVBSoftCAM

misc.h File Reference

#include <alloca.h>

Go to the source code of this file.

Classes

class  cLineBuff
class  cSimpleItem
class  cSimpleListBase
class  cSimpleList< T >

Defines

#define WORD(buffer, index, mask)   (((buffer[(index)]<<8) + buffer[(index)+1]) & mask)
#define SCT_LEN(sct)   (3+(((sct)[1]&0x0f)<<8)+(sct)[2])
#define MBC(a, b)   (((a)<<8)+(b))
#define ADDC3(ab, c)   ((ab)+((c)<<16))
#define MBC3(a, b, c)   ADDC3(MBC((a),(b)),(c))
#define C2(x)   (((x)>>8)&0xFF)
#define C3(x)   (((x)>>16)&0xFF)
#define C2MASK   0xFFFF
#define AUTOARRAY(type, size)   (type *)alloca(sizeof(type)*(size))
#define AUTOMEM(size)   (unsigned char *)alloca(size)
#define KeyStr(str, key)   HexStr(str,key,8)
#define Bin2Int(mem, len)   ((int)Bin2LongLong((mem),(len)))

Functions

const char * HexStr (char *str, const unsigned char *mem, int len)
void SetSctLen (unsigned char *data, int len)
int GetHex (const char *&line, unsigned char *store, int count, bool fixedLen=true)
int GetHexAsc (const char *&line, unsigned char *store, int count)
int GetChar (const char *&line, int *store, int count)
unsigned long long Bin2LongLong (unsigned char *mem, int len)
bool CheckNull (const unsigned char *data, int len)
bool CheckFF (const unsigned char *data, int len)
unsigned char XorSum (const unsigned char *mem, int len)
unsigned int crc32_le (unsigned int crc, unsigned char const *p, int len)
char * bprintf (const char *fmt,...) __attribute__((format(printf

Define Documentation

#define ADDC3 (   ab,
  c 
)    ((ab)+((c)<<16))
#define AUTOARRAY (   type,
  size 
)    (type *)alloca(sizeof(type)*(size))

Definition at line 38 of file misc.h.

Referenced by cRC6::SetKey(), cCaDescr::ToString(), and cEcmData::ToString().

#define C2 (   x)    (((x)>>8)&0xFF)

Definition at line 33 of file misc.h.

Referenced by cPlainKeySeca::Parse(), and cPlainKeyNagra::PrintKeyNr().

#define C2MASK   0xFFFF
#define C3 (   x)    (((x)>>16)&0xFF)

Definition at line 34 of file misc.h.

Referenced by cPlainKeyVia::PrintKeyNr(), and cPlainKeySeca::PrintKeyNr().

#define KeyStr (   str,
  key 
)    HexStr(str,key,8)

Definition at line 44 of file misc.h.

Referenced by cSystemIrd::ProcessEMM(), and cIrdCardInfos::Update().


Function Documentation

unsigned long long Bin2LongLong ( unsigned char *  mem,
int  len 
)

Definition at line 96 of file misc.c.

{
  unsigned long long k=0;
  for(int i=0 ; i<len ; i++) { k<<=8; k+=mem[i]; }
  return k;
}
char* bprintf ( const char *  fmt,
  ... 
)
bool CheckFF ( const unsigned char *  data,
int  len 
)

Definition at line 109 of file misc.c.

{
  while(--len>=0) if(data[len]!=0xFF) return false;
  return true;
}
bool CheckNull ( const unsigned char *  data,
int  len 
)

Definition at line 103 of file misc.c.

{
  while(--len>=0) if(data[len]) return false;
  return true;
}
unsigned int crc32_le ( unsigned int  crc,
unsigned char const *  p,
int  len 
)

Definition at line 146 of file misc.c.

{
  crc^=0xffffffff; // zlib mod
  while(len--) {
    crc^=*p++;
    for(int i=0; i<8; i++)
      crc=(crc&1) ? (crc>>1)^CRCPOLY_LE : (crc>>1);
    }
  crc^=0xffffffff; // zlib mod
  return crc;
}
int GetChar ( const char *&  line,
int *  store,
int  count 
)

Definition at line 44 of file misc.c.

{
  line=skipspace(line);
  const char *sline=line;
  *store=0;
  while(count) {
    if(line[0]==0 || !isalnum(line[0])) break;
    *store<<=8; *store+=line[0];
    line++; count--;
    }
  if(!count && (!*line || isspace(*line) || *line==';')) return sline-line;
  *store=0;
  line=sline;
  return 0;
}
int GetHex ( const char *&  line,
unsigned char *  store,
int  count,
bool  fixedLen = true 
)

Definition at line 86 of file misc.c.

{
  return GetHexBase(line,store,count,fixedLen,false);
}
int GetHexAsc ( const char *&  line,
unsigned char *  store,
int  count 
)

Definition at line 91 of file misc.c.

{
  return GetHexBase(line,store,count/2,true,true)*2;
}
const char* HexStr ( char *  str,
const unsigned char *  mem,
int  len 
)

Definition at line 32 of file misc.c.

{
  for(int i=0 ; i<len ; i++) sprintf(&str[i*2],"%02X",mem[i]);
  return str;
}
void SetSctLen ( unsigned char *  data,
int  len 
)

Definition at line 115 of file misc.c.

{
  data[1]=(len>>8) | 0x70;
  data[2]=len & 0xFF;
}
unsigned char XorSum ( const unsigned char *  mem,
int  len 
)

Definition at line 121 of file misc.c.

{
  unsigned char cs=0;
  while(len>0) { cs ^= *mem++; len--; }
  return cs;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines