diff src/xmlnode.c @ 8262:b5dbd1839716

[gaim-migrate @ 8985] this is jabber new-style file transfer receive support. this doesn't do much error checking or handling, but I managed to send pictures to myself from Exodus on my laptop in the living room, which would have taken twice as long were it not for VNC. i said i was going to bed 1, 2, and 3 hours ago. i should go to bed. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 15 Feb 2004 10:11:38 +0000
parents b55b70aef314
children 35f69749b226
line wrap: on
line diff
--- a/src/xmlnode.c	Sun Feb 15 08:51:32 2004 +0000
+++ b/src/xmlnode.c	Sun Feb 15 10:11:38 2004 +0000
@@ -183,7 +183,7 @@
 }
 
 xmlnode*
-xmlnode_get_child(xmlnode *parent, const char *name)
+xmlnode_get_child_with_namespace(xmlnode *parent, const char *name, const char *ns)
 {
 	xmlnode *x, *ret = NULL;
 	char **names;
@@ -196,19 +196,30 @@
 	child_name = names[1];
 
 	for(x = parent->child; x; x = x->next) {
-		if(x->type == XMLNODE_TYPE_TAG && name && !strcmp(parent_name, x->name)) {
+		const char *xmlns = NULL;
+		if(ns)
+			xmlns = xmlnode_get_attrib(x, "xmlns");
+
+		if(x->type == XMLNODE_TYPE_TAG && name && !strcmp(parent_name, x->name)
+				&& (!ns || (xmlns && !strcmp(ns, xmlns)))) {
 			ret = x;
 			break;
 		}
 	}
 
 	if(child_name && ret)
-		ret = xmlnode_get_child(x, child_name);
+		ret = xmlnode_get_child(ret, child_name);
 
 	g_strfreev(names);
 	return ret;
 }
 
+xmlnode*
+xmlnode_get_child(xmlnode *parent, const char *name)
+{
+	return xmlnode_get_child_with_namespace(parent, name, NULL);
+}
+
 char *
 xmlnode_get_data(xmlnode *node)
 {
@@ -416,12 +427,18 @@
 
 xmlnode *xmlnode_get_next_twin(xmlnode *node) {
 	xmlnode *sibling;
+	const char *ns = xmlnode_get_attrib(node, "xmlns");
 
 	g_return_val_if_fail(node != NULL, NULL);
 	g_return_val_if_fail(node->type == XMLNODE_TYPE_TAG, NULL);
 
 	for(sibling = node->next; sibling; sibling = sibling->next) {
-		if(sibling->type == XMLNODE_TYPE_TAG && !strcmp(node->name, sibling->name))
+		const char *xmlns;
+		if(ns)
+			xmlns = xmlnode_get_attrib(sibling, "xmlns");
+
+		if(sibling->type == XMLNODE_TYPE_TAG && !strcmp(node->name, sibling->name) &&
+				(!ns || (xmlns && !strcmp(ns, xmlns))))
 			return sibling;
 	}