comparison libpurple/xmlnode.c @ 20453:69febfa6d307

propagate from branch 'im.pidgin.pidgin' (head d3e5a5add3f39caa08b46c83177328e51c2d961a) to branch 'im.pidgin.cpw.khc.msnp14' (head a8f6c999b039b4097aa70cd8d2597f3127615435)
author Carlos Silva <typ0@pidgin.im>
date Sat, 16 Jun 2007 04:00:32 +0000
parents 3fc94e7c7056
children 6050348614ab
comparison
equal deleted inserted replaced
20452:5c34a0a3c362 20453:69febfa6d307
331 g_return_val_if_fail(node != NULL, NULL); 331 g_return_val_if_fail(node != NULL, NULL);
332 332
333 for(c = node->child; c; c = c->next) { 333 for(c = node->child; c; c = c->next) {
334 if(c->type == XMLNODE_TYPE_DATA) { 334 if(c->type == XMLNODE_TYPE_DATA) {
335 if(!str) 335 if(!str)
336 str = g_string_new(""); 336 str = g_string_new_len(c->data, c->data_sz);
337 str = g_string_append_len(str, c->data, c->data_sz); 337 else
338 str = g_string_append_len(str, c->data, c->data_sz);
338 } 339 }
339 } 340 }
340 341
341 if (str == NULL) 342 if (str == NULL)
342 return NULL; 343 return NULL;
343 344
344 return g_string_free(str, FALSE); 345 return g_string_free(str, FALSE);
346 }
347
348 char *
349 xmlnode_get_data_unescaped(xmlnode *node)
350 {
351 char *escaped = xmlnode_get_data(node);
352
353 char *unescaped = escaped ? purple_unescape_html(escaped) : NULL;
354
355 g_free(escaped);
356
357 return unescaped;
345 } 358 }
346 359
347 static char * 360 static char *
348 xmlnode_to_str_helper(xmlnode *node, int *len, gboolean formatting, int depth) 361 xmlnode_to_str_helper(xmlnode *node, int *len, gboolean formatting, int depth)
349 { 362 {
517 struct _xmlnode_parser_data *xpd = user_data; 530 struct _xmlnode_parser_data *xpd = user_data;
518 xpd->error = TRUE; 531 xpd->error = TRUE;
519 } 532 }
520 533
521 static xmlSAXHandler xmlnode_parser_libxml = { 534 static xmlSAXHandler xmlnode_parser_libxml = {
522 .internalSubset = NULL, 535 NULL, /* internalSubset */
523 .isStandalone = NULL, 536 NULL, /* isStandalone */
524 .hasInternalSubset = NULL, 537 NULL, /* hasInternalSubset */
525 .hasExternalSubset = NULL, 538 NULL, /* hasExternalSubset */
526 .resolveEntity = NULL, 539 NULL, /* resolveEntity */
527 .getEntity = NULL, 540 NULL, /* getEntity */
528 .entityDecl = NULL, 541 NULL, /* entityDecl */
529 .notationDecl = NULL, 542 NULL, /* notationDecl */
530 .attributeDecl = NULL, 543 NULL, /* attributeDecl */
531 .elementDecl = NULL, 544 NULL, /* elementDecl */
532 .unparsedEntityDecl = NULL, 545 NULL, /* unparsedEntityDecl */
533 .setDocumentLocator = NULL, 546 NULL, /* setDocumentLocator */
534 .startDocument = NULL, 547 NULL, /* startDocument */
535 .endDocument = NULL, 548 NULL, /* endDocument */
536 .startElement = NULL, 549 NULL, /* startElement */
537 .endElement = NULL, 550 NULL, /* endElement */
538 .reference = NULL, 551 NULL, /* reference */
539 .characters = xmlnode_parser_element_text_libxml, 552 xmlnode_parser_element_text_libxml, /* characters */
540 .ignorableWhitespace = NULL, 553 NULL, /* ignorableWhitespace */
541 .processingInstruction = NULL, 554 NULL, /* processingInstruction */
542 .comment = NULL, 555 NULL, /* comment */
543 .warning = NULL, 556 NULL, /* warning */
544 .error = xmlnode_parser_error_libxml, 557 xmlnode_parser_error_libxml, /* error */
545 .fatalError = NULL, 558 NULL, /* fatalError */
546 .getParameterEntity = NULL, 559 NULL, /* getParameterEntity */
547 .cdataBlock = NULL, 560 NULL, /* cdataBlock */
548 .externalSubset = NULL, 561 NULL, /* externalSubset */
549 .initialized = XML_SAX2_MAGIC, 562 XML_SAX2_MAGIC, /* initialized */
550 ._private = NULL, 563 NULL, /* _private */
551 .startElementNs = xmlnode_parser_element_start_libxml, 564 xmlnode_parser_element_start_libxml, /* startElementNs */
552 .endElementNs = xmlnode_parser_element_end_libxml, 565 xmlnode_parser_element_end_libxml, /* endElementNs */
553 .serror = NULL 566 NULL, /* serror */
554 }; 567 };
555 568
556 xmlnode * 569 xmlnode *
557 xmlnode_from_str(const char *str, gssize size) 570 xmlnode_from_str(const char *str, gssize size)
558 { 571 {