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;
return NULL;
}
- while ((xml->attr[i]) && (strcmp(attr, xml->attr[i]) != 0)) {
+ while ((xml->attr[i]) && (strcasecmp(attr, xml->attr[i]) != 0)) {
i += 2;
}
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;
}
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 </%s>", name);
return -1;
}
return 0;
}
+#if 0
// checks for circular entity references, returns non-zero if no circular
// references are found, zero otherwise
static int v3_xml_ent_ok(char * name, char * s, char ** ent) {
}
}
}
+#endif
// 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);
// 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;
// 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'
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,
}
+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