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

Function xmlParseChunk

ThirdParty/libxml2/vtklibxml2/parser.c:11599–11698  ·  view source on GitHub ↗

* xmlParseChunk: * @ctxt: an XML parser context * @chunk: chunk of memory * @size: size of chunk in bytes * @terminate: last chunk indicator * * Parse a chunk of memory in push parser mode. * * Assumes that the parser context was initialized with * xmlCreatePushParserCtxt. * * The last chunk, which will often be empty, must be marked with * the @terminate flag. With the default SAX

Source from the content-addressed store, hash-verified

11597 * Returns an xmlParserErrors code (0 on success).
11598 */
11599int
11600xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
11601 int terminate) {
11602 size_t curBase;
11603 size_t maxLength;
11604 int end_in_lf = 0;
11605
11606 if ((ctxt == NULL) || (size < 0))
11607 return(XML_ERR_ARGUMENT);
11608 if (ctxt->disableSAX != 0)
11609 return(ctxt->errNo);
11610 if (ctxt->input == NULL)
11611 return(XML_ERR_INTERNAL_ERROR);
11612
11613 ctxt->input->flags |= XML_INPUT_PROGRESSIVE;
11614 if (ctxt->instate == XML_PARSER_START)
11615 xmlCtxtInitializeLate(ctxt);
11616 if ((size > 0) && (chunk != NULL) && (!terminate) &&
11617 (chunk[size - 1] == '\r')) {
11618 end_in_lf = 1;
11619 size--;
11620 }
11621
11622 if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
11623 (ctxt->input->buf != NULL)) {
11624 size_t pos = ctxt->input->cur - ctxt->input->base;
11625 int res;
11626
11627 res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
11628 xmlBufUpdateInput(ctxt->input->buf->buffer, ctxt->input, pos);
11629 if (res < 0) {
11630 xmlCtxtErrIO(ctxt, ctxt->input->buf->error, NULL);
11631 xmlHaltParser(ctxt);
11632 return(ctxt->errNo);
11633 }
11634 }
11635
11636 xmlParseTryOrFinish(ctxt, terminate);
11637
11638 curBase = ctxt->input->cur - ctxt->input->base;
11639 maxLength = (ctxt->options & XML_PARSE_HUGE) ?
11640 XML_MAX_HUGE_LENGTH :
11641 XML_MAX_LOOKUP_LIMIT;
11642 if (curBase > maxLength) {
11643 xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT,
11644 "Buffer size limit exceeded, try XML_PARSE_HUGE\n");
11645 xmlHaltParser(ctxt);
11646 }
11647
11648 if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX != 0))
11649 return(ctxt->errNo);
11650
11651 if ((end_in_lf == 1) && (ctxt->input != NULL) &&
11652 (ctxt->input->buf != NULL)) {
11653 size_t pos = ctxt->input->cur - ctxt->input->base;
11654 int res;
11655
11656 res = xmlParserInputBufferPush(ctxt->input->buf, 1, "\r");

Callers 7

parseFileFunction · 0.85
xmlTextReaderPushDataFunction · 0.85
xmlTextReaderReadFunction · 0.85
pushParseTestFunction · 0.85
pushBoundaryTestFunction · 0.85

Calls 8

xmlCtxtInitializeLateFunction · 0.85
xmlParserInputBufferPushFunction · 0.85
xmlBufUpdateInputFunction · 0.85
xmlCtxtErrIOFunction · 0.85
xmlHaltParserFunction · 0.85
xmlFatalErrFunction · 0.85
xmlBufIsEmptyFunction · 0.85
xmlFinishDocumentFunction · 0.85

Tested by 2

pushParseTestFunction · 0.68
pushBoundaryTestFunction · 0.68