{
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)
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)";
}
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('/');
continue;
}
}
+ free(line);
fclose(fp);
eDebug("%d entries in Bouquet %s", entries, bouquet_name.c_str());
}