xmlinterface use const char instand char

This commit is contained in:
Jacek Jendrzej
2015-03-20 12:05:22 +01:00
parent 40fe7fae34
commit 8227a01592
9 changed files with 50 additions and 50 deletions

View File

@@ -47,7 +47,7 @@
unsigned long xmlGetNumericAttribute(const xmlNodePtr node, const char *name, const int base) unsigned long xmlGetNumericAttribute(const xmlNodePtr node, const char *name, const int base)
{ {
char *ptr = xmlGetAttribute(node, name); const char *ptr = xmlGetAttribute(node, name);
if (!ptr) if (!ptr)
return 0; return 0;
@@ -57,7 +57,7 @@ unsigned long xmlGetNumericAttribute(const xmlNodePtr node, const char *name, co
long xmlGetSignedNumericAttribute(const xmlNodePtr node, const char *name, const int base) long xmlGetSignedNumericAttribute(const xmlNodePtr node, const char *name, const int base)
{ {
char *ptr = xmlGetAttribute(node, name); const char *ptr = xmlGetAttribute(node, name);
if (!ptr) if (!ptr)
return 0; return 0;

View File

@@ -41,8 +41,8 @@
#ifdef USE_LIBXML #ifdef USE_LIBXML
#include <libxml/parser.h> #include <libxml/parser.h>
#define xmlNextNode next #define xmlNextNode next
inline char* xmlGetAttribute (xmlNodePtr cur, const char * s) { return (char *)xmlGetProp(cur, (const xmlChar *)s); }; inline const char* xmlGetAttribute (xmlNodePtr cur, const char * s) { return (const char *)xmlGetProp(cur, (const xmlChar *)s); };
inline char* xmlGetName (xmlNodePtr cur) { return (char *)(cur->name); }; inline const char* xmlGetName (xmlNodePtr cur) { return (const char *)(cur->name); };
#else /* use libxmltree */ #else /* use libxmltree */
#include "xmltree.h" #include "xmltree.h"
@@ -52,9 +52,9 @@ typedef XMLTreeNode* xmlNodePtr;
#define xmlNextNode GetNext() #define xmlNextNode GetNext()
inline xmlNodePtr xmlDocGetRootElement(xmlDocPtr doc) { return doc->RootNode(); } inline xmlNodePtr xmlDocGetRootElement(xmlDocPtr doc) { return doc->RootNode(); }
inline void xmlFreeDoc (xmlDocPtr doc) { delete doc; } inline void xmlFreeDoc (xmlDocPtr doc) { delete doc; }
inline char* xmlGetAttribute (xmlNodePtr cur, const char *s) { return cur->GetAttributeValue(s); } inline const char* xmlGetAttribute (xmlNodePtr cur, const char *s) { return cur->GetAttributeValue(s); }
inline char* xmlGetName (xmlNodePtr cur) { return cur->GetType(); } inline const char* xmlGetName (xmlNodePtr cur) { return cur->GetType(); }
inline char* xmlGetData (xmlNodePtr cur) { return cur->GetData(); } inline const char* xmlGetData (xmlNodePtr cur) { return cur->GetData(); }
#endif /* USE_LIBXML */ #endif /* USE_LIBXML */

View File

@@ -347,7 +347,7 @@ void *insertEventsfromFile(void * data)
node = event->xmlChildrenNode; node = event->xmlChildrenNode;
while ((node = xmlGetNextOccurence(node, "name"))) { while ((node = xmlGetNextOccurence(node, "name"))) {
char *s = xmlGetAttribute(node, "string"); const char *s = xmlGetAttribute(node, "string");
if (s) if (s)
e.setName(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "lang")), s); e.setName(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "lang")), s);
node = node->xmlNextNode; node = node->xmlNextNode;
@@ -355,7 +355,7 @@ void *insertEventsfromFile(void * data)
node = event->xmlChildrenNode; node = event->xmlChildrenNode;
while ((node = xmlGetNextOccurence(node, "text"))) { while ((node = xmlGetNextOccurence(node, "text"))) {
char *s = xmlGetAttribute(node, "string"); const char *s = xmlGetAttribute(node, "string");
if (s) if (s)
e.setText(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "lang")), s); e.setText(ZapitTools::UTF8_to_Latin1(xmlGetAttribute(node, "lang")), s);
node = node->xmlNextNode; node = node->xmlNextNode;
@@ -363,7 +363,7 @@ void *insertEventsfromFile(void * data)
node = event->xmlChildrenNode; node = event->xmlChildrenNode;
while ((node = xmlGetNextOccurence(node, "item"))) { while ((node = xmlGetNextOccurence(node, "item"))) {
#ifdef USE_ITEM_DESCRIPTION #ifdef USE_ITEM_DESCRIPTION
char *s = xmlGetAttribute(node, "string"); const char *s = xmlGetAttribute(node, "string");
if (s) if (s)
e.item = s; e.item = s;
#endif #endif
@@ -373,7 +373,7 @@ void *insertEventsfromFile(void * data)
node = event->xmlChildrenNode; node = event->xmlChildrenNode;
while ((node = xmlGetNextOccurence(node, "item_description"))) { while ((node = xmlGetNextOccurence(node, "item_description"))) {
#ifdef USE_ITEM_DESCRIPTION #ifdef USE_ITEM_DESCRIPTION
char *s = xmlGetAttribute(node, "string"); const char *s = xmlGetAttribute(node, "string");
if (s) if (s)
e.itemDescription = s; e.itemDescription = s;
#endif #endif
@@ -381,8 +381,8 @@ void *insertEventsfromFile(void * data)
} }
node = event->xmlChildrenNode; node = event->xmlChildrenNode;
while ((node = xmlGetNextOccurence(node, "extended_text"))) { while ((node = xmlGetNextOccurence(node, "extended_text"))) {
char *l = xmlGetAttribute(node, "lang"); const char *l = xmlGetAttribute(node, "lang");
char *s = xmlGetAttribute(node, "string"); const char *s = xmlGetAttribute(node, "string");
if (l && s) if (l && s)
e.appendExtendedText(ZapitTools::UTF8_to_Latin1(l), s); e.appendExtendedText(ZapitTools::UTF8_to_Latin1(l), s);
node = node->xmlNextNode; node = node->xmlNextNode;
@@ -397,10 +397,10 @@ void *insertEventsfromFile(void * data)
node = event->xmlChildrenNode; node = event->xmlChildrenNode;
while ((node = xmlGetNextOccurence(node, "content"))) { while ((node = xmlGetNextOccurence(node, "content"))) {
char cl = xmlGetNumericAttribute(node, "class", 16); const char cl = xmlGetNumericAttribute(node, "class", 16);
contentClassification += cl; contentClassification += cl;
cl = xmlGetNumericAttribute(node, "user", 16); const char cl2 = xmlGetNumericAttribute(node, "user", 16);
userClassification += cl; userClassification += cl2;
node = node->xmlNextNode; node = node->xmlNextNode;
} }
@@ -410,7 +410,7 @@ void *insertEventsfromFile(void * data)
c.streamContent = xmlGetNumericAttribute(node, "stream_content", 16); c.streamContent = xmlGetNumericAttribute(node, "stream_content", 16);
c.componentType = xmlGetNumericAttribute(node, "type", 16); c.componentType = xmlGetNumericAttribute(node, "type", 16);
c.componentTag = xmlGetNumericAttribute(node, "tag", 16); c.componentTag = xmlGetNumericAttribute(node, "tag", 16);
char *s = xmlGetAttribute(node, "text"); const char *s = xmlGetAttribute(node, "text");
if (s) if (s)
c.setComponent(s); c.setComponent(s);
//e.components.insert(c); //e.components.insert(c);
@@ -420,7 +420,7 @@ void *insertEventsfromFile(void * data)
node = event->xmlChildrenNode; node = event->xmlChildrenNode;
while ((node = xmlGetNextOccurence(node, "parental_rating"))) { while ((node = xmlGetNextOccurence(node, "parental_rating"))) {
char *s = xmlGetAttribute(node, "country"); const char *s = xmlGetAttribute(node, "country");
if (s) if (s)
#if 0 #if 0
e.ratings.insert(SIparentalRating(ZapitTools::UTF8_to_Latin1(s), e.ratings.insert(SIparentalRating(ZapitTools::UTF8_to_Latin1(s),
@@ -438,7 +438,7 @@ void *insertEventsfromFile(void * data)
l.transportStreamId = xmlGetNumericAttribute(node, "transport_stream_id", 16); l.transportStreamId = xmlGetNumericAttribute(node, "transport_stream_id", 16);
l.originalNetworkId = xmlGetNumericAttribute(node, "original_network_id", 16); l.originalNetworkId = xmlGetNumericAttribute(node, "original_network_id", 16);
l.serviceId = xmlGetNumericAttribute(node, "service_id", 16); l.serviceId = xmlGetNumericAttribute(node, "service_id", 16);
char *s = xmlGetAttribute(node, "linkage_descriptor"); const char *s = xmlGetAttribute(node, "linkage_descriptor");
if (s) if (s)
l.name = s; l.name = s;
e.linkage_descs.insert(e.linkage_descs.end(), l); e.linkage_descs.insert(e.linkage_descs.end(), l);

View File

@@ -1133,9 +1133,9 @@ void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *nametag,
neutrino_msg_data_t data; neutrino_msg_data_t data;
g_RCInput->getMsg(&msg, &data, 0); g_RCInput->getMsg(&msg, &data, 0);
while (element && msg != CRCInput::RC_home) { while (element && msg != CRCInput::RC_home) {
char *ptr = NULL; const char *ptr = NULL;
char *name = NULL; const char *name = NULL;
char *url = NULL; const char *url = NULL;
time_t bitrate = 0; time_t bitrate = 0;
bool skip = true; bool skip = true;
listPos++; listPos++;
@@ -1148,7 +1148,7 @@ void CAudioPlayerGui::scanXmlData(xmlDocPtr answer_parser, const char *nametag,
#endif // LCD_UPDATE #endif // LCD_UPDATE
if (usechild) { if (usechild) {
char *type = NULL; const char *type = NULL;
xmlNodePtr child = element->xmlChildrenNode; xmlNodePtr child = element->xmlChildrenNode;
while (child) { while (child) {
if (strcmp(xmlGetName(child), nametag) == 0) if (strcmp(xmlGetName(child), nametag) == 0)

View File

@@ -439,7 +439,7 @@ printf("CFileBrowser::readDir_sc: read done, size %d\n", (int)answer.size());
xmlDocPtr answer_parser = parseXml(answer.c_str()); xmlDocPtr answer_parser = parseXml(answer.c_str());
if (answer_parser != NULL) { if (answer_parser != NULL) {
char *ptr; const char *ptr = NULL;
unsigned char xml_decode = 0; unsigned char xml_decode = 0;
xmlNodePtr element = xmlDocGetRootElement(answer_parser); xmlNodePtr element = xmlDocGetRootElement(answer_parser);
@@ -458,7 +458,7 @@ printf("CFileBrowser::readDir_sc: read done, size %d\n", (int)answer.size());
file.Time = 0; file.Time = 0;
flist->push_back(file); flist->push_back(file);
} else { } else {
char * tunein_base = NULL; const char * tunein_base = NULL;
if (xml_decode == 1) { if (xml_decode == 1) {
CFile file; CFile file;

View File

@@ -252,7 +252,7 @@ bool cYTFeedParser::saveToFile(const char * name, std::string str)
std::string cYTFeedParser::getXmlName(xmlNodePtr node) std::string cYTFeedParser::getXmlName(xmlNodePtr node)
{ {
std::string result; std::string result;
char * name = xmlGetName(node); const char * name = xmlGetName(node);
if (name) if (name)
result = name; result = name;
return result; return result;
@@ -261,7 +261,7 @@ std::string cYTFeedParser::getXmlName(xmlNodePtr node)
std::string cYTFeedParser::getXmlAttr(xmlNodePtr node, const char * attr) std::string cYTFeedParser::getXmlAttr(xmlNodePtr node, const char * attr)
{ {
std::string result; std::string result;
char * value = xmlGetAttribute(node, attr); const char * value = xmlGetAttribute(node, attr);
if (value) if (value)
result = value; result = value;
return result; return result;
@@ -270,7 +270,7 @@ std::string cYTFeedParser::getXmlAttr(xmlNodePtr node, const char * attr)
std::string cYTFeedParser::getXmlData(xmlNodePtr node) std::string cYTFeedParser::getXmlData(xmlNodePtr node)
{ {
std::string result; std::string result;
char * value = xmlGetData(node); const char * value = xmlGetData(node);
if (value) if (value)
result = value; result = value;
return result; return result;

View File

@@ -109,7 +109,7 @@ class CServiceManager
static void CopyFile(char * from, char * to); static void CopyFile(char * from, char * to);
bool InitSatPosition(t_satellite_position position, char * name = NULL, bool force = false, delivery_system_t delsys = DVB_S, uint16_t nid = 0); bool InitSatPosition(t_satellite_position position, const char * name = NULL, bool force = false, delivery_system_t delsys = DVB_S, uint16_t nid = 0);
bool LoadServices(bool only_current); bool LoadServices(bool only_current);
void SaveServices(bool tocopy, bool if_changed = false, bool no_deleted = false); void SaveServices(bool tocopy, bool if_changed = false, bool no_deleted = false);
void SaveMotorPositions(); void SaveMotorPositions();

View File

@@ -43,7 +43,7 @@ extern CBouquetManager *g_bouquetManager;
#define GET_ATTR(node, name, fmt, arg) \ #define GET_ATTR(node, name, fmt, arg) \
do { \ do { \
char * ptr = xmlGetAttribute(node, name); \ const char * ptr = xmlGetAttribute(node, name); \
if ((ptr == NULL) || (sscanf(ptr, fmt, &arg) <= 0)) \ if ((ptr == NULL) || (sscanf(ptr, fmt, &arg) <= 0)) \
arg = 0; \ arg = 0; \
} \ } \
@@ -395,16 +395,16 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser)
INFO("reading bouquets from %s", fname); INFO("reading bouquets from %s", fname);
while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) { while ((search = xmlGetNextOccurence(search, "Bouquet")) != NULL) {
char * name = xmlGetAttribute(search, "name"); const char * name = xmlGetAttribute(search, "name");
if(name == NULL) if(name == NULL)
name = const_cast<char*>("Unknown"); name = const_cast<char*>("Unknown");
CZapitBouquet* newBouquet = addBouquet(name, bUser); CZapitBouquet* newBouquet = addBouquet(name, bUser);
// per default in contructor: newBouquet->BqID = 0; //set to default, override if bqID exists // per default in contructor: newBouquet->BqID = 0; //set to default, override if bqID exists
GET_ATTR(search, "bqID", SCANF_BOUQUET_ID_TYPE, newBouquet->BqID); GET_ATTR(search, "bqID", SCANF_BOUQUET_ID_TYPE, newBouquet->BqID);
char* hidden = xmlGetAttribute(search, "hidden"); const char* hidden = xmlGetAttribute(search, "hidden");
char* locked = xmlGetAttribute(search, "locked"); const char* locked = xmlGetAttribute(search, "locked");
char* scanepg = xmlGetAttribute(search, "epg"); const char* scanepg = xmlGetAttribute(search, "epg");
newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false; newBouquet->bHidden = hidden ? (strcmp(hidden, "1") == 0) : false;
newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false; newBouquet->bLocked = locked ? (strcmp(locked, "1") == 0) : false;
newBouquet->bFav = (strcmp(name, "favorites") == 0); newBouquet->bFav = (strcmp(name, "favorites") == 0);
@@ -416,10 +416,10 @@ void CBouquetManager::parseBouquetsXml(const char *fname, bool bUser)
if (name) if (name)
name2 = name; name2 = name;
std::string uname; std::string uname;
char *uName = xmlGetAttribute(channel_node, "un"); const char *uName = xmlGetAttribute(channel_node, "un");
if (uName) if (uName)
uname = uName; uname = uName;
char *url = xmlGetAttribute(channel_node, "u"); const char *url = xmlGetAttribute(channel_node, "u");
GET_ATTR(channel_node, "i", SCANF_SERVICE_ID_TYPE, service_id); GET_ATTR(channel_node, "i", SCANF_SERVICE_ID_TYPE, service_id);
GET_ATTR(channel_node, "on", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id); GET_ATTR(channel_node, "on", SCANF_ORIGINAL_NETWORK_ID_TYPE, original_network_id);
GET_ATTR(channel_node, "s", SCANF_SATELLITE_POSITION_TYPE, satellitePosition); GET_ATTR(channel_node, "s", SCANF_SATELLITE_POSITION_TYPE, satellitePosition);

View File

@@ -462,7 +462,7 @@ void CServiceManager::ParseChannels(xmlNodePtr node, const t_transport_stream_id
flags = CZapitChannel::UPDATED; flags = CZapitChannel::UPDATED;
t_channel_id chid = CREATE_CHANNEL_ID64; t_channel_id chid = CREATE_CHANNEL_ID64;
char *ptr = xmlGetAttribute(node, "action"); const char *ptr = xmlGetAttribute(node, "action");
bool remove = ptr ? (!strcmp(ptr, "remove") || !strcmp(ptr, "replace")) : false; bool remove = ptr ? (!strcmp(ptr, "remove") || !strcmp(ptr, "replace")) : false;
bool add = ptr ? (!strcmp(ptr, "add") || !strcmp(ptr, "replace")) : true; bool add = ptr ? (!strcmp(ptr, "add") || !strcmp(ptr, "replace")) : true;
if (remove) { if (remove) {
@@ -541,12 +541,12 @@ void CServiceManager::FindTransponder(xmlNodePtr search)
std::string delivery_name = xmlGetName(search); std::string delivery_name = xmlGetName(search);
if (delivery_name == "cable") { if (delivery_name == "cable") {
char *name = xmlGetAttribute(search, "name"); const char *name = xmlGetAttribute(search, "name");
satellitePosition = GetSatellitePosition(name); satellitePosition = GetSatellitePosition(name);
delsys = ALL_CABLE; delsys = ALL_CABLE;
} }
else if (delivery_name == "terrestrial") { else if (delivery_name == "terrestrial") {
char *name = xmlGetAttribute(search, "name"); const char *name = xmlGetAttribute(search, "name");
satellitePosition = GetSatellitePosition(name); satellitePosition = GetSatellitePosition(name);
delsys = ALL_TERR; delsys = ALL_TERR;
} }
@@ -560,7 +560,7 @@ void CServiceManager::FindTransponder(xmlNodePtr search)
} }
#if 0 #if 0
//t_satellite_position satellitePosition = xmlGetSignedNumericAttribute(search, "position", 10); //t_satellite_position satellitePosition = xmlGetSignedNumericAttribute(search, "position", 10);
char * name = xmlGetAttribute(search, "name"); const char * name = xmlGetAttribute(search, "name");
t_satellite_position satellitePosition = GetSatellitePosition(name); t_satellite_position satellitePosition = GetSatellitePosition(name);
#endif #endif
DBG("going to parse dvb-%c provider %s\n", xmlGetName(search)[0], xmlGetAttribute(search, "name")); DBG("going to parse dvb-%c provider %s\n", xmlGetName(search)[0], xmlGetAttribute(search, "name"));
@@ -797,7 +797,7 @@ void CServiceManager::SaveMotorPositions()
} }
#endif #endif
bool CServiceManager::InitSatPosition(t_satellite_position position, char * name, bool force, delivery_system_t delsys, uint16_t nid) bool CServiceManager::InitSatPosition(t_satellite_position position, const char * name, bool force, delivery_system_t delsys, uint16_t nid)
{ {
if(force || (satellitePositions.find(position) == satellitePositions.end())) { if(force || (satellitePositions.find(position) == satellitePositions.end())) {
satellitePositions[position].position = position; satellitePositions[position].position = position;
@@ -833,15 +833,15 @@ bool CServiceManager::LoadScanXml(delivery_system_t delsys)
std::string delivery_name = xmlGetName(search); std::string delivery_name = xmlGetName(search);
if (delivery_name == "sat") { if (delivery_name == "sat") {
position = xmlGetSignedNumericAttribute(search, "position", 10); position = xmlGetSignedNumericAttribute(search, "position", 10);
char * name = xmlGetAttribute(search, "name"); const char * name = xmlGetAttribute(search, "name");
InitSatPosition(position, name, false, ALL_SAT); InitSatPosition(position, name, false, ALL_SAT);
} else if (delivery_name == "terrestrial") { } else if (delivery_name == "terrestrial") {
char * name = xmlGetAttribute(search, "name"); const char * name = xmlGetAttribute(search, "name");
position = fake_pos++; position = fake_pos++;
position &= 0x0EFF; position &= 0x0EFF;
InitSatPosition(position, name, false, ALL_TERR); InitSatPosition(position, name, false, ALL_TERR);
} else if(delivery_name == "cable") { } else if(delivery_name == "cable") {
char * name = xmlGetAttribute(search, "name"); const char * name = xmlGetAttribute(search, "name");
position = fake_pos++; position = fake_pos++;
InitSatPosition(position, name, false, ALL_CABLE, xmlGetNumericAttribute(search, "nid", 0)); InitSatPosition(position, name, false, ALL_CABLE, xmlGetNumericAttribute(search, "nid", 0));
} else { } else {
@@ -910,7 +910,7 @@ bool CServiceManager::LoadServices(bool only_current)
if (parser != NULL) { if (parser != NULL) {
xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode; xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode;
while (search) { while (search) {
char * name = xmlGetAttribute(search, "name"); const char * name = xmlGetAttribute(search, "name");
t_satellite_position position; t_satellite_position position;
std::string delivery_name = xmlGetName(search); std::string delivery_name = xmlGetName(search);
if (delivery_name == "sat") { if (delivery_name == "sat") {
@@ -947,9 +947,9 @@ bool CServiceManager::LoadServices(bool only_current)
xmlNodePtr l1 = l0->xmlChildrenNode; xmlNodePtr l1 = l0->xmlChildrenNode;
if (l1) { if (l1) {
while ((xmlGetNextOccurence(l1, "webtv"))) { while ((xmlGetNextOccurence(l1, "webtv"))) {
char *title = xmlGetAttribute(l1, "title"); const char *title = xmlGetAttribute(l1, "title");
char *url = xmlGetAttribute(l1, "url"); const char *url = xmlGetAttribute(l1, "url");
char *desc = xmlGetAttribute(l1, "description"); const char *desc = xmlGetAttribute(l1, "description");
if (title && url) { if (title && url) {
t_channel_id chid = create_channel_id64(0, 0, 0, 0, 0, url); t_channel_id chid = create_channel_id64(0, 0, 0, 0, 0, url);
CZapitChannel * channel = new CZapitChannel(title, chid, url, desc); CZapitChannel * channel = new CZapitChannel(title, chid, url, desc);
@@ -1299,8 +1299,8 @@ bool CServiceManager::LoadProviderMap()
replace.original_network_id = xmlGetNumericAttribute(node, "on", 16); replace.original_network_id = xmlGetNumericAttribute(node, "on", 16);
replace.frequency = xmlGetNumericAttribute(node, "frq", 0); replace.frequency = xmlGetNumericAttribute(node, "frq", 0);
char * name = xmlGetAttribute(node, "name"); const char * name = xmlGetAttribute(node, "name");
char * newname = xmlGetAttribute(node, "newname"); const char * newname = xmlGetAttribute(node, "newname");
if(name) if(name)
replace.name = name; replace.name = name;
if(newname) if(newname)