// 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
// 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;
}
+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);
+}
}
}
- 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) {
}
V3_Free(root->str_ptr); // malloced xml data
-
}
v3_xml_free_attr(xml->attr); // tag attributes