* xmlReaderForIO: * @ioread: an I/O read function * @ioclose: an I/O close function * @ioctx: an I/O handler * @URL: the base URL to use for the document * @encoding: the document encoding, or NULL * @options: a combination of xmlParserOption * * Create an xmltextReader for an XML document from I/O functions and source. * The parsing flags @options are a combination of xmlParserOpti
| 5266 | * Returns the new reader or NULL in case of error. |
| 5267 | */ |
| 5268 | xmlTextReaderPtr |
| 5269 | xmlReaderForIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, |
| 5270 | void *ioctx, const char *URL, const char *encoding, |
| 5271 | int options) |
| 5272 | { |
| 5273 | xmlTextReaderPtr reader; |
| 5274 | xmlParserInputBufferPtr input; |
| 5275 | |
| 5276 | if (ioread == NULL) |
| 5277 | return (NULL); |
| 5278 | |
| 5279 | input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, |
| 5280 | XML_CHAR_ENCODING_NONE); |
| 5281 | if (input == NULL) { |
| 5282 | if (ioclose != NULL) |
| 5283 | ioclose(ioctx); |
| 5284 | return (NULL); |
| 5285 | } |
| 5286 | reader = xmlNewTextReader(input, URL); |
| 5287 | if (reader == NULL) { |
| 5288 | xmlFreeParserInputBuffer(input); |
| 5289 | return (NULL); |
| 5290 | } |
| 5291 | reader->allocs |= XML_TEXTREADER_INPUT; |
| 5292 | if (xmlTextReaderSetup(reader, NULL, URL, encoding, options) < 0) { |
| 5293 | xmlFreeTextReader(reader); |
| 5294 | return (NULL); |
| 5295 | } |
| 5296 | return (reader); |
| 5297 | } |
| 5298 | |
| 5299 | /** |
| 5300 | * xmlReaderNewWalker: |
nothing calls this directly
no test coverage detected