summaryrefslogtreecommitdiff
path: root/eepg.c
diff options
context:
space:
mode:
authorDimitar Petrovski <dimeptr@gmail.com>2013-01-31 13:51:27 (GMT)
committerDimitar Petrovski <dimeptr@gmail.com>2013-01-31 13:51:27 (GMT)
commitc9a302eff85ad0d6c337743b7373b4ee0c7bded3 (patch)
tree224215e7bf23e834563c8e3495fc6b7f8071e802 /eepg.c
parent2eb5f7d939dd8dbcb560d03bf608e341924b0c2b (diff)
downloadvdr-plugin-eepg-c9a302eff85ad0d6c337743b7373b4ee0c7bded3.tar.gz
vdr-plugin-eepg-c9a302eff85ad0d6c337743b7373b4ee0c7bded3.tar.bz2
Update the sky_*.themes file if a theme is added in the source
Count only nonempty themes as found themes for sky
Diffstat (limited to 'eepg.c')
-rw-r--r--eepg.c57
1 files changed, 43 insertions, 14 deletions
diff --git a/eepg.c b/eepg.c
index 7a7272c..ea5fd8c 100644
--- a/eepg.c
+++ b/eepg.c
@@ -745,10 +745,16 @@ bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB
FILE *FileThemes;
char *Line;
char Buffer[256];
- if (Format == SKY_IT)
+ const char **SkyThemes;
+ bool updateFile = false;
+ if (Format == SKY_IT) {
FileName += "/sky_it.themes";
- else if (Format == SKY_UK)
+ SkyThemes = SkyItThemes;
+ }
+ else if (Format == SKY_UK) {
FileName += "/sky_uk.themes";
+ SkyThemes = SkyUkThemes;
+ }
else {
LogE (0, prep("Error, wrong format detected in GetThemesSKYBOX. Format = %i."), Format);
return false;
@@ -759,26 +765,49 @@ bool cFilterEEPG::GetThemesSKYBOX (void) //TODO can't we read this from the DVB
LogE (0, prep("Error opening file '%s'. %s"), FileName.c_str(), strerror (errno));
return false;
} else {
- //int id = 0;
+ int id = 0;
nThemes = 0;
- char string1[256];
- char string2[256];
- //sTheme *T;
+ char thId[256];
+ char theme[256];
+
while ((Line = fgets (Buffer, sizeof (Buffer), FileThemes)) != NULL) {
- memset (string1, 0, sizeof (string1));
- memset (string2, 0, sizeof (string2));
+ memset (thId, 0, sizeof (thId));
+ memset (theme, 0, sizeof (theme));
if (!isempty (Line)) {
- //T = &Themes[nThemes];
- if (sscanf (Line, "%[^=] =%[^\n] ", string1, string2) == 2) {
- snprintf ((char *) Themes[nThemes], 255, "%s", string2);
+ if (sscanf (Line, "%[^=] =%[^\n] ", thId, theme) == 2 && !isempty (theme)) {
+ snprintf ((char *) Themes[id], 255, "%s", theme);
+ nThemes++;
} else {
- Themes[nThemes][0] = '\0';
+ if (SkyThemes[id]) {
+ updateFile = true;
+ snprintf ((char *) Themes[id], 255, "%s", SkyThemes[id]);
+ LogD (1, prep("Theme '%s' missing in theme file '%s'"), SkyThemes[id], FileName.c_str());
+ } else
+ Themes[id][0] = '\0';
}
- //id ++;
- nThemes++;
+ id ++;
}
}
fclose (FileThemes);
+
+ if (updateFile) {
+ FileThemes = fopen (FileName.c_str(), "w");
+ if (FileThemes == NULL) {
+ LogE (0, prep("Error re-creating file '%s', %s"), FileName.c_str(), strerror (errno));
+ } else {
+ for (int i = 0; i < 256; i++) {
+ if (Themes[nThemes]) {
+ fprintf (FileThemes, "0x%02x=%s\n", i, (char *) Themes[nThemes]);
+ }
+ else {
+ fprintf (FileThemes, "0x%02x=\n", i);
+ }
+ }
+
+ LogI (0, prep("Success updating file '%s'"), FileName.c_str());
+ fclose (FileThemes);
+ }
+ }
}
return true;
}