* xmlReaderForFd: * @fd: an open file descriptor * @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 from a file descriptor. * The parsing flags @options are a combination of xmlParserOption. * NOTE that the file descriptor will not be closed when the * reader
| 5226 | * Returns the new reader or NULL in case of error. |
| 5227 | */ |
| 5228 | xmlTextReaderPtr |
| 5229 | xmlReaderForFd(int fd, const char *URL, const char *encoding, int options) |
| 5230 | { |
| 5231 | xmlTextReaderPtr reader; |
| 5232 | xmlParserInputBufferPtr input; |
| 5233 | |
| 5234 | if (fd < 0) |
| 5235 | return (NULL); |
| 5236 | |
| 5237 | input = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE); |
| 5238 | if (input == NULL) |
| 5239 | return (NULL); |
| 5240 | input->closecallback = NULL; |
| 5241 | reader = xmlNewTextReader(input, URL); |
| 5242 | if (reader == NULL) { |
| 5243 | xmlFreeParserInputBuffer(input); |
| 5244 | return (NULL); |
| 5245 | } |
| 5246 | reader->allocs |= XML_TEXTREADER_INPUT; |
| 5247 | if (xmlTextReaderSetup(reader, NULL, URL, encoding, options) < 0) { |
| 5248 | xmlFreeTextReader(reader); |
| 5249 | return (NULL); |
| 5250 | } |
| 5251 | return (reader); |
| 5252 | } |
| 5253 | |
| 5254 | /** |
| 5255 | * xmlReaderForIO: |
no test coverage detected