summaryrefslogtreecommitdiffstats
path: root/common/eurephia_xml.c
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2009-03-29 00:07:45 +0100
committerDavid Sommerseth <dazo@users.sourceforge.net>2009-03-29 00:07:45 +0100
commitbf152fe270a195bddb14010662995560e1edb481 (patch)
tree09e3b2937775153cb988beebebb175d028064e7b /common/eurephia_xml.c
parent5f208d0f6c0281569f14299965beff12807272c6 (diff)
downloadeurephia-bf152fe270a195bddb14010662995560e1edb481.tar.gz
eurephia-bf152fe270a195bddb14010662995560e1edb481.tar.xz
eurephia-bf152fe270a195bddb14010662995560e1edb481.zip
Fixed some possible issues with the XML implementation, regarding UTF-8
Do proper conversion from char * to xmlChar *. Need to figure out a better way how to return xmlChar * to char * when returning strings which may contain UTF-8.
Diffstat (limited to 'common/eurephia_xml.c')
-rw-r--r--common/eurephia_xml.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/common/eurephia_xml.c b/common/eurephia_xml.c
index 7e6baf8..fe09bde 100644
--- a/common/eurephia_xml.c
+++ b/common/eurephia_xml.c
@@ -30,26 +30,40 @@
char *xmlGetAttrValue(xmlAttr *attr, const char *key) {
xmlAttr *aptr;
+ xmlChar *x_key = NULL;
+
+ x_key = xmlCharStrdup(key);
+ assert( x_key != NULL );
for( aptr = attr; aptr != NULL; aptr = aptr->next ) {
- if( xmlStrcmp(aptr->name, (xmlChar *)key) == 0 ) {
+ if( xmlStrcmp(aptr->name, x_key) == 0 ) {
+ // FIXME: Should find a better way to return UTF-8 data
+ free_nullsafe(x_key);
return (char *)(aptr->children != NULL ? aptr->children->content : NULL);
}
}
+ free_nullsafe(x_key);
return NULL;
}
xmlNode *xmlFindNode(xmlNode *node, const char *key) {
xmlNode *nptr = NULL;
+ xmlChar *x_key = NULL;
if( node->children == NULL ) {
return NULL;
}
+
+ x_key = xmlCharStrdup(key);
+ assert( x_key != NULL );
+
for( nptr = node->children; nptr != NULL; nptr = nptr->next ) {
- if( xmlStrcmp(nptr->name, (xmlChar *)key) == 0 ) {
+ if( xmlStrcmp(nptr->name, x_key) == 0 ) {
+ free_nullsafe(x_key);
return nptr;
}
}
+ free_nullsafe(x_key);
return NULL;
}
@@ -103,6 +117,7 @@ xmlNode *eurephiaXML_getRoot(eurephiaCTX *ctx, xmlDoc *doc, const char *nodeset,
inline char *xmlExtractContent(xmlNode *n) {
+ // FIXME: Should find better way how to return UTF-8 data
return (char *) (((n != NULL) && (n->children != NULL)) ? n->children->content : NULL);
}