From a1da0e5c5de55009716e2c327dda16c61c1dae83 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 10 Feb 2002 18:00:00 +0100 Subject: =?UTF-8?q?Version=200.99=20-=20Fixed=20a=20bug=20in=20moving=20ti?= =?UTF-8?q?mers=20or=20channels=20to=20the=20last=20position=20in=20the=20?= =?UTF-8?q?list=20=20=20(thanks=20to=20Matthias=20Schniedermeyer=20for=20h?= =?UTF-8?q?elping=20to=20debug=20this=20one).=20-=20Changed=20the=20estima?= =?UTF-8?q?ted=20data=20rate=20for=20calculating=20the=20remaining=20disk?= =?UTF-8?q?=20capacity=20=20=20to=2025.75=20MB/min.=20-=20Only=20reporting?= =?UTF-8?q?=20the=20'EPG=20bugfix=20statistics'=20if=20there=20really=20we?= =?UTF-8?q?re=20any=20fixes.=20-=20Added=20Finnish=20language=20texts=20(t?= =?UTF-8?q?hanks=20to=20Hannu=20Savolainen).=20-=20Reverted=20to=20the=20p?= =?UTF-8?q?revious=20way=20of=20searching=20for=20the=20EPG=20record=20of?= =?UTF-8?q?=20the=20current=20=20=20recording=20in=20case=20of=20a=20perio?= =?UTF-8?q?dic=20timer=20(i.e.=20taking=20the=20one=20that=20is=20in=20the?= =?UTF-8?q?=20=20=20middle=20between=20start=20and=20end=20time).=20-=20Ad?= =?UTF-8?q?ded=20a=20typedef=20for=20'in=5Faddr=5Ft'=20to=20make=20it=20wo?= =?UTF-8?q?rk=20with=20glibc=20<=202.2=20(thanks=20to=20=20=20J=FCrgen=20S?= =?UTF-8?q?chmidt).=20-=20When=20the=20last=20entry=20in=20a=20"Recordings?= =?UTF-8?q?"=20menu=20page=20is=20deleted,=20that=20page=20is=20now=20=20?= =?UTF-8?q?=20automatically=20closed=20(suggested=20by=20Uwe=20Freese).=20?= =?UTF-8?q?-=20Changed=20the=20default=20name=20for=20instant=20recordings?= =?UTF-8?q?=20to=20"TITLE=20EPISODE"=20(avoiding=20=20=20the=20'-').=20-?= =?UTF-8?q?=20If=20Setup.ShowInfoOnChSwitch=20is=20set=20to=20"no",=20the?= =?UTF-8?q?=20box=20for=20the=20EPG=20display=20is=20no=20=20=20longer=20s?= =?UTF-8?q?hown=20(thanks=20to=20Andy=20Grobb).=20-=20If=20compiled=20with?= =?UTF-8?q?=20VFAT=3D1,=20characters=20that=20can't=20be=20handled=20by=20?= =?UTF-8?q?a=20VFAT=20system=20are=20=20=20now=20encoded=20to=20'#XX'.=20-?= =?UTF-8?q?=20When=20the=20user=20presses=20the=20"Power"=20button=20and?= =?UTF-8?q?=20there=20is=20a=20timer=20about=20to=20start=20=20=20recordin?= =?UTF-8?q?g=20within=20Setup.MinEventTimeout=20minutes,=20there=20is=20no?= =?UTF-8?q?w=20a=20confirmation=20=20=20prompt=20telling=20the=20user=20th?= =?UTF-8?q?at=20there=20is=20an=20upcoming=20timer=20event.=20-=20If=20a?= =?UTF-8?q?=20recording=20has=20no=20episode=20title,=20the=20trailing=20'?= =?UTF-8?q?~'=20is=20no=20longer=20shown=20in=20=20=20the=20progress=20dis?= =?UTF-8?q?play.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recording.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 9 deletions(-) (limited to 'recording.c') diff --git a/recording.c b/recording.c index 7a55e1a..d822887 100644 --- a/recording.c +++ b/recording.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.c 1.49 2002/02/03 15:46:42 kls Exp $ + * $Id: recording.c 1.51 2002/02/10 15:41:23 kls Exp $ */ #include "recording.h" @@ -196,22 +196,82 @@ tCharExchange CharExchange[] = { { ' ', '_' }, { '\'', '\x01' }, { '/', '\x02' }, -#ifdef VFAT - { ':', '\x03' }, -#endif { 0, 0 } }; -char *ExchangeChars(char *s, bool ToFileSystem) +static char *ExchangeChars(char *s, bool ToFileSystem) { char *p = s; while (*p) { +#define VFAT 1 +#ifdef VFAT + // The VFAT file system can't handle all characters, so we + // have to take extra efforts to encode/decode them: + if (ToFileSystem) { + switch (*p) { + // characters that can be used "as is": + case '!': + case '@': + case '$': + case '%': + case '&': + case '(': + case ')': + case '+': + case ',': + case '-': + case '.': + case ';': + case '=': + case '0' ... '9': + case 'a' ... 'z': + case 'A' ... 'Z': break; + // characters that can be mapped to other characters: + case ' ': *p = '_'; break; + case '~': *p = '/'; break; + // characters that have to be encoded: + default: { + int l = p - s; + s = (char *)realloc(s, strlen(s) + 10); + p = s + l; + char buf[4]; + sprintf(buf, "#%02X", (unsigned char)*p); + memmove(p + 2, p, strlen(p) + 1); + strncpy(p, buf, 3); + p += 2; + } + } + } + else { + switch (*p) { + // mapped characters: + case '_': *p = ' '; break; + case '/': *p = '~'; break; + // encodes characters: + case '#': { + if (strlen(p) > 2) { + char buf[3]; + sprintf(buf, "%c%c", *(p + 1), *(p + 2)); + unsigned char c = strtol(buf, NULL, 16); + *p = c; + memmove(p + 1, p + 3, strlen(p) - 2); + } + } + break; + // backwards compatibility: + case '\x01': *p = '\''; break; + case '\x02': *p = '/'; break; + case '\x03': *p = ':'; break; + } + } +#else for (struct tCharExchange *ce = CharExchange; ce->a && ce->b; ce++) { if (*p == (ToFileSystem ? ce->a : ce->b)) { *p = ToFileSystem ? ce->b : ce->a; break; } } +#endif p++; } return s; @@ -285,7 +345,7 @@ cRecording::cRecording(const char *FileName) name = new char[p - FileName + 1]; strncpy(name, FileName, p - FileName); name[p - FileName] = 0; - ExchangeChars(name, false); + name = ExchangeChars(name, false); } // read an optional summary file: char *SummaryFileName = NULL; @@ -384,9 +444,9 @@ const char *cRecording::FileName(void) if (!fileName) { struct tm tm_r; struct tm *t = localtime_r(&start, &tm_r); - ExchangeChars(name, true); + name = ExchangeChars(name, true); asprintf(&fileName, NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime); - ExchangeChars(name, false); + name = ExchangeChars(name, false); } return fileName; } @@ -399,7 +459,7 @@ const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level) if (Level < 0 || Level == HierarchyLevels()) { struct tm tm_r; struct tm *t = localtime_r(&start, &tm_r); - const char *s; + char *s; if (Level > 0 && (s = strrchr(name, '~')) != NULL) s++; else @@ -413,6 +473,11 @@ const char *cRecording::Title(char Delimiter, bool NewIndicator, int Level) New, Delimiter, s); + // let's not display a trailing '~': + stripspace(titleBuffer); + s = &titleBuffer[strlen(titleBuffer) - 1]; + if (*s == '~') + *s = 0; } else if (Level < HierarchyLevels()) { const char *s = name; -- cgit v1.2.3