* xmlNewInputInternal: * @ctxt: parser context * @buf: parser input buffer * @filename: filename or URL * @encoding: character encoding (optional) * * Internal helper function. * * Returns a new parser input. */
| 1590 | * Returns a new parser input. |
| 1591 | */ |
| 1592 | static xmlParserInputPtr |
| 1593 | xmlNewInputInternal(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr buf, |
| 1594 | const char *filename, const char *encoding) { |
| 1595 | xmlParserInputPtr input; |
| 1596 | |
| 1597 | input = xmlNewInputStream(ctxt); |
| 1598 | if (input == NULL) { |
| 1599 | xmlFreeParserInputBuffer(buf); |
| 1600 | return(NULL); |
| 1601 | } |
| 1602 | |
| 1603 | input->buf = buf; |
| 1604 | xmlBufResetInput(input->buf->buffer, input); |
| 1605 | |
| 1606 | if (filename != NULL) { |
| 1607 | input->filename = xmlMemStrdup(filename); |
| 1608 | if (input->filename == NULL) { |
| 1609 | xmlCtxtErrMemory(ctxt); |
| 1610 | xmlFreeInputStream(input); |
| 1611 | return(NULL); |
| 1612 | } |
| 1613 | } |
| 1614 | |
| 1615 | if (encoding != NULL) |
| 1616 | xmlSwitchInputEncodingName(ctxt, input, encoding); |
| 1617 | |
| 1618 | return(input); |
| 1619 | } |
| 1620 | |
| 1621 | /** |
| 1622 | * xmlNewInputMemory: |
no test coverage detected