Fixed channel parameter corruption.

This commit is contained in:
Rolf Ahrenberg 2010-03-08 21:12:06 +02:00
parent 1a825f5636
commit d8585ba0fc
3 changed files with 70 additions and 52 deletions

View File

@ -132,3 +132,7 @@ VDR Plugin 'iptv' Revision History
- Updated for vdr-1.7.13. - Updated for vdr-1.7.13.
- Fixed argument corruption. - Fixed argument corruption.
2010-03-08: Version 0.4.1
- Fixed channel parameter corruption.

2
iptv.c
View File

@ -16,7 +16,7 @@
#error "VDR-1.7.13 API version or greater is required!" #error "VDR-1.7.13 API version or greater is required!"
#endif #endif
static const char VERSION[] = "0.4.0"; static const char VERSION[] = "0.4.1";
static const char DESCRIPTION[] = trNOOP("Experience the IPTV"); static const char DESCRIPTION[] = trNOOP("Experience the IPTV");
class cPluginIptv : public cPlugin { class cPluginIptv : public cPlugin {

116
source.c
View File

@ -49,63 +49,77 @@ cString cIptvTransponderParameters::ToString(char Type) const
bool cIptvTransponderParameters::Parse(const char *s) bool cIptvTransponderParameters::Parse(const char *s)
{ {
debug("cIptvTransponderParameters::Parse(): s=%s\n", s); debug("cIptvTransponderParameters::Parse(): s=%s\n", s);
bool result = false;
const char *delim = "|"; if (s && *s) {
char *str = (char *)s; const char *delim = "|";
char *saveptr = NULL; char *str = strdup(s);
char *token = NULL; char *saveptr = NULL;
bool found_s = false; char *token = NULL;
bool found_p = false; bool found_s = false;
bool found_f = true; bool found_p = false;
bool found_u = false; bool found_f = false;
bool found_a = false; bool found_u = false;
bool found_a = false;
while ((token = (char *)strtok_r(str, delim, &saveptr)) != NULL) { while ((token = strtok_r(str, delim, &saveptr)) != NULL) {
char *data = token + 1; char *data = token;
if (data && (*data == '=')) {
++data; ++data;
switch (*token) { if (data && (*data == '=')) {
case 'S': ++data;
sidscan = (int)strtol(data, (char **)NULL, 10); switch (*token) {
found_s = true; case 'S':
break; sidscan = (int)strtol(data, (char **)NULL, 10);
case 'P': found_s = true;
pidscan = (int)strtol(data, (char **)NULL, 10); break;
found_p = true; case 'P':
break; pidscan = (int)strtol(data, (char **)NULL, 10);
case 'F': found_p = true;
if (strstr(data, "UDP")) break;
protocol = eProtocolUDP; case 'F':
else if (strstr(data, "HTTP")) if (strstr(data, "UDP")) {
protocol = eProtocolHTTP; protocol = eProtocolUDP;
else if (strstr(data, "FILE")) found_f = true;
protocol = eProtocolFILE; }
else if (strstr(data, "EXT")) else if (strstr(data, "HTTP")) {
protocol = eProtocolEXT; protocol = eProtocolHTTP;
else found_f = true;
found_u = false; }
break; else if (strstr(data, "FILE")) {
case 'U': protocol = eProtocolFILE;
strn0cpy(address, data, sizeof(address)); found_f = true;
found_u = true; }
break; else if (strstr(data, "EXT")) {
case 'A': protocol = eProtocolEXT;
parameter = (int)strtol(data, (char **)NULL, 10); found_f = true;
found_a = true; }
break; break;
default: case 'U':
break; strn0cpy(address, data, sizeof(address));
} found_u = true;
break;
case 'A':
parameter = (int)strtol(data, (char **)NULL, 10);
found_a = true;
break;
default:
break;
}
}
str = NULL;
} }
str = NULL;
}
if (found_s && found_p && found_f && found_u && found_a) free(str);
return (true);
error("Invalid channel parameters: %s\n", s); if (found_s && found_p && found_f && found_u && found_a)
return (false); result = true;
else
error("Invalid channel parameters: %s\n", str);
}
else
error("No channel parameters\n");
return (result);
} }
// --- cIptvSourceParam ------------------------------------------------------ // --- cIptvSourceParam ------------------------------------------------------