/************************************************************************* * Copyright 2009 Ralph Spitzner (rasp@spitzner.org) * * This file is part of Yahdr. * * Yahdr is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Yahdr is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Yahdr. If not, see . **************************************************************************/ #include "defs.hpp" #include "rconf.h" CHANNEL *readchans(char *filename) { struct ConfigFile::confval *cp,*cp2,*cp3; ConfigFile *cfile; CHANNEL *fchan,*chanp,*jp; APID *apidp; char *p; uint32_t freq,tsid; fe_modulation_t qam; uint8_t bw; cfile = new ConfigFile(filename); if (!(cp = cfile->findkey((char *)"transponder",cfile->first))) { cout << "no transponder in channels file ?!" << endl; return NULL; } fchan = chanp = new CHANNEL; //chanp->apid = fapid = apidp = new APID; memset(fchan,0,sizeof(CHANNEL)); // memset(fapid,0,sizeof(APID)); do { cp2 = cfile->findkey((char*)"freq",cp->leaf); freq = atoi(cp2->value); cp2 = cfile->findkey((char *)"bw",cp2); bw = atoi(cp2->value); cp2 = cfile->findkey((char *)"tsid",cp2); tsid = atoi(cp2->value); cp2 = cfile->findkey((char *)"QAM",cp2); qam = (fe_modulation_t)atoi(cp2->value); cp2 = cfile->findkey((char *)"program",cp2); while (cp2) { chanp->freq = freq; chanp->tsid = tsid; chanp->qam = qam; chanp->bw = bw; cp3 = cfile->findkey((char *)"service_id",cp2->leaf); chanp->pnum = atoi(cp3->value); cp3 = cfile->findkey((char *)"internal_channel",cp2->leaf); chanp->channum = atoi(cp3->value); cp3 = cfile->findkey((char *)"service-type",cp2->leaf); chanp->stype = new string; chanp->stype->assign(cp3->value); cp3 = cfile->findkey((char *)"EIT-sched",cp2->leaf); chanp->epg_sched = atoi(cp3->value); cp3 = cfile->findkey((char *)"EIT-pf",cp2->leaf); chanp->epg_pf = atoi(cp3->value); cp3 = cfile->findkey((char *)"providername",cp2->leaf); chanp->provider = new string; chanp->provider->assign(cp3->value); cp3 = cfile->findkey((char *)"servicename",cp2->leaf); chanp->name = new string; chanp->name->assign(cp3->value); cp3 = cfile->findkey((char *)"pid",cp2->leaf); do { if ((p = strtok(cp3->value,","))) { char *num,*type,*lang; num = p; type = strtok(NULL,","); lang = strtok(NULL,","); if (num == NULL || lang == NULL || type == NULL) break; if (!strncmp(type,"VIDEO",5)) chanp->vpid = atoi(num); else if (!strncmp(type,"AUDIO",5)) { if (!chanp->apid) { chanp->apid = new APID [0]; apidp = chanp->apid; } else { apidp = chanp->apid; while (apidp->next) apidp = apidp->next; apidp->next = new APID[0]; apidp = apidp->next; } apidp->apid = atoi(num); if(strcmp(lang,"NONE")) strncpy(apidp->lang,lang,3); } } cp3 = cp3->next; }while ((cp3 = cfile->findkey((char *)"pid",cp3))); cp2 = cp2->next; cp2 = cfile->findkey((char *)"program",cp2); chanp->next = new CHANNEL[0]; chanp->next->apid = NULL; chanp->next->next = NULL; chanp = chanp->next; } }while((cp = cp->next)); ///cp = cfile->findkey((char *)"transponder",cp))); jp = fchan; while(jp->next != chanp) jp = jp->next; jp->next = NULL; return fchan; }