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

Function xmlOutputBufferWrite

ThirdParty/libxml2/vtklibxml2/xmlIO.c:2440–2538  ·  view source on GitHub ↗

* xmlOutputBufferWrite: * @out: a buffered parser output * @len: the size in bytes of the array. * @buf: an char array * * Write the content of the array in the output I/O buffer * This routine handle the I18N transcoding from internal UTF-8 * The buffer is lossless, i.e. will store in case of partial * or delayed writes. * * Returns the number of chars immediately written, or -1 *

Source from the content-addressed store, hash-verified

2438 * in case of error.
2439 */
2440int
2441xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
2442 int nbchars = 0; /* number of chars to output to I/O */
2443 int ret; /* return from function call */
2444 int written = 0; /* number of char written to I/O so far */
2445 int chunk; /* number of byte current processed from buf */
2446
2447 if ((out == NULL) || (out->error)) return(-1);
2448 if (len < 0) return(0);
2449 if (out->error) return(-1);
2450
2451 do {
2452 chunk = len;
2453 if (chunk > 4 * MINLEN)
2454 chunk = 4 * MINLEN;
2455
2456 /*
2457 * first handle encoding stuff.
2458 */
2459 if (out->encoder != NULL) {
2460 /*
2461 * Store the data in the incoming raw buffer
2462 */
2463 if (out->conv == NULL) {
2464 out->conv = xmlBufCreate();
2465 if (out->conv == NULL) {
2466 out->error = XML_ERR_NO_MEMORY;
2467 return(-1);
2468 }
2469 }
2470 ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
2471 if (ret != 0) {
2472 out->error = XML_ERR_NO_MEMORY;
2473 return(-1);
2474 }
2475
2476 if ((xmlBufUse(out->buffer) < MINLEN) && (chunk == len))
2477 goto done;
2478
2479 /*
2480 * convert as much as possible to the parser reading buffer.
2481 */
2482 ret = xmlCharEncOutput(out, 0);
2483 if (ret < 0)
2484 return(-1);
2485 if (out->writecallback)
2486 nbchars = xmlBufUse(out->conv);
2487 else
2488 nbchars = ret >= 0 ? ret : 0;
2489 } else {
2490 ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
2491 if (ret != 0) {
2492 out->error = XML_ERR_NO_MEMORY;
2493 return(-1);
2494 }
2495 if (out->writecallback)
2496 nbchars = xmlBufUse(out->buffer);
2497 else

Callers 15

doXPathDumpFunction · 0.85
xmlAttrSerializeContentFunction · 0.85
xmlBufDumpNotationDeclFunction · 0.85
xmlBufDumpElementOccurFunction · 0.85
xmlBufDumpElementContentFunction · 0.85
xmlBufDumpElementDeclFunction · 0.85
xmlBufDumpEnumerationFunction · 0.85
xmlBufDumpAttributeDeclFunction · 0.85
xmlBufDumpEntityContentFunction · 0.85
xmlBufDumpEntityDeclFunction · 0.85
xmlNsDumpOutputFunction · 0.85

Calls 7

xmlBufCreateFunction · 0.85
xmlBufAddFunction · 0.85
xmlBufUseFunction · 0.85
xmlCharEncOutputFunction · 0.85
xmlBufContentFunction · 0.85
xmlBufShrinkFunction · 0.85
xmlIOErrFunction · 0.85

Tested by

no test coverage detected