summaryrefslogtreecommitdiff
path: root/xmltv2vdr.cpp
diff options
context:
space:
mode:
authorJochen Dolze <vdr@dolze.de>2011-08-01 17:55:01 +0200
committerJochen Dolze <vdr@dolze.de>2011-08-01 17:55:01 +0200
commit197e21d0450b0fdc6b52f8c89a48c3cd637c88ed (patch)
tree2c21c0d96fabd693f22a3b956224f0a6da5ab383 /xmltv2vdr.cpp
parent4acb900fec6961c82d67f0d87e1e6a973324005d (diff)
downloadvdr-plugin-xmltv2vdr-197e21d0450b0fdc6b52f8c89a48c3cd637c88ed.tar.gz
vdr-plugin-xmltv2vdr-197e21d0450b0fdc6b52f8c89a48c3cd637c88ed.tar.bz2
Fixed "parse error" bug
Diffstat (limited to 'xmltv2vdr.cpp')
-rw-r--r--xmltv2vdr.cpp60
1 files changed, 39 insertions, 21 deletions
diff --git a/xmltv2vdr.cpp b/xmltv2vdr.cpp
index 533bf2c..42be8cb 100644
--- a/xmltv2vdr.cpp
+++ b/xmltv2vdr.cpp
@@ -9,6 +9,7 @@
#include <string.h>
#include <time.h>
#include <sys/wait.h>
+#include <sys/ioctl.h>
#include "xmltv2vdr.h"
#include "extpipe.h"
#include "setup.h"
@@ -349,8 +350,26 @@ int cEPGSource::Execute()
strcat(cmd," ");
}
}
- //dsyslog("xmltv2vdr: '%s' %s",name,cmd);
- cExtPipe p;
+ char *pcmd=strdup(cmd);
+ if (pcmd) {
+ char *pa=strchr(pcmd,'\'');
+ char *pe=strchr(pa+1,'\'');
+ if (pa && pe) {
+ pa++;
+ for (char *c=pa; c<pe; c++)
+ {
+ if (c==pa) {
+ *c='X';
+ } else {
+ *c='@';
+ }
+ }
+ // TODO: strip @
+ isyslog("xmltv2vdr: '%s' %s",name,pcmd);
+ }
+ free(pcmd);
+ }
+ cExtPipe p;
if (!p.Open(cmd))
{
free(cmd);
@@ -369,19 +388,26 @@ int cEPGSource::Execute()
fds[1].events=POLLIN;
if (poll(fds,2,500)>=0) {
if (fds[0].revents & POLLIN) {
- unsigned char c;
- if (read(p.Out(),&c,1)==1)
+ int n;
+ if (ioctl(p.Out(),FIONREAD,&n)<0) {
+ n=1;
+ }
+ r_out=(char *) realloc(r_out, l_out+n+1);
+ int l=read(p.Out(),r_out+l_out,n);
+ if (l>0)
{
- if (l_out%20==0) r_out=(char *) realloc(r_out, l_out+21);
- r_out[l_out++]=c;
+ l_out+=l;
}
}
if (fds[1].revents & POLLIN) {
- unsigned char c;
- if (read(p.Err(),&c,1)==1)
- {
- if (l_err%20==0) r_err=(char *) realloc(r_err, l_err+21);
- r_err[l_err++]=c;
+ int n;
+ if (ioctl(p.Err(),FIONREAD,&n)<0) {
+ n=1;
+ }
+ r_err=(char *) realloc(r_err, l_err+n+1);
+ int l=read(p.Err(),r_err+l_err,n);
+ if (l>0) {
+ l_err+=l;
}
}
if (fds[0].revents & POLLHUP) {
@@ -407,11 +433,7 @@ int cEPGSource::Execute()
if ((!returncode) && (r_out))
{
dsyslog("xmltv2vdr: '%s' parsing output",name);
- if (!parse->Process(r_out,l_out))
- {
- esyslog("xmltv2vdr: '%s' ERROR failed to parse output",name);
- ret=141;
- }
+ ret=parse->Process(r_out,l_out);
}
else
{
@@ -437,11 +459,7 @@ int cEPGSource::Execute()
char *result=NULL;
ret=ReadOutput(result,l);
if ((!ret) && (result)) {
- if (!parse->Process(result,l))
- {
- esyslog("xmltv2vdr: '%s' failed to parse output",name);
- ret=149;
- }
+ ret=parse->Process(result,l);
}
if (result) free(result);
}