eitd/xmlutil.cpp: split read events code

This commit is contained in:
[CST] Focus
2015-06-01 13:24:53 +03:00
parent 94667ee39a
commit 36cec7d41f
2 changed files with 156 additions and 149 deletions

View File

@@ -285,47 +285,18 @@ void deleteOldfileEvents(const char *epgdir)
}
}
void *insertEventsfromFile(void * data)
bool readEventsFromFile(std::string &epgname, int &ev_count)
{
set_threadname(__func__);
reader_ready=false;
xmlDocPtr event_parser = NULL;
xmlNodePtr eventfile;
xmlNodePtr service;
xmlNodePtr event;
t_original_network_id onid = 0;
t_transport_stream_id tsid = 0;
t_service_id sid = 0;
std::string indexname;
std::string filename;
std::string epgname;
int ev_count = 0;
char * epg_dir = (char *) data;
indexname = std::string(epg_dir) + "index.xml";
xmlDocPtr index_parser = parseXmlFile(indexname.c_str());
if (index_parser == NULL) {
reader_ready = true;
pthread_exit(NULL);
}
time_t now = time_monotonic_ms();
printdate_ms(stdout);
printf("[sectionsd] Reading Information from file %s:\n", indexname.c_str());
eventfile = xmlDocGetRootElement(index_parser);
eventfile = xmlChildrenNode(eventfile);
while (eventfile) {
const char * name = xmlGetAttribute(eventfile, "name");
if(name)
filename=name;
epgname = epg_dir + filename;
if (!(event_parser = parseXmlFile(epgname.c_str()))) {
dprintf("unable to open %s for reading\n", epgname.c_str());
eventfile = xmlNextNode(eventfile);
continue;
return false;
}
service = xmlDocGetRootElement(event_parser);
service = xmlChildrenNode(service);
@@ -467,6 +438,41 @@ void *insertEventsfromFile(void * data)
service = xmlNextNode(service);
}
xmlFreeDoc(event_parser);
return true;
}
void *insertEventsfromFile(void * data)
{
set_threadname(__func__);
reader_ready=false;
std::string indexname;
std::string filename;
std::string epgname;
xmlNodePtr eventfile;
int ev_count = 0;
char * epg_dir = (char *) data;
indexname = std::string(epg_dir) + "index.xml";
xmlDocPtr index_parser = parseXmlFile(indexname.c_str());
if (index_parser == NULL) {
reader_ready = true;
pthread_exit(NULL);
}
time_t now = time_monotonic_ms();
printdate_ms(stdout);
printf("[sectionsd] Reading Information from file %s:\n", indexname.c_str());
eventfile = xmlDocGetRootElement(index_parser);
eventfile = xmlChildrenNode(eventfile);
while (eventfile) {
const char * name = xmlGetAttribute(eventfile, "name");
if(name)
filename=name;
epgname = epg_dir + filename;
readEventsFromFile(epgname, ev_count);
eventfile = xmlNextNode(eventfile);
}

View File

@@ -35,6 +35,7 @@
#include <zapit/types.h>
void *insertEventsfromFile(void * data);
bool readEventsFromFile(std::string &epgname, int &ev_count);
void writeEventsToFile(const char *epgdir);
bool readEPGFilter(void);