comparison libgaim/xmlnode.c @ 15176:50f263712df1

[gaim-migrate @ 17963] Rename namespace to xmlns because namespace is a reserved word in C++ committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 11 Dec 2006 19:44:35 +0000
parents c6978ee9ac4d
children f814b2df9cce
comparison
equal deleted inserted replaced
15175:bbeb1dfcb25b 15176:50f263712df1
179 179
180 void xmlnode_set_namespace(xmlnode *node, const char *xmlns) 180 void xmlnode_set_namespace(xmlnode *node, const char *xmlns)
181 { 181 {
182 g_return_if_fail(node != NULL); 182 g_return_if_fail(node != NULL);
183 183
184 g_free(node->namespace); 184 g_free(node->xmlns);
185 node->namespace = g_strdup(xmlns); 185 node->xmlns = g_strdup(xmlns);
186 } 186 }
187 187
188 const char *xmlnode_get_namespace(xmlnode *node) 188 const char *xmlnode_get_namespace(xmlnode *node)
189 { 189 {
190 g_return_val_if_fail(node != NULL, NULL); 190 g_return_val_if_fail(node != NULL, NULL);
191 191
192 return node->namespace; 192 return node->xmlns;
193 } 193 }
194 194
195 void 195 void
196 xmlnode_free(xmlnode *node) 196 xmlnode_free(xmlnode *node)
197 { 197 {
206 x = y; 206 x = y;
207 } 207 }
208 208
209 g_free(node->name); 209 g_free(node->name);
210 g_free(node->data); 210 g_free(node->data);
211 g_free(node->namespace); 211 g_free(node->xmlns);
212 212
213 GAIM_DBUS_UNREGISTER_POINTER(node); 213 GAIM_DBUS_UNREGISTER_POINTER(node);
214 g_free(node); 214 g_free(node);
215 } 215 }
216 216
291 } 291 }
292 292
293 node_name = g_markup_escape_text(node->name, -1); 293 node_name = g_markup_escape_text(node->name, -1);
294 g_string_append_printf(text, "<%s", node_name); 294 g_string_append_printf(text, "<%s", node_name);
295 295
296 if (node->namespace) { 296 if (node->xmlns) {
297 if(!node->parent || !node->parent->namespace || strcmp(node->namespace, node->parent->namespace)) 297 if(!node->parent || !node->parent->xmlns || strcmp(node->xmlns, node->parent->xmlns))
298 { 298 {
299 char *namespace = g_markup_escape_text(node->namespace, -1); 299 char *xmlns = g_markup_escape_text(node->xmlns, -1);
300 g_string_append_printf(text, " xmlns='%s'", namespace); 300 g_string_append_printf(text, " xmlns='%s'", xmlns);
301 g_free(namespace); 301 g_free(xmlns);
302 } 302 }
303 } 303 }
304 for(c = node->child; c; c = c->next) 304 for(c = node->child; c; c = c->next)
305 { 305 {
306 if(c->type == XMLNODE_TYPE_ATTRIB) { 306 if(c->type == XMLNODE_TYPE_ATTRIB) {
375 xmlnode *current; 375 xmlnode *current;
376 }; 376 };
377 377
378 static void 378 static void
379 xmlnode_parser_element_start_libxml(void *user_data, 379 xmlnode_parser_element_start_libxml(void *user_data,
380 const xmlChar *element_name, const xmlChar *prefix, const xmlChar *namespace, 380 const xmlChar *element_name, const xmlChar *prefix, const xmlChar *xmlns,
381 int nb_namespaces, const xmlChar **namespaces, 381 int nb_namespaces, const xmlChar **namespaces,
382 int nb_attributes, int nb_defaulted, const xmlChar **attributes) 382 int nb_attributes, int nb_defaulted, const xmlChar **attributes)
383 { 383 {
384 struct _xmlnode_parser_data *xpd = user_data; 384 struct _xmlnode_parser_data *xpd = user_data;
385 xmlnode *node; 385 xmlnode *node;
391 if(xpd->current) 391 if(xpd->current)
392 node = xmlnode_new_child(xpd->current, (const char*) element_name); 392 node = xmlnode_new_child(xpd->current, (const char*) element_name);
393 else 393 else
394 node = xmlnode_new((const char *) element_name); 394 node = xmlnode_new((const char *) element_name);
395 395
396 xmlnode_set_namespace(node, (const char *) namespace); 396 xmlnode_set_namespace(node, (const char *) xmlns);
397 397
398 for(i=0; i < nb_attributes * 5; i+=5) { 398 for(i=0; i < nb_attributes * 5; i+=5) {
399 char *txt; 399 char *txt;
400 int attrib_len = attributes[i+4] - attributes[i+3]; 400 int attrib_len = attributes[i+4] - attributes[i+3];
401 char *attrib = g_malloc(attrib_len + 1); 401 char *attrib = g_malloc(attrib_len + 1);
412 } 412 }
413 } 413 }
414 414
415 static void 415 static void
416 xmlnode_parser_element_end_libxml(void *user_data, const xmlChar *element_name, 416 xmlnode_parser_element_end_libxml(void *user_data, const xmlChar *element_name,
417 const xmlChar *prefix, const xmlChar *namespace) 417 const xmlChar *prefix, const xmlChar *xmlns)
418 { 418 {
419 struct _xmlnode_parser_data *xpd = user_data; 419 struct _xmlnode_parser_data *xpd = user_data;
420 420
421 if(!element_name || !xpd->current) 421 if(!element_name || !xpd->current)
422 return; 422 return;