MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / htmlDocDumpMemoryFormat

Function htmlDocDumpMemoryFormat

Externals/LibXML/HTMLtree.c:518–587  ·  view source on GitHub ↗

* htmlDocDumpMemoryFormat: * @cur: the document * @mem: OUT: the memory pointer * @size: OUT: the memory length * @format: should formatting spaces been added * * Dump an HTML document in memory and return the xmlChar * and it's size. * It's up to the caller to free the memory. */

Source from the content-addressed store, hash-verified

516 * It's up to the caller to free the memory.
517 */
518void
519htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
520 xmlOutputBufferPtr buf;
521 xmlCharEncodingHandlerPtr handler = NULL;
522 const char *encoding;
523
524 xmlInitParser();
525
526 if ((mem == NULL) || (size == NULL))
527 return;
528 if (cur == NULL) {
529 *mem = NULL;
530 *size = 0;
531 return;
532 }
533
534 encoding = (const char *) htmlGetMetaEncoding(cur);
535
536 if (encoding != NULL) {
537 xmlCharEncoding enc;
538
539 enc = xmlParseCharEncoding(encoding);
540 if (enc != cur->charset) {
541 if (cur->charset != XML_CHAR_ENCODING_UTF8) {
542 /*
543 * Not supported yet
544 */
545 *mem = NULL;
546 *size = 0;
547 return;
548 }
549
550 handler = xmlFindCharEncodingHandler(encoding);
551 if (handler == NULL) {
552 *mem = NULL;
553 *size = 0;
554 return;
555 }
556 } else {
557 handler = xmlFindCharEncodingHandler(encoding);
558 }
559 }
560
561 /*
562 * Fallback to HTML or ASCII when the encoding is unspecified
563 */
564 if (handler == NULL)
565 handler = xmlFindCharEncodingHandler("HTML");
566 if (handler == NULL)
567 handler = xmlFindCharEncodingHandler("ascii");
568
569 buf = xmlAllocOutputBuffer(handler);
570 if (buf == NULL) {
571 *mem = NULL;
572 *size = 0;
573 return;
574 }
575

Callers 2

htmlDocDumpMemoryFunction · 0.85

Calls 8

htmlGetMetaEncodingFunction · 0.85
xmlParseCharEncodingFunction · 0.85
xmlAllocOutputBufferFunction · 0.85
xmlOutputBufferFlushFunction · 0.85
xmlStrndupFunction · 0.85
xmlOutputBufferCloseFunction · 0.85

Tested by 1