Mercurial > pidgin.yaz
comparison libpurple/xmlnode.c @ 20332:3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
through 525a410c03e7e16535f3fe683f9651283109265d
applied changes from 525a410c03e7e16535f3fe683f9651283109265d
through d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Fri, 19 Oct 2007 18:27:12 +0000 |
| parents | 6b8bc3309ab7 |
| children | b93e7be3847b |
comparison
equal
deleted
inserted
replaced
| 20331:233c423d40d3 | 20332:3a9709bfde65 |
|---|---|
| 144 } | 144 } |
| 145 sibling = attr_node; | 145 sibling = attr_node; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 /* Compare two nullable xmlns strings. | |
| 150 * They are considered equal if they're both NULL or the strings are equal | |
| 151 */ | |
| 152 static gboolean _xmlnode_compare_xmlns(const char *xmlns1, const char *xmlns2) { | |
| 153 gboolean equal = FALSE; | |
| 154 | |
| 155 if (xmlns1 == NULL && xmlns2 == NULL) | |
| 156 equal = TRUE; | |
| 157 else if (xmlns1 != NULL && xmlns2 != NULL && !strcmp(xmlns1, xmlns2)) | |
| 158 equal = TRUE; | |
| 159 | |
| 160 return equal; | |
| 161 } | |
| 149 | 162 |
| 150 void | 163 void |
| 151 xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) | 164 xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns) |
| 152 { | 165 { |
| 153 xmlnode *attr_node, *sibling = NULL; | 166 xmlnode *attr_node, *sibling = NULL; |
| 157 | 170 |
| 158 for(attr_node = node->child; attr_node; attr_node = attr_node->next) | 171 for(attr_node = node->child; attr_node; attr_node = attr_node->next) |
| 159 { | 172 { |
| 160 if(attr_node->type == XMLNODE_TYPE_ATTRIB && | 173 if(attr_node->type == XMLNODE_TYPE_ATTRIB && |
| 161 !strcmp(attr_node->name, attr) && | 174 !strcmp(attr_node->name, attr) && |
| 162 !strcmp(attr_node->xmlns, xmlns)) | 175 _xmlnode_compare_xmlns(xmlns, attr_node->xmlns)) |
| 163 { | 176 { |
| 164 if(node->child == attr_node) { | 177 if(node->child == attr_node) { |
| 165 node->child = attr_node->next; | 178 node->child = attr_node->next; |
| 166 } else { | 179 } else { |
| 167 sibling->next = attr_node->next; | 180 sibling->next = attr_node->next; |
| 236 | 249 |
| 237 g_return_val_if_fail(node != NULL, NULL); | 250 g_return_val_if_fail(node != NULL, NULL); |
| 238 | 251 |
| 239 for(x = node->child; x; x = x->next) { | 252 for(x = node->child; x; x = x->next) { |
| 240 if(x->type == XMLNODE_TYPE_ATTRIB && | 253 if(x->type == XMLNODE_TYPE_ATTRIB && |
| 241 !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) { | 254 !strcmp(attr, x->name) && |
| 255 _xmlnode_compare_xmlns(xmlns, x->xmlns)) { | |
| 242 return x->data; | 256 return x->data; |
| 243 } | 257 } |
| 244 } | 258 } |
| 245 | 259 |
| 246 return NULL; | 260 return NULL; |
| 324 names = g_strsplit(name, "/", 2); | 338 names = g_strsplit(name, "/", 2); |
| 325 parent_name = names[0]; | 339 parent_name = names[0]; |
| 326 child_name = names[1]; | 340 child_name = names[1]; |
| 327 | 341 |
| 328 for(x = parent->child; x; x = x->next) { | 342 for(x = parent->child; x; x = x->next) { |
| 343 /* XXX: Is it correct to ignore the namespace for the match if none was specified? */ | |
| 329 const char *xmlns = NULL; | 344 const char *xmlns = NULL; |
| 330 if(ns) | 345 if(ns) |
| 331 xmlns = xmlnode_get_namespace(x); | 346 xmlns = xmlnode_get_namespace(x); |
| 332 | 347 |
| 333 if(x->type == XMLNODE_TYPE_TAG && name && !strcmp(parent_name, x->name) | 348 if(x->type == XMLNODE_TYPE_TAG && name && !strcmp(parent_name, x->name) |
| 671 | 686 |
| 672 g_return_val_if_fail(node != NULL, NULL); | 687 g_return_val_if_fail(node != NULL, NULL); |
| 673 g_return_val_if_fail(node->type == XMLNODE_TYPE_TAG, NULL); | 688 g_return_val_if_fail(node->type == XMLNODE_TYPE_TAG, NULL); |
| 674 | 689 |
| 675 for(sibling = node->next; sibling; sibling = sibling->next) { | 690 for(sibling = node->next; sibling; sibling = sibling->next) { |
| 691 /* XXX: Is it correct to ignore the namespace for the match if none was specified? */ | |
| 676 const char *xmlns = NULL; | 692 const char *xmlns = NULL; |
| 677 if(ns) | 693 if(ns) |
| 678 xmlns = xmlnode_get_namespace(sibling); | 694 xmlns = xmlnode_get_namespace(sibling); |
| 679 | 695 |
| 680 if(sibling->type == XMLNODE_TYPE_TAG && !strcmp(node->name, sibling->name) && | 696 if(sibling->type == XMLNODE_TYPE_TAG && !strcmp(node->name, sibling->name) && |
