X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fdvb%2Fdb.cpp;h=ea0df97f6d68337eee0fd751364a5f8e123eebfe;hp=522035eb7585b751c0f22bf6ac117ea0bdc03ed9;hb=2d3c6126e0c8e2949d9a918ba8f2005d2ee28150;hpb=27b36b78b0e7018a1e40b8943ebc2b1d021bfaa0 diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp old mode 100644 new mode 100755 index 522035e..ea0df97 --- a/lib/dvb/db.cpp +++ b/lib/dvb/db.cpp @@ -325,19 +325,11 @@ void eDVBDB::loadServicelist(const char *file) { eDebug("---- opening lame channel db"); FILE *f=fopen(file, "rt"); - if (!f && strcmp(file, eEnv::resolve("${sysconfdir}/enigma2/lamedb").c_str()) == 0) - { - struct stat s; - if ( !stat("lamedb", &s) ) - { - if ( !stat(eEnv::resolve("${sysconfdir}/enigma2").c_str(), &s) ) - { - rename("lamedb", eEnv::resolve("${sysconfdir}/enigma2/lamedb").c_str()); - reloadServicelist(); - } - } + if (!f) { + eDebug("can't open %s: %m", file); return; } + char line[256]; int version=3; if ((!fgets(line, 256, f)) || sscanf(line, "eDVB services /%d/", &version) != 1) @@ -623,24 +615,16 @@ void eDVBDB::loadBouquet(const char *path) p+=path; eDebug("loading bouquet... %s", p.c_str()); FILE *fp=fopen(p.c_str(), "rt"); - int entries=0; if (!fp) { - struct stat s; - if ( !stat(path, &s) ) - { - rename(path, p.c_str() ); - loadBouquet(path); - return; - } - eDebug("failed to open."); - if ( strstr(path, "bouquets.tv") ) + eDebug("can't open %s: %m", p.c_str()); + if (!strcmp(path, "bouquets.tv")) { eDebug("recreate bouquets.tv"); bouquet.m_bouquet_name="Bouquets (TV)"; bouquet.flushChanges(); } - else if ( strstr(path, "bouquets.radio") ) + else if (!strcmp(path, "bouquets.radio")) { eDebug("recreate bouquets.radio"); bouquet.m_bouquet_name="Bouquets (Radio)"; @@ -648,29 +632,25 @@ void eDVBDB::loadBouquet(const char *path) } return; } - char line[256]; + int entries=0; + size_t linesize = 256; + char *line = (char*)malloc(linesize); bool read_descr=false; eServiceReference *e = NULL; while (1) { - if (!fgets(line, 256, fp)) - break; - line[strlen(line)-1]=0; - if (strlen(line) && line[strlen(line)-1]=='\r') - line[strlen(line)-1]=0; - if (!line[0]) - break; + int len; + if ((len = getline(&line, &linesize, fp)) < 2) break; + /* strip newline */ + line[--len] = 0; + /* strip carriage return (when found) */ + if (line[len - 1] == '\r') line[--len] = 0; if (line[0]=='#') { if (!strncmp(line, "#SERVICE", 8)) { int offs = line[8] == ':' ? 10 : 9; eServiceReference tmp(line+offs); - if (tmp.type != eServiceReference::idDVB) - { - eDebug("only DVB Bouquets supported"); - continue; - } if ( tmp.flags&eServiceReference::canDescent ) { size_t pos = tmp.path.rfind('/'); @@ -720,6 +700,7 @@ void eDVBDB::loadBouquet(const char *path) continue; } } + free(line); fclose(fp); eDebug("%d entries in Bouquet %s", entries, bouquet_name.c_str()); }