premiereepg.c
branchtrunk
changeset 26 0953c008ab80
parent 25 f0ca0c236cfc
equal deleted inserted replaced
25:f0ca0c236cfc 26:0953c008ab80
    21  * along with this program; if not, write to the Free Software
    21  * along with this program; if not, write to the Free Software
    22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    23  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
    23  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
    24  */
    24  */
    25 
    25 
       
    26 #include <stdarg.h>
    26 #include <vdr/plugin.h>
    27 #include <vdr/plugin.h>
    27 #include <vdr/filter.h>
    28 #include <vdr/filter.h>
    28 #include <vdr/epg.h>
    29 #include <vdr/epg.h>
    29 #include <vdr/channels.h>
    30 #include <vdr/channels.h>
    30 #include <vdr/dvbdevice.h>
    31 #include <vdr/dvbdevice.h>
   134     crc^=*p++;
   135     crc^=*p++;
   135     for(int i=0; i<8; i++)
   136     for(int i=0; i<8; i++)
   136       crc=(crc&1) ? (crc>>1)^POLY : (crc>>1);
   137       crc=(crc&1) ? (crc>>1)^POLY : (crc>>1);
   137     }
   138     }
   138   return crc&0xFFFF;
   139   return crc&0xFFFF;
       
   140 }
       
   141 
       
   142 // --- cStrBuff ----------------------------------------------------------------
       
   143 
       
   144 class cStrBuff {
       
   145 private:
       
   146   char *buff;
       
   147   int size, pos;
       
   148 public:
       
   149   cStrBuff(int Size);
       
   150   ~cStrBuff();
       
   151   void Printf(const char *fmt, ...) __attribute__ ((format (printf,2,3)));
       
   152   char *Buff(void) { return (buff && pos>0) ? strdup(buff):0; }
       
   153   };
       
   154 
       
   155 cStrBuff::cStrBuff(int Size)
       
   156 {
       
   157   size=Size; pos=0;
       
   158   buff=MALLOC(char,size);
       
   159 }
       
   160 
       
   161 cStrBuff::~cStrBuff()
       
   162 {
       
   163   free(buff);
       
   164 }
       
   165 
       
   166 void cStrBuff::Printf(const char *fmt, ...)
       
   167 {
       
   168   int s=size-pos;
       
   169   if(buff && s>0) {
       
   170     va_list ap;
       
   171     va_start(ap,fmt);
       
   172     int q=vsnprintf(buff+pos,s,fmt,ap);
       
   173     va_end(ap);
       
   174     if(q>0) pos+=q;
       
   175     }
   139 }
   176 }
   140 
   177 
   141 // --- cFilterPremiereEpg ------------------------------------------------------
   178 // --- cFilterPremiereEpg ------------------------------------------------------
   142 
   179 
   143 #define STARTTIME_BIAS (20*60)
   180 #define STARTTIME_BIAS (20*60)
   281                   trNOOP("Price"),
   318                   trNOOP("Price"),
   282                   trNOOP("Ordering"),
   319                   trNOOP("Ordering"),
   283                   trNOOP("SMS"),
   320                   trNOOP("SMS"),
   284                   trNOOP("WWW")
   321                   trNOOP("WWW")
   285                   };
   322                   };
   286                 char buff[2048];
   323                 cStrBuff str(1024);
   287                 int p=0;
       
   288                 const unsigned char *data=d->getData().getData()+2;
   324                 const unsigned char *data=d->getData().getData()+2;
   289                 for(int i=0; i<5; i++) {
   325                 for(int i=0; i<5; i++) {
   290                   int l=data[0]; 
   326                   int l=data[0]; 
   291                   if(l>0) p+=snprintf(&buff[p],sizeof(buff)-p,"\n%s: %.*s",tr(text[i]),l,&data[1]);
   327                   if(l>0) str.Printf("\n%s: %.*s",tr(text[i]),l,&data[1]);
   292                   data+=l+1;
   328                   data+=l+1;
   293                   }
   329                   }
   294                 if(p>0) order=strdup(buff);
   330                 order=str.Buff();
   295                 }
   331                 }
   296               break;
   332               break;
   297             case 0xF1: // parental rating
   333             case 0xF1: // parental rating
   298               if(SetupPE.RatingInfo) {
   334               if(SetupPE.RatingInfo) {
   299                 char buff[2048];
   335                 cStrBuff str(1024);
   300                 int p=0;
       
   301                 const unsigned char *data=d->getData().getData()+2;
   336                 const unsigned char *data=d->getData().getData()+2;
   302                 p+=snprintf(&buff[p],sizeof(buff)-p,"\n%s: %d %s",tr("Rating"),data[0]+3,tr("years"));
   337                 str.Printf("\n%s: %d %s",tr("Rating"),data[0]+3,tr("years"));
   303                 data+=7;
   338                 data+=7;
   304                 int l=data[0]; 
   339                 int l=data[0]; 
   305                 if(l>0) p+=snprintf(&buff[p],sizeof(buff)-p," (%.*s)",l,&data[1]);
   340                 if(l>0) str.Printf(" (%.*s)",l,&data[1]);
   306                 if(p>0) rating=strdup(buff);
   341                 rating=str.Buff();
   307                 }
   342                 }
   308               break;
   343               break;
   309             case SI::PremiereContentTransmissionDescriptorTag:
   344             case SI::PremiereContentTransmissionDescriptorTag:
   310               if(nCount>=0) {
   345               if(nCount>=0) {
   311                 SI::PremiereContentTransmissionDescriptor *pct=(SI::PremiereContentTransmissionDescriptor *)d;
   346                 SI::PremiereContentTransmissionDescriptor *pct=(SI::PremiereContentTransmissionDescriptor *)d;