p+=path;
eDebug("loading bouquet... %s", p.c_str());
FILE *fp=fopen(p.c_str(), "rt");
- int entries=0;
if (!fp)
{
eDebug("can't open %s: %m", p.c_str());
- if ( strstr(path, "bouquets.tv") )
+ 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());
}