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

Function xmlCharEncOutFunc

ThirdParty/libxml2/vtklibxml2/encoding.c:2557–2641  ·  view source on GitHub ↗

* xmlCharEncOutFunc: * @handler: char encoding transformation data structure * @out: an xmlBuffer for the output. * @in: an xmlBuffer for the input * * Generic front-end for the encoding handler output function * a first call with @in == NULL has to be made firs to initiate the * output in case of non-stateless encoding needing to initiate their * state or the output (like the BOM in UTF

Source from the content-addressed store, hash-verified

2555 * Returns the number of bytes written or an XML_ENC_ERR code.
2556 */
2557int
2558xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
2559 xmlBufferPtr in) {
2560 int ret;
2561 int written;
2562 int writtentot = 0;
2563 int toconv;
2564
2565 if (handler == NULL) return(XML_ENC_ERR_INTERNAL);
2566 if (out == NULL) return(XML_ENC_ERR_INTERNAL);
2567
2568retry:
2569
2570 written = out->size - out->use;
2571
2572 if (written > 0)
2573 written--; /* Gennady: count '/0' */
2574
2575 /*
2576 * First specific handling of in = NULL, i.e. the initialization call
2577 */
2578 if (in == NULL) {
2579 toconv = 0;
2580 /* TODO: Check return value. */
2581 xmlEncOutputChunk(handler, &out->content[out->use], &written,
2582 NULL, &toconv);
2583 out->use += written;
2584 out->content[out->use] = 0;
2585 return(0);
2586 }
2587
2588 /*
2589 * Conversion itself.
2590 */
2591 toconv = in->use;
2592 if (toconv * 4 >= written) {
2593 xmlBufferGrow(out, toconv * 4);
2594 written = out->size - out->use - 1;
2595 }
2596 ret = xmlEncOutputChunk(handler, &out->content[out->use], &written,
2597 in->content, &toconv);
2598 xmlBufferShrink(in, toconv);
2599 out->use += written;
2600 writtentot += written;
2601 out->content[out->use] = 0;
2602
2603 if (ret == XML_ENC_ERR_SPACE)
2604 goto retry;
2605
2606 /*
2607 * Attempt to handle error cases
2608 */
2609 if (ret == XML_ENC_ERR_INPUT) {
2610 xmlChar charref[20];
2611 int len = in->use;
2612 const xmlChar *utf = (const xmlChar *) in->content;
2613 int cur, charrefLen;
2614

Callers

nothing calls this directly

Calls 4

xmlEncOutputChunkFunction · 0.85
xmlBufferGrowFunction · 0.85
xmlBufferShrinkFunction · 0.85
xmlGetUTF8CharFunction · 0.85

Tested by

no test coverage detected