Remove libxmlccwrap and use directly libxml2
authorAthanasios Oikonomou <athoik@gmail.com>
Tue, 28 Jul 2015 20:19:59 +0000 (23:19 +0300)
committerMike Looijmans <milo-software@users.sourceforge.net>
Sat, 1 Aug 2015 14:55:59 +0000 (16:55 +0200)
libxmlccwrap is used to read satellites, cables and terrestrial xml files.
Use directly libxml2 that is already installed without using libxmlccwrap.

Signed-off-by: Mike Looijmans <milo-software@users.sourceforge.net>

Typo: s/transpoder/transponder/g

configure.ac
lib/dvb/db.cpp
main/Makefile.am

index f2a4770..60f35fe 100644 (file)
@@ -46,11 +46,6 @@ AC_SUBST(LIBJPEG_LIBS)
 AC_CHECK_LIB([ungif], [DGifOpen], [LIBGIF_LIBS="-lungif"], [AC_CHECK_LIB([gif], [DGifOpen], [LIBGIF_LIBS="-lgif"], [AC_MSG_ERROR([Could not find libgif or libungif])])])
 AC_SUBST(LIBGIF_LIBS)
 
-AC_LANG_PUSH([C++])
-AC_CHECK_LIB([xmlccwrap], [exit], [LIBXMLCCWRAP_LIBS="-lxmlccwrap"], [AC_MSG_ERROR([Could not find libxmlccwrap])])
-AC_SUBST(LIBXMLCCWRAP_LIBS)
-AC_LANG_POP
-
 AC_ARG_WITH(boxtype,
        [  --with-boxtype=NAME box type [[none,dm7025,dm800...]]],
        [BOXTYPE="$withval"],[BOXTYPE="dm800"])
index ae50031..c49e59c 100644 (file)
@@ -9,7 +9,8 @@
 #include <lib/base/eerror.h>
 #include <lib/base/estring.h>
 #include <lib/base/nconfig.h>
-#include <xmlccwrap/xmlccwrap.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
 #include <dvbsi++/service_description_section.h>
 #include <dvbsi++/descriptor_tag.h>
 #include <dvbsi++/service_descriptor.h>
@@ -1030,8 +1031,6 @@ int eDVBDB::renumberBouquet(eBouquet &bouquet, int startChannelNum)
 
 eDVBDB *eDVBDB::instance;
 
-using namespace xmlcc;
-
 eDVBDB::eDVBDB()
        : m_numbering_mode(false), m_load_unlinked_userbouquets(true)
 {
@@ -1061,60 +1060,59 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                        eDebug("[eDVBDB] readSatellites arg 0 is not a python list");
                return NULL;
        }
-       XMLTree tree;
+
        const char* satellitesFilename = "/etc/enigma2/satellites.xml";
        if (::access(satellitesFilename, R_OK) < 0)
        {
                satellitesFilename = "/etc/tuxbox/satellites.xml";
        }
-       tree.setFilename(satellitesFilename);
-       tree.read();
-       Element *root = tree.getRoot();
-       if (!root)
+
+       xmlDoc *doc = xmlReadFile(satellitesFilename, NULL, 0);
+       if (!doc)
        {
                eDebug("[eDVBDB] couldn't open %s!!", satellitesFilename);
                Py_INCREF(Py_False);
                return Py_False;
        }
+
        int tmp, *dest = NULL,
                modulation, system, freq, sr, pol, fec, inv, pilot, rolloff, tsid, onid;
        char *end_ptr;
