]> www.vanbest.org Git - sasc-ng.git/commitdiff
switch smartcard.conf to new loader code
authormirv <unknown>
Fri, 4 Jan 2008 18:06:45 +0000 (19:06 +0100)
committermirv <unknown>
Fri, 4 Jan 2008 18:06:45 +0000 (19:06 +0100)
cam.c
data.c
data.h
sc.c
smartcard.c
smartcard.h
system.c
systems/irdeto/irdeto.c
systems/seca/seca.c
systems/viaccess/viaccess.c

diff --git a/cam.c b/cam.c
index a4002008d77562b729e7f9b9c3b47bf1b6b56f0c..4030e72d07949383c3dd34c0d20ef2519ecedec5 100644 (file)
--- a/cam.c
+++ b/cam.c
@@ -575,7 +575,7 @@ class cEcmData : public cEcmInfo {
 public:
   cEcmData(void):cEcmInfo() {}
   cEcmData(cEcmInfo *e):cEcmInfo(e) {}
-  virtual cString ToString(bool hide=false);
+  virtual cString ToString(bool hide);
   bool Parse(const char *buf);
   };
 
diff --git a/data.c b/data.c
index 86c6c15e569da3a9e0c01f1165c8cc8858b22c43..7427078449bc0b77d2402cf191363d6ac8ca5227 100644 (file)
--- a/data.c
+++ b/data.c
@@ -169,7 +169,6 @@ bool cStructItem::Save(FILE *f)
 class cCommentItem : public cStructItem {
 public:
   cCommentItem(void);
-  virtual cString ToString(bool hide=false) { return ""; }
   };
 
 cCommentItem::cCommentItem(void)
diff --git a/data.h b/data.h
index 26ba4b6926fc6633d1442171145251b91540aaf5..1e7a879e4ba937ba41c39b90773d1a9a41d97b4b 100644 (file)
--- a/data.h
+++ b/data.h
@@ -78,7 +78,7 @@ protected:
 public:
   cStructItem(void);
   virtual ~cStructItem();
-  virtual cString ToString(bool hide=false)=0;
+  virtual cString ToString(bool hide) { return ""; }
   bool Save(FILE *f);
   //
   void SetComment(const char *com);
@@ -272,7 +272,7 @@ public:
   //
   cPlainKey(bool CanSupersede);
   virtual bool Parse(const char *line)=0;
-  virtual cString ToString(bool hide=false);
+  virtual cString ToString(bool hide);
   virtual bool Cmp(void *Key, int Keylen)=0;
   virtual bool Cmp(cPlainKey *k)=0;
   virtual void Get(void *mem)=0;
diff --git a/sc.c b/sc.c
index 001fae5531bfbb0f21eced6a33e24a1c29cf7a7c..4fe29012faf1723a7a5f6820f8a34cbbac33347d 100644 (file)
--- a/sc.c
+++ b/sc.c
@@ -1006,12 +1006,11 @@ bool cScSetup::Ignore(unsigned short caid)
 bool cSoftCAM::Load(const char *cfgdir)
 {
   if(!Feature.KeyFile()) keys.Disable();
+  if(!Feature.SmartCard()) smartcards.Disable();
   cStructLoaders::Load(false);
   if(Feature.KeyFile() && keys.Count()<1)
     PRINTF(L_GEN_ERROR,"no keys loaded for softcam!");
-
   if(!cSystems::Init(cfgdir)) return false;
-  if(Feature.SmartCard()) smartcards.LoadData(cfgdir);
   return true;
 }
 
index 50d43a34392858daa8415470283f66433932e18c..14cd9be24ed360c12ba960c4849ee2e2ee73e0b2 100644 (file)
@@ -1107,6 +1107,7 @@ static const char *serModes[] = { 0,"8e2","8o2","8n2" };
 
 cSmartCards::cSmartCards(void)
 :cThread("SmartcardWatcher")
+,cStructList<cSmartCardData>("smartcard data",DATAFILE,SL_MISSINGOK|SL_WATCH)
 {
   for(int i=0 ; i<MAX_PORTS ; i++) ports[i].Serial=0;
   firstRun=true;
@@ -1138,8 +1139,8 @@ void cSmartCards::Shutdown(void)
       ports[i].Serial=0;
       }
     }
-  dataList.Clear();
   mutex.Unlock();
+  ListLock(true); Clear(); ListUnlock();
 }
 
 bool cSmartCards::AddPort(const char *devName, bool invCD, bool invRST, int clock)
@@ -1173,41 +1174,28 @@ bool cSmartCards::AddPort(const char *devName, bool invCD, bool invRST, int cloc
   return false;
 }
 
