X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_xml.c;h=e632a4ffdcddeab9ef273f517ec4f33457095c4e;hp=532d5ee068883f371ff47dc9a7dd931e8283f974;hb=123a1ba27ea09c8fa77a1b36ce625b43d7c48b14;hpb=d9557a9bea506fd8b40acd7a44a16b46e2a97848 diff --git a/palacios/src/palacios/vmm_xml.c b/palacios/src/palacios/vmm_xml.c index 532d5ee..e632a4f 100644 --- a/palacios/src/palacios/vmm_xml.c +++ b/palacios/src/palacios/vmm_xml.c @@ -112,12 +112,10 @@ struct v3_xml * v3_xml_child(struct v3_xml * xml, const char * name) { if (xml != NULL) { child = xml->child; - } + } - if (child != NULL) { - while (strcmp(name, child->name) != 0) { - child = child->sibling; - } + while ((child) && (strcasecmp(name, child->name) != 0)) { + child = child->sibling; } return child; @@ -143,7 +141,7 @@ const char * v3_xml_attr(struct v3_xml * xml, const char * attr) { return NULL; } - while ((xml->attr[i]) && (strcmp(attr, xml->attr[i]) != 0)) { + while ((xml->attr[i]) && (strcasecmp(attr, xml->attr[i]) != 0)) { i += 2; } @@ -157,14 +155,14 @@ const char * v3_xml_attr(struct v3_xml * xml, const char * attr) { for (i = 0; ( (root->attr[i] != NULL) && - (strcmp(xml->name, root->attr[i][0]) != 0) ); + (strcasecmp(xml->name, root->attr[i][0]) != 0) ); i++); if (! root->attr[i]) { return NULL; // no matching default attributes } - while ((root->attr[i][j] != NULL) && (strcmp(attr, root->attr[i][j]) != 0)) { + while ((root->attr[i][j] != NULL) && (strcasecmp(attr, root->attr[i][j]) != 0)) { j += 3; } @@ -356,7 +354,7 @@ static void v3_xml_char_content(struct v3_xml_root * root, char * s, size_t len, static int v3_xml_close_tag(struct v3_xml_root * root, char * name, char * s) { if ( (root->cur == NULL) || (root->cur->name == NULL) || - (strcmp(name, root->cur->name))) { + (strcasecmp(name, root->cur->name))) { v3_xml_err(root, s, "unexpected closing tag ", name); return -1; } @@ -484,7 +482,7 @@ static struct v3_xml * v3_xml_insert(struct v3_xml * xml, struct v3_xml * dest, // find tag type for (cur = head, prev = NULL; - ((cur) && (strcmp(cur->name, xml->name) != 0)); + ((cur) && (strcasecmp(cur->name, xml->name) != 0)); prev = cur, cur = cur->sibling); @@ -569,7 +567,7 @@ static void v3_xml_open_tag(struct v3_xml_root * root, char * name, char ** attr // parse the given xml string and return an v3_xml structure -struct v3_xml * v3_xml_parse_str(char * buf, size_t len) { +static struct v3_xml * parse_str(char * buf, size_t len) { struct v3_xml_root * root = (struct v3_xml_root *)v3_xml_new(NULL); char quote_char; char last_char; @@ -628,7 +626,7 @@ struct v3_xml * v3_xml_parse_str(char * buf, size_t len) { // find attributes for correct tag for ((i = 0); ((tmp_attr = root->attr[i]) && - (strcmp(tmp_attr[0], tag_ptr) != 0)); + (strcasecmp(tmp_attr[0], tag_ptr) != 0)); (i++)) ; // 'tmp_attr' now points to the attribute list associated with 'tag_ptr' @@ -700,7 +698,7 @@ struct v3_xml * v3_xml_parse_str(char * buf, size_t len) { for (j = 1; ( (tmp_attr) && (tmp_attr[j]) && - (strcmp(tmp_attr[j], attr[attr_idx]) != 0)); + (strcasecmp(tmp_attr[j], attr[attr_idx]) != 0)); j += 3); attr[val_idx] = v3_xml_decode(attr[val_idx], root->ent, @@ -825,7 +823,20 @@ struct v3_xml * v3_xml_parse_str(char * buf, size_t len) { } +struct v3_xml * v3_xml_parse(char * buf) { + int str_len = 0; + char * xml_buf = NULL; + + if (!buf) { + return NULL; + } + + str_len = strlen(buf); + xml_buf = (char *)V3_Malloc(str_len + 1); + strcpy(xml_buf, buf); + return parse_str(xml_buf, str_len); +} @@ -852,7 +863,7 @@ void v3_xml_free(struct v3_xml * xml) { } } - V3_Free(root->ent); // free list of general entities + V3_Free(root->ent); // free list of general entities for (i = 0; (a = root->attr[i]); i++) { for (j = 1; a[j++]; j += 2) { @@ -870,7 +881,6 @@ void v3_xml_free(struct v3_xml * xml) { } V3_Free(root->str_ptr); // malloced xml data - } v3_xml_free_attr(xml->attr); // tag attributes