-       const Attribute *at;
-       std::string name;
-       const ElementList &root_elements = root->getElementList();
-       for (ElementConstIterator it(root_elements.begin()); it != root_elements.end(); ++it)
-       {
-//             eDebug("[eDVBDB] element: %s", (*it)->name().c_str());
-               const Element *el = *it;
-               const ElementList &sat_elements = el->getElementList();
-               const AttributeList &sat_attributes = el->getAttributeList();
+
+       xmlNode *root_element = xmlDocGetRootElement(doc);
+       xmlNode *satellite = root_element ? root_element->children : NULL;
+
+       while(satellite)
+       {
                ePyObject sat_name;
                ePyObject sat_pos;
                ePyObject sat_flags;
-               for (AttributeConstIterator it(sat_attributes.begin()); it != sat_attributes.end(); ++it)
+
+               for(xmlAttrPtr attr = satellite->properties; attr; attr = attr->next)
                {
-//                     eDebug("[eDVBDB] \tattr: %s", at->name().c_str());
-                       at = *it;
-                       name = at->name();
+                       std::string name((const char*)attr->name);
                        if (name == "name")
-                               sat_name = PyString_FromString(at->value().c_str());
+                       {
+                               sat_name = PyString_FromString((const char*)attr->children->content);
+                       }
                        else if (name == "flags")
                        {
-                               tmp = strtol(at->value().c_str(), &end_ptr, 10);
+                               tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
                                if (!*end_ptr)
+                               {
                                        sat_flags = PyInt_FromLong(tmp);
+                               }
                        }
                        else if (name == "position")
                        {
-                               tmp = strtol(at->value().c_str(), &end_ptr, 10);
+                               tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
                                if (!*end_ptr)
                                {
-                                       if (tmp < 0)
-                                               tmp = 3600 + tmp;
-                                       sat_pos = PyInt_FromLong(tmp);
+                                       sat_pos = PyInt_FromLong(tmp < 0 ? 3600 + tmp : tmp);
                                }
                        }
                }
+
                if (sat_pos && sat_name)
                {
                        ePyObject tplist = PyList_New(0);
@@ -1128,11 +1126,11 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                        Py_DECREF(tuple);
                        PyDict_SetItem(sat_dict, sat_pos, sat_name);
                        PyDict_SetItem(tp_dict, sat_pos, tplist);
-                       for (ElementConstIterator it(sat_elements.begin()); it != sat_elements.end(); ++it)
+
+                       xmlNode *transponder = satellite->children;
+
+                       while(transponder)
                        {
-                               //eDebug("[eDVBDB] \telement: %s", (*it)->name().c_str());
-                               const AttributeList &tp_attributes = (*it)->getAttributeList();
-                               AttributeConstIterator end = tp_attributes.end();
                                modulation = eDVBFrontendParametersSatellite::Modulation_QPSK;
                                system = eDVBFrontendParametersSatellite::System_DVB_S;
                                freq = 0;
@@ -1145,11 +1143,9 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                                tsid = -1;
                                onid = -1;
 
-                               for (AttributeConstIterator it(tp_attributes.begin()); it != end; ++it)
+                               for(xmlAttrPtr attr = transponder->properties; attr; attr = attr->next)
                                {
-                                       at = *it;
-                                       //eDebug("[eDVBDB] \t\tattr: %s", at->name().c_str());
-                                       name = at->name();
+                                       std::string name((const char*)attr->name);
                                        if (name == "modulation") dest = &modulation;
                                        else if (name == "system") dest = &system;
                                        else if (name == "frequency") dest = &freq;
@@ -1162,14 +1158,17 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                                        else if (name == "tsid") dest = &tsid;
                                        else if (name == "onid") dest = &onid;
                                        else continue;
+
                                        if (dest)
                                        {
-                                               //eDebug("[eDVBDB] \t\t\tvalue: %s", at->value().c_str());
-                                               tmp = strtol(at->value().c_str(), &end_ptr, 10);
+                                               tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
                                                if (!*end_ptr)
+                                               {
                                                        *dest = tmp;
+                                               }
                                        }
                                }
+
                                if (freq && sr && pol != -1)
                                {
                                        tuple = PyTuple_New(12);
@@ -1188,7 +1187,11 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                                        PyList_Append(tplist, tuple);
                                        Py_DECREF(tuple);
                                }
+
+                               // next transponder
+                               transponder = transponder->next;
                        }
+
                        Py_DECREF(tplist);
                }
                else
@@ -1200,7 +1203,13 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
                        if (sat_flags)
                                Py_DECREF(sat_flags);
                }
+
+               // next satellite
+               satellite = satellite->next;
        }
