* xmlNewInputPush: * @ctxt: parser context * @url: base URL (optional) * @chunk: pointer to char array * @size: size of array * @encoding: character encoding (optional) * * Creates a new parser input for a push parser. * * Returns a new parser input. */
| 1794 | * Returns a new parser input. |
| 1795 | */ |
| 1796 | xmlParserInputPtr |
| 1797 | xmlNewInputPush(xmlParserCtxtPtr ctxt, const char *url, |
| 1798 | const char *chunk, int size, const char *encoding) { |
| 1799 | xmlParserInputBufferPtr buf; |
| 1800 | xmlParserInputPtr input; |
| 1801 | |
| 1802 | buf = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE); |
| 1803 | if (buf == NULL) { |
| 1804 | xmlCtxtErrMemory(ctxt); |
| 1805 | return(NULL); |
| 1806 | } |
| 1807 | |
| 1808 | input = xmlNewInputInternal(ctxt, buf, url, encoding); |
| 1809 | if (input == NULL) |
| 1810 | return(NULL); |
| 1811 | |
| 1812 | input->flags |= XML_INPUT_PROGRESSIVE; |
| 1813 | |
| 1814 | if ((size > 0) && (chunk != NULL)) { |
| 1815 | int res; |
| 1816 | |
| 1817 | res = xmlParserInputBufferPush(input->buf, size, chunk); |
| 1818 | xmlBufResetInput(input->buf->buffer, input); |
| 1819 | if (res < 0) { |
| 1820 | xmlCtxtErrIO(ctxt, input->buf->error, NULL); |
| 1821 | xmlFreeInputStream(input); |
| 1822 | return(NULL); |
| 1823 | } |
| 1824 | } |
| 1825 | |
| 1826 | return(input); |
| 1827 | } |
| 1828 | |
| 1829 | /** |
| 1830 | * xmlNewIOInputStream: |
no test coverage detected