-void cSmartCards::LoadData(const char *cfgdir)
-{
-  mutex.Lock();
-  dataList.Clear();
-  ConfRead("smartcard data",AddDirectory(cfgdir,DATAFILE),true);
-  mutex.Unlock();
-}
-
-bool cSmartCards::ParseLine(const char *line, bool fromCache)
+cStructItem *cSmartCards::ParseLine(char *line)
 {
   char *r=index(line,':');
-  if(!r) return false;
-  for(cSmartCardLink *scl=first; scl; scl=scl->next) {
-    if(!strncasecmp(scl->name,line,r-line)) {
-      cSmartCardData *scd=scl->CreateData();
-      if(scd && scd->Parse(r+1)) {
-        dataList.Add(scd);
-        break;
-        }
-      else {
+  if(r)
+    for(cSmartCardLink *scl=first; scl; scl=scl->next)
+      if(!strncasecmp(scl->name,line,r-line)) {
+        cSmartCardData *scd=scl->CreateData();
+        if(scd && scd->Parse(r+1)) return scd;
         delete scd;
-        return false;
+        break;
         }
-      }
-    }
-  return true;
+  return 0;
 }
 
 cSmartCardData *cSmartCards::FindCardData(cSmartCardData *param)
 {
-  cMutexLock lock(&mutex);
-  for(cSmartCardData *cd=dataList.First(); cd; cd=dataList.Next(cd))
-    if(cd->ident==param->ident && cd->Matches(param))
-      return cd;
-  return 0;
+  ListLock(false);
+  cSmartCardData *cd;
+  for(cd=First(); cd; cd=Next(cd))
+    if(cd->ident==param->ident && cd->Matches(param)) break;
+  ListUnlock();
+  return cd;
 }
 
 bool cSmartCards::HaveCard(int id)
index 5c87de3d6e30af77a819c644f751e8c5521dd426..184cef45c6b7f2f459819106eb398b7c27ce5103 100644 (file)
@@ -155,7 +155,7 @@ public:
 
 // ----------------------------------------------------------------
 
-class cSmartCardData : public cSimpleItem {
+class cSmartCardData : public cStructItem {
 friend class cSmartCards;
 protected:
   int ident;
@@ -194,7 +194,7 @@ struct Port {
   struct Atr Atr;
   };
 
-class cSmartCards : private cThread, private cConfRead {
+class cSmartCards : private cThread, public cStructList<cSmartCardData> {
 friend class cSmartCardLink;
 private:
   static cSmartCardLink *first;
@@ -202,7 +202,6 @@ private:
   cCondVar cond;
   struct Port ports[MAX_PORTS];
   bool firstRun;
-  cSimpleList<cSmartCardData> dataList;
   //
   static void Register(cSmartCardLink *scl);
   bool CardInserted(cSerial *ser);
@@ -212,7 +211,7 @@ private:
   void SetPort(struct Port *port, cSmartCard *sc, int id, bool dead);
 protected:
   virtual void Action(void);
-  virtual bool ParseLine(const char *line, bool fromCache);
+  virtual cStructItem *ParseLine(char *line);
 public:
   cSmartCards(void);
   void Shutdown(void);
@@ -224,7 +223,6 @@ public:
   // to be called ONLY from frontend thread!
   bool AddPort(const char *devName, bool invCD, bool invRST, int clock);
   void LaunchWatcher(void);
-  void LoadData(const char *cfgdir);
   bool ListCard(int num, char *str, int len);
   bool CardInfo(int num, char *str, int len);
   void CardReset(int num);
index 920217ccea19d60fe71b97bf201421848e6f9c39..36e83c63a3d46556e9aefae58a4f4fdc4451f98d 100644 (file)
--- a/system.c
+++ b/system.c
@@ -239,7 +239,7 @@ void cSystem::CheckECMResult(const cEcmInfo *ecm, const unsigned char *data, boo
 void cSystem::KeyOK(cPlainKey *pk)
 {
   if(lastkey.NotLast(pk->type,pk->id,pk->keynr)) {
-    strn0cpy(currentKeyStr,pk->ToString(),sizeof(currentKeyStr));
+    strn0cpy(currentKeyStr,pk->ToString(false),sizeof(currentKeyStr));
     PRINTF(L_CORE_ECM,"system: using key %s",*pk->ToString(true));
     doLog=true;
     }
index 543ccecc1da76a4880623d5d146cd3a4f23f04c5..9414976593fcc9b38e43403c2494dc2ae76fb45e 100644 (file)
@@ -54,7 +54,7 @@ public:
   bool haveHMK;
   //
   bool Parse(const char *line);
-  virtual cString ToString(bool hide=false);
+  virtual cString ToString(bool hide);
   };
 
 bool cIrdCardInfo::Parse(const char *line)
index afd5e55270ebdeb98734e434a0ddd951dd65f9c8..b91650d1bd01bc0771ae38c7c4cfe37caf124726 100644 (file)
@@ -174,7 +174,6 @@ public:
   unsigned char key[16];
   //
   bool Parse(const char *line);
-  virtual cString ToString(bool hide=false) { return ""; }
   int KeySize(void) { return len; }
   };
 
index cd7a3166a95e76b53d07b799c799a75b3a7ebbc9..d083894d24579a1a1a7ffb1faada09665ec9e8c9 100644 (file)
@@ -130,7 +130,6 @@ public:
   unsigned char keyno, key[8];
   //
   bool Parse(const char *line);
-  virtual cString ToString(bool hide=false) { return ""; }
   };
 
 bool cViaccessCardInfo::Parse(const char *line)