summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extpipe.cpp30
-rw-r--r--parse.cpp26
-rw-r--r--parse.h2
-rw-r--r--setup.cpp8
-rw-r--r--setup.h1
-rw-r--r--xmltv2vdr.cpp60
6 files changed, 66 insertions, 61 deletions
diff --git a/extpipe.cpp b/extpipe.cpp
index 4ce2c80..eb057d1 100644
--- a/extpipe.cpp
+++ b/extpipe.cpp
@@ -54,36 +54,8 @@ bool cExtPipe::Open(const char *Command)
{
close(fd_stdout[1]); // close write fd, we need only read fd
close(fd_stderr[1]); // close write fd, we need only read fd
- int flags=fcntl(fd_stdout[0],F_GETFL,0);
- if (flags==-1) {
- LOG_ERROR;
- close(fd_stdout[0]);
- close(fd_stderr[0]);
- return false;
- }
- flags|=O_NONBLOCK;
- if (fcntl(fd_stdout[0],F_SETFL,flags)==-1) {
- LOG_ERROR;
- close(fd_stdout[0]);
- close(fd_stderr[0]);
- return false;
- }
- flags=fcntl(fd_stderr[0],F_GETFL,0);
- if (flags==-1) {
- LOG_ERROR;
- close(fd_stdout[0]);
- close(fd_stderr[0]);
- return false;
-
- }
- if (fcntl(fd_stderr[0],F_SETFL,flags)==-1) {
- LOG_ERROR;
- close(fd_stdout[0]);
- close(fd_stderr[0]);
- return false;
- }
f_stdout = fd_stdout[0];
- f_stderr = fd_stderr[0];
+ f_stderr = fd_stderr[0];
return true;
}
else // child process
diff --git a/parse.cpp b/parse.cpp
index 8a5eb52..cbf7a60 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -22,7 +22,7 @@ void cXMLTVEvent::SetTitle(const char *Title)
{
title = strcpyrealloc(title, Title);
if (title) {
- title = compactspace(title);
+ title = compactspace(title);
}
}
@@ -857,28 +857,32 @@ cEPGMapping *cParse::EPGMapping(const char *ChannelName)
return NULL;
}
-bool cParse::Process(char *buffer, int bufsize)
+int cParse::Process(char *buffer, int bufsize)
{
- if (!buffer) return false;
- if (!bufsize) return false;
+ if (!buffer) return 134;
+ if (!bufsize) return 134;
xmlDocPtr xmltv;
xmltv=xmlReadMemory(buffer,bufsize,NULL,NULL,0);
- if (!xmltv) return false;
+ if (!xmltv) {
+ esyslog("xmltv2vdr: '%s' ERROR failed to parse xmltv",name);
+ return 141;
+ }
xmlNodePtr rootnode=xmlDocGetRootElement(xmltv);
if (!rootnode)
{
+ esyslog("xmltv2vdr: '%s' ERROR no rootnode in xmltv",name);
xmlFreeDoc(xmltv);
- return false;
+ return 141;
}
cSchedulesLock schedulesLock(true,25000); // wait up to 25 secs for lock!
const cSchedules *schedules = cSchedules::Schedules(schedulesLock);
if (!schedules)
{
- esyslog("xmltv2vdr: '%s' cannot get schedules, try later",name);
- return false;
+ esyslog("xmltv2vdr: '%s' cannot get schedules now, trying later",name);
+ return 1;
}
time_t begin=time(NULL);
@@ -916,7 +920,9 @@ bool cParse::Process(char *buffer, int bufsize)
node=node->next;
continue;
}
- time_t end=begin+(86000*map->Days())+3600; // 1 hour overlap
+ int days=map->Days();
+ if ((map->Flags() & OPT_APPEND)!=OPT_APPEND) days=1; // only one day with merge
+ time_t end=begin+(86000*days)+3600; // 1 hour overlap
xmlChar *start,*stop;
time_t starttime=(time_t) 0;
time_t stoptime=(time_t) 0;
@@ -1041,7 +1047,7 @@ bool cParse::Process(char *buffer, int bufsize)
node=node->next;
}
xmlFreeDoc(xmltv);
- return true;
+ return 0;
}
void cParse::InitLibXML()
diff --git a/parse.h b/parse.h
index d4970b0..2ea1912 100644
--- a/parse.h
+++ b/parse.h
@@ -174,7 +174,7 @@ private:
public:
cParse(const char *Name, cEPGMappings *Maps, cTEXTMappings *Texts);
~cParse();
- bool Process(char *buffer, int bufsize);
+ int Process(char *buffer, int bufsize);
static void InitLibXML();
static void CleanupLibXML();
};
diff --git a/setup.cpp b/setup.cpp
index 606ce81..b6ae0f1 100644
--- a/setup.cpp
+++ b/setup.cpp
@@ -819,6 +819,12 @@ int cMenuSetupXmltv2vdrChannelMap::getdaysmax()
return ret;
}
+cOsdItem *cMenuSetupXmltv2vdrChannelMap::optionN(const char *s, int num)
+{
+ cString buffer = cString::sprintf("%s:\t%i", s, num);
+ return new cOsdItem(buffer,osUnknown,false);
+}
+
cOsdItem *cMenuSetupXmltv2vdrChannelMap::option(const char *s, bool yesno)
{
cString buffer = cString::sprintf("%s:\t%s", s, yesno ? trVDR("yes") : trVDR("no"));
@@ -846,6 +852,7 @@ void cMenuSetupXmltv2vdrChannelMap::output(void)
c1=Current();
if ((flags & OPT_APPEND)!=OPT_APPEND)
{
+ Add(new cMenuEditIntItem(tr("days in advance"),&days,1,daysmax),true);
Add(new cMyMenuEditBitItem(tr("short text"),&flags,USE_SHORTTEXT),true);
Add(new cMyMenuEditBitItem(tr("long text"),&flags,USE_LONGTEXT),true);
c2=Current();
@@ -856,6 +863,7 @@ void cMenuSetupXmltv2vdrChannelMap::output(void)
}
else
{
+ Add(optionN(tr("days in advance"),1),true);
Add(option(tr("short text"),true),true);
Add(option(tr("long text"),true),true);
Add(option(tr(" merge long texts"),false),true);
diff --git a/setup.h b/setup.h
index a787db7..b1a9b3e 100644
--- a/setup.h
+++ b/setup.h
@@ -126,6 +126,7 @@ private:
const char *channel;
int getdaysmax();
cOsdItem *newtitle (const char *s);
+ cOsdItem *optionN(const char *s, int num);
cOsdItem *option(const char *s, bool yesno);
void epgmappingreplace(cEPGMapping *newmapping);
int c1,c2,c3,cm;
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);
}