+
+       xmlFreeDoc(doc);
+
        Py_INCREF(Py_True);
        return Py_True;
 }
@@ -1220,49 +1229,46 @@ PyObject *eDVBDB::readCables(ePyObject cab_list, ePyObject tp_dict)
                        eDebug("[eDVBDB] readCables arg 0 is not a python list");
                return NULL;
        }
-       XMLTree tree;
+
        const char* cablesFilename = "/etc/enigma2/cables.xml";
        if (::access(cablesFilename, R_OK) < 0)
        {
                cablesFilename = "/etc/tuxbox/cables.xml";
        }
-       tree.setFilename(cablesFilename);
-       tree.read();
-       Element *root = tree.getRoot();
-       if (!root)
+
+       xmlDoc *doc = xmlReadFile(cablesFilename, NULL, 0);
+       if (!doc)
        {
                eDebug("[eDVBDB] couldn't open %s!!", cablesFilename);
                Py_INCREF(Py_False);
                return Py_False;
        }
-       const Attribute *at;
+
        int tmp, *dest,
                modulation, fec, freq, sr, inversion, system;
-       std::string name;
        char *end_ptr;
-       const ElementList &root_elements = root->getElementList();
-       for (ElementConstIterator it(root_elements.begin()); it != root_elements.end(); ++it)
+
+       xmlNode *root_element = xmlDocGetRootElement(doc);
+       xmlNode *cable = root_element ? root_element->children : NULL;
+
+       while(cable)
        {
-//             eDebug("[eDVBDB] element: %s", el->name().c_str());
-               const Element *el = *it;
-               const ElementList &cab_elements = el->getElementList();
-               const AttributeList &cab_attributes = el->getAttributeList();
                ePyObject cab_name;
                ePyObject cab_flags;
-               for (AttributeConstIterator it(cab_attributes.begin()); it != cab_attributes.end(); ++it)
+
+               for(xmlAttrPtr attr = cable->properties; attr; attr = attr->next)
                {
-//                     eDebug("[eDVBDB]\tattr: %s", at->name().c_str());
-                       at = *it;
-                       name = at->name();
+                       std::string name((const char*)attr->name);
                        if (name == "name")
-                               cab_name = PyString_FromString(at->value().c_str());
+                               cab_name = PyString_FromString((const char*)attr->children->content);
                        else if (name == "flags")
                        {
-                               tmp = strtol(at->value().c_str(), &end_ptr, 10);
+                               tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
                                if (!*end_ptr)
                                        cab_flags = PyInt_FromLong(tmp);
                        }
                }
+
                if (cab_name)
                {
                        ePyObject tplist = PyList_New(0);
@@ -1274,23 +1280,22 @@ PyObject *eDVBDB::readCables(ePyObject cab_list, ePyObject tp_dict)
                        PyList_Append(cab_list, tuple);
                        Py_DECREF(tuple);
                        PyDict_SetItem(tp_dict, cab_name, tplist);
-                       for (ElementConstIterator it(cab_elements.begin()); it != cab_elements.end(); ++it)
+
+                       xmlNode *transponder = cable->children;
+
+                       while(transponder)
                        {
-//                             eDebug("[eDVBDB]\telement: %s", (*it)->name().c_str());
-                               const AttributeList &tp_attributes = (*it)->getAttributeList();
-                               AttributeConstIterator end = tp_attributes.end();
                                modulation = eDVBFrontendParametersCable::Modulation_QAM64;
                                fec = eDVBFrontendParametersCable::FEC_Auto;
                                system = eDVBFrontendParametersCable::System_DVB_C_ANNEX_A;
                                inversion = eDVBFrontendParametersCable::Inversion_Unknown;
                                freq = 0;
                                sr = 0;
-                               for (AttributeConstIterator it(tp_attributes.begin()); it != end; ++it)
+
+                               for(xmlAttrPtr attr = transponder->properties; attr; attr = attr->next)
                                {
-//                                     eDebug("[eDVBDB]\t\tattr: %s", at->name().c_str());
-                                       at = *it;
                                        dest = 0;
-                                       name = at->name();
+                                       std::string name((const char*)attr->name);
                                        if (name == "modulation") dest = &modulation;
                                        else if (name == "frequency") dest = &freq;
                                        else if (name == "symbol_rate") dest = &sr;
@@ -1298,13 +1303,17 @@ PyObject *eDVBDB::readCables(ePyObject cab_list, ePyObject tp_dict)
                                        else if (name == "inversion") dest = &inversion;
                                        else if (name == "system") dest = &system;
                                        else continue;
+
                                        if (dest)
                                        {
-                                               tmp = strtol(at->value().c_str(), &end_ptr, 10);
+                                               tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
                                                if (!*end_ptr)
+                                               {
                                                        *dest = tmp;
+                                               }
                                        }
                                }
+
                                if (freq && sr)
                                {
                                        while (freq > 999999)
@@ -1320,12 +1329,24 @@ PyObject *eDVBDB::readCables(ePyObject cab_list, ePyObject tp_dict)
                                        PyList_Append(tplist, tuple);
                                        Py_DECREF(tuple);
                                }
+
+                               // next transponder
+                               transponder = transponder->next;
                        }
+
                        Py_DECREF(tplist);
                }
                else if (cab_flags)
+               {
                        Py_DECREF(cab_flags);
+               }
+
+               // next cable
+               cable = cable->next;
        }
