* htmlParseChunk: * @ctxt: an HTML 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 * htmlCreatePushParserCtxt. * * The last chunk, which will often be empty, must be marked with * the @terminate flag. With the default
| 5750 | * Returns an xmlParserErrors code (0 on success). |
| 5751 | */ |
| 5752 | int |
| 5753 | htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size, |
| 5754 | int terminate) { |
| 5755 | if ((ctxt == NULL) || (ctxt->input == NULL)) |
| 5756 | return(XML_ERR_ARGUMENT); |
| 5757 | if (PARSER_STOPPED(ctxt) != 0) |
| 5758 | return(ctxt->errNo); |
| 5759 | if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) && |
| 5760 | (ctxt->input->buf != NULL)) { |
| 5761 | size_t pos = ctxt->input->cur - ctxt->input->base; |
| 5762 | int res; |
| 5763 | |
| 5764 | res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk); |
| 5765 | xmlBufUpdateInput(ctxt->input->buf->buffer, ctxt->input, pos); |
| 5766 | if (res < 0) { |
| 5767 | htmlParseErr(ctxt, ctxt->input->buf->error, |
| 5768 | "xmlParserInputBufferPush failed", NULL, NULL); |
| 5769 | xmlHaltParser(ctxt); |
| 5770 | return (ctxt->errNo); |
| 5771 | } |
| 5772 | } |
| 5773 | htmlParseTryOrFinish(ctxt, terminate); |
| 5774 | if (terminate) { |
| 5775 | if (ctxt->instate != XML_PARSER_EOF) { |
| 5776 | if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) |
| 5777 | ctxt->sax->endDocument(ctxt->userData); |
| 5778 | } |
| 5779 | ctxt->instate = XML_PARSER_EOF; |
| 5780 | } |
| 5781 | return((xmlParserErrors) ctxt->errNo); |
| 5782 | } |
| 5783 | |
| 5784 | /************************************************************************ |
| 5785 | * * |