MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlOutputBufferWriteEscape

Function xmlOutputBufferWriteEscape

ThirdParty/libxml2/vtklibxml2/xmlIO.c:2615–2745  ·  view source on GitHub ↗

* xmlOutputBufferWriteEscape: * @out: a buffered parser output * @str: a zero terminated UTF-8 string * @escaping: an optional escaping function (or NULL) * * Write the content of the string in the output I/O buffer * This routine escapes the characters and then handle the I18N * transcoding from internal UTF-8 * The buffer is lossless, i.e. will store in case of partial * or delayed w

Source from the content-addressed store, hash-verified

2613 * in case of error.
2614 */
2615int
2616xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
2617 xmlCharEncodingOutputFunc escaping) {
2618 int nbchars = 0; /* number of chars to output to I/O */
2619 int ret; /* return from function call */
2620 int written = 0; /* number of char written to I/O so far */
2621 int oldwritten=0;/* loop guard */
2622 int chunk; /* number of byte currently processed from str */
2623 int len; /* number of bytes in str */
2624 int cons; /* byte from str consumed */
2625
2626 if ((out == NULL) || (out->error) || (str == NULL) ||
2627 (out->buffer == NULL))
2628 return(-1);
2629 len = strlen((const char *)str);
2630 if (len < 0) return(0);
2631 if (out->error) return(-1);
2632 if (escaping == NULL) escaping = xmlEscapeContent;
2633
2634 do {
2635 oldwritten = written;
2636
2637 /*
2638 * how many bytes to consume and how many bytes to store.
2639 */
2640 cons = len;
2641 chunk = xmlBufAvail(out->buffer);
2642
2643 /*
2644 * make sure we have enough room to save first, if this is
2645 * not the case force a flush, but make sure we stay in the loop
2646 */
2647 if (chunk < 40) {
2648 if (xmlBufGrow(out->buffer, 100) < 0) {
2649 out->error = XML_ERR_NO_MEMORY;
2650 return(-1);
2651 }
2652 oldwritten = -1;
2653 continue;
2654 }
2655
2656 /*
2657 * first handle encoding stuff.
2658 */
2659 if (out->encoder != NULL) {
2660 /*
2661 * Store the data in the incoming raw buffer
2662 */
2663 if (out->conv == NULL) {
2664 out->conv = xmlBufCreate();
2665 if (out->conv == NULL) {
2666 out->error = XML_ERR_NO_MEMORY;
2667 return(-1);
2668 }
2669 }
2670 ret = escaping(xmlBufEnd(out->buffer) ,
2671 &chunk, str, &cons);
2672 if (ret < 0) {

Callers 3

xhtmlNodeDumpOutputFunction · 0.85
xmlTextWriterWriteStringFunction · 0.85

Calls 10

xmlBufAvailFunction · 0.85
xmlBufGrowFunction · 0.85
xmlBufCreateFunction · 0.85
xmlBufEndFunction · 0.85
xmlBufAddLenFunction · 0.85
xmlBufUseFunction · 0.85
xmlCharEncOutputFunction · 0.85
xmlBufContentFunction · 0.85
xmlBufShrinkFunction · 0.85
xmlIOErrFunction · 0.85

Tested by

no test coverage detected