+
+       xmlFreeDoc(doc);
+
        Py_INCREF(Py_True);
        return Py_True;
 }
@@ -1345,49 +1366,50 @@ PyObject *eDVBDB::readTerrestrials(ePyObject ter_list, ePyObject tp_dict)
                        eDebug("[eDVBDB] readTerrestrials arg 0 is not a python list");
                return NULL;
        }
-       XMLTree tree;
+
        const char* terrestrialFilename = "/etc/enigma2/terrestrial.xml";
        if (::access(terrestrialFilename, R_OK) < 0)
        {
                terrestrialFilename = "/etc/tuxbox/terrestrial.xml";
        }
-       tree.setFilename(terrestrialFilename);
-       tree.read();
-       Element *root = tree.getRoot();
-       if (!root)
+
+       xmlDoc *doc = xmlReadFile(terrestrialFilename, NULL, 0);
+       if (!doc)
        {
                eDebug("[eDVBDB] couldn't open %s!!", terrestrialFilename);
                Py_INCREF(Py_False);
                return Py_False;
        }
-       const Attribute *at;
-       std::string name;
+
        int tmp, *dest,
                freq, bw, constellation, crh, crl, guard, transm, hierarchy, inv, system, plpid;
        char *end_ptr;
-       const ElementList &root_elements = root->getElementList();
-       for (ElementConstIterator it(root_elements.begin()); it != root_elements.end(); ++it)
+
+       xmlNode *root_element = xmlDocGetRootElement(doc);
+       xmlNode *terrestrial = root_element ? root_element->children : NULL;
+
+       while(terrestrial)
        {
-//             eDebug("[eDVBDB] element: %s", el->name().c_str());
-               const Element *el = *it;
-               const ElementList &ter_elements = el->getElementList();
-               const AttributeList &ter_attributes = el->getAttributeList();
                ePyObject ter_name;
                ePyObject ter_flags;
-               for (AttributeConstIterator it(ter_attributes.begin()); it != ter_attributes.end(); ++it)
+
+               for(xmlAttrPtr attr = terrestrial->properties; attr; attr = attr->next)
                {
-//                     eDebug("[eDVBDB]\tattr: %s", at->name().c_str());
-                       at = *it;
-                       name = at->name();
+                       std::string name((const char*)attr->name);
                        if (name == "name")
-                               ter_name = PyString_FromString(at->value().c_str());
+                       {
+                               ter_name = PyString_FromString((const char*)attr->children->content);
+                       }
                        else if (name == "flags")
                        {
-                               tmp = strtol(at->value().c_str(), &end_ptr, 10);
+                               tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
                                if (!*end_ptr)
+                               {
                                        ter_flags = PyInt_FromLong(tmp);
+                               }
                        }
                }
+
                if (ter_name)
                {
                        ePyObject tplist = PyList_New(0);
@@ -1399,11 +1421,11 @@ PyObject *eDVBDB::readTerrestrials(ePyObject ter_list, ePyObject tp_dict)
                        PyList_Append(ter_list, tuple);
                        Py_DECREF(tuple);
                        PyDict_SetItem(tp_dict, ter_name, tplist);
-                       for (ElementConstIterator it(ter_elements.begin()); it != ter_elements.end(); ++it)
+
+                       xmlNode *transponder = terrestrial->children;
+
+                       while(transponder)
                        {
-//                             eDebug("[eDVBDB]\telement: %s", (*it)->name().c_str());
-                               const AttributeList &tp_attributes = (*it)->getAttributeList();
-                               AttributeConstIterator end = tp_attributes.end();
                                freq = 0;
                                bw = eDVBFrontendParametersTerrestrial::Bandwidth_Auto;
                                constellation = eDVBFrontendParametersTerrestrial::Modulation_Auto;
@@ -1415,12 +1437,11 @@ PyObject *eDVBDB::readTerrestrials(ePyObject ter_list, ePyObject tp_dict)
                                inv = eDVBFrontendParametersTerrestrial::Inversion_Unknown;
                                system = eDVBFrontendParametersTerrestrial::System_DVB_T_T2;
                                plpid = 0;
-                               for (AttributeConstIterator it(tp_attributes.begin()); it != end; ++it)
+
+                               for(xmlAttrPtr attr = transponder->properties; attr; attr = attr->next)
                                {
-//                                     eDebug("[eDVBDB]\t\tattr: %s", at->name().c_str());
-                                       at = *it;
                                        dest = 0;
-                                       name = at->name();
+                                       std::string name((const char*)attr->name);
                                        if (name == "centre_frequency") dest = &freq;
                                        else if (name == "bandwidth") dest = &bw;
                                        else if (name == "constellation") dest = &constellation;
@@ -1433,13 +1454,17 @@ PyObject *eDVBDB::readTerrestrials(ePyObject ter_list, ePyObject tp_dict)
                                        else if (name == "system") dest = &system;
                                        else if (name == "plp_id") dest = &plpid;
                                        else continue;
+
                                        if (dest)
                                        {
-                                               tmp = strtol(at->value().c_str(), &end_ptr, 10);
+                                               tmp = strtol((const char*)attr->name, &end_ptr, 10);
                                                if (!*end_ptr)
+                                               {
                                                        *dest = tmp;
+                                               }
                                        }
                                }
+
                                if (freq)
                                {
                                        switch (bw)
@@ -1473,12 +1498,24 @@ PyObject *eDVBDB::readTerrestrials(ePyObject ter_list, ePyObject tp_dict)
                                        PyList_Append(tplist, tuple);
                                        Py_DECREF(tuple);
                                }
+
+                               // next transponder
+                               transponder = transponder->next;
                        }
+
                        Py_DECREF(tplist);
                }
                else if (ter_flags)
+               {
                        Py_DECREF(ter_flags);
+               }
+
+               // next terrestrial
+               terrestrial = terrestrial->next;
        }
+
+       xmlFreeDoc(doc);
+
        Py_INCREF(Py_True);
        return Py_True;
 }
index 03121cc..8d9923b 100644 (file)
@@ -47,7 +47,6 @@ enigma2_LDADD = \
        @LIBJPEG_LIBS@ \
        @LIBSDL_LIBS@ \
        @LIBXINE_LIBS@ \
-       @LIBXMLCCWRAP_LIBS@ \
        @PTHREAD_LIBS@ \
        @PYTHON_LDFLAGS@ \
        @LIBDDVD_LIBS@ \