}
}
-// -- cConfRead ----------------------------------------------------------------
-
-bool cConfRead::ConfRead(const char *type, const char *filename, bool missingok)
-{
- bool res=false;
- FILE *f=fopen(filename,"r");
- if(f) {
- res=true;
- PRINTF(L_GEN_INFO,"loading %s from %s",type,filename);
- char buff[1024];
- while(fgets(buff,sizeof(buff),f)) {
- if(!index(buff,'\n') && !feof(f))
- PRINTF(L_GEN_ERROR,"confread %s fgets readbuffer overflow",type);
- char *line=skipspace(stripspace(buff));
- if(line[0]==0 || line[0]==';' || line[0]=='#') continue; // skip empty & comment lines
- if(!ParseLine(line,false)) {
- PRINTF(L_GEN_ERROR,"file '%s' has error in line '%s'",filename,buff);
- res=false;
- }
- }
- fclose(f);
- }
- else if(!missingok) PRINTF(L_GEN_ERROR,"Failed to open file '%s': %s",filename,strerror(errno));
- return res;
-}
-
// -- cPid ---------------------------------------------------------------------
cPid::cPid(int Pid, int Section, int Mask, int Mode)
return cString::sprintf(hide ? "%c %.*X %s %.4s..." : "%c %.*X %s %s",type,IdSize(),id,*PrintKeyNr(),*Print());
}
-void cPlainKey::FormatError(const char *type, const char *sline)
-{
- PRINTF(L_GEN_WARN,"%s key: bad format '%.15s%s'\n",type,sline,(strlen(sline)>15)?"...":"");
-}
-
// -- cMutableKey --------------------------------------------------------------
cMutableKey::cMutableKey(bool Super)
// ----------------------------------------------------------------
-class cConfRead {
-public:
- virtual ~cConfRead() {}
- bool ConfRead(const char *type, const char *filename, bool missingok=false);
- virtual bool ParseLine(const char *line, bool fromCache)=0;
- };
-
-// ----------------------------------------------------------------
-
class cPid : public cSimpleItem {
public:
int pid, sct, mask, mode;
virtual int IdSize(void);
virtual cString Print(void)=0;
virtual cString PrintKeyNr(void);
- void FormatError(const char *type, const char *sline);
public:
int type, id, keynr;
//
cSmartCards::cSmartCards(void)
:cThread("SmartcardWatcher")
-,cStructList<cSmartCardData>("smartcard data",DATAFILE,SL_MISSINGOK|SL_WATCH)
+,cStructList<cSmartCardData>("smartcard data",DATAFILE,SL_MISSINGOK|SL_WATCH|SL_VERBOSE)
{
for(int i=0 ; i<MAX_PORTS ; i++) ports[i].Serial=0;
firstRun=true;
bool cPlainKeyStd::Parse(const char *line)
{
unsigned char sid[3], skeynr, skey[PLAINLEN_STD];
- const char *sline=line;
int len;
if(GetChar(line,&type,1) && (len=GetHex(line,sid,3,false)) &&
GetHex(line,&skeynr,1) && GetHex(line,skey,PLAINLEN_STD)) {
SetBinKey(skey,PLAINLEN_STD);
return true;
}
- FormatError("standard",sline);
return false;
}
bool cPlainKeyConax::Parse(const char *line)
{
unsigned char sid, skey[PLAINLEN_CONAX];
- const char *sline=line;
if(GetChar(line,&type,1) && GetHex(line,&sid,1) &&
GetChar(line,&keynr,1) && GetHex(line,skey,PLAINLEN_CONAX)) {
type=toupper(type); keynr=toupper(keynr); id=sid;
SetBinKey(skey,PLAINLEN_CONAX);
return true;
}
- FormatError("conax",sline);
return false;
}
bool cPlainKeyConstCw::Parse(const char *line)
{
unsigned char caid[2], skey[PLAINLEN_CW];
- const char *sline=line;
if(GetChar(line,&type,1) && GetHex(line,caid,2)) {
int num;
char srcBuf[16];
}
}
}
- FormatError("constcw",sline);
return false;
}
bool cPlainKeyCryptoworks::Parse(const char *line)
{
- const char *sline=line;
unsigned char sid[2], sprov;
if(GetChar(line,&type,1) && GetHex(line,sid,2) && GetHex(line,&sprov,1)) {
int keylen, prov;
}
}
}
- FormatError("cryptoworks",sline);
return false;
}
bool cPlainKeyNagra::Parse(const char *line)
{
unsigned char sid[2];
- const char *sline=line;
int len;
if(GetChar(line,&type,1) && (len=GetHex(line,sid,2,false))) {
type=toupper(type); id=Bin2Int(sid,len);
return true;
}
}
- FormatError("nagra",sline);
return false;
}
bool cPlainKeySeca::Parse(const char *line)
{
unsigned char sid[2];
- const char *sline=line;
int len;
if(GetChar(line,&type,1) && (len=GetHex(line,sid,2,false))) {
type=toupper(type); id=Bin2Int(sid,len);
}
}
}
- FormatError("seca",sline);
return false;
}
bool cPlainKeyVia::Parse(const char *line)
{
unsigned char sid[3], skeynr, skey[VIA2_KEYLEN];
- const char *sline=line;
int len;
if(GetChar(line,&type,1) && (len=GetHex(line,sid,3,false))) {
type=toupper(type); id=Bin2Int(sid,len);
return true;
}
}
- FormatError("viaccess",sline);
return false;
}