From: Jack Lange Date: Tue, 17 Nov 2009 23:17:22 +0000 (-0600) Subject: interface updates X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=fe36af6238917000f4cc8b971829e347732df598 interface updates --- diff --git a/palacios/include/palacios/vmm_xml.h b/palacios/include/palacios/vmm_xml.h index fc2c8d6..f45f804 100644 --- a/palacios/include/palacios/vmm_xml.h +++ b/palacios/include/palacios/vmm_xml.h @@ -50,7 +50,7 @@ struct v3_xml { // structure. For efficiency, modifies the data by adding null terminators // and decoding ampersand sequences. If you don't want this, copy the data and // pass in the copy. Returns NULL on failure. -struct v3_xml * v3_xml_parse_str(char * s, size_t len); +struct v3_xml * v3_xml_parse(char * buf); // returns the name of the given tag diff --git a/palacios/src/palacios/vmm_xml.c b/palacios/src/palacios/vmm_xml.c index 532d5ee..2201ad9 100644 --- a/palacios/src/palacios/vmm_xml.c +++ b/palacios/src/palacios/vmm_xml.c @@ -569,7 +569,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; @@ -825,7 +825,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 +865,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 +883,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