| 11819 | */ |
| 11820 | |
| 11821 | xmlDtdPtr |
| 11822 | xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input, |
| 11823 | xmlCharEncoding enc) { |
| 11824 | xmlDtdPtr ret = NULL; |
| 11825 | xmlParserCtxtPtr ctxt; |
| 11826 | xmlParserInputPtr pinput = NULL; |
| 11827 | |
| 11828 | if (input == NULL) |
| 11829 | return(NULL); |
| 11830 | |
| 11831 | ctxt = xmlNewSAXParserCtxt(sax, NULL); |
| 11832 | if (ctxt == NULL) { |
| 11833 | xmlFreeParserInputBuffer(input); |
| 11834 | return(NULL); |
| 11835 | } |
| 11836 | xmlCtxtSetOptions(ctxt, XML_PARSE_DTDLOAD); |
| 11837 | |
| 11838 | /* |
| 11839 | * generate a parser input from the I/O handler |
| 11840 | */ |
| 11841 | |
| 11842 | pinput = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE); |
| 11843 | if (pinput == NULL) { |
| 11844 | xmlFreeParserInputBuffer(input); |
| 11845 | xmlFreeParserCtxt(ctxt); |
| 11846 | return(NULL); |
| 11847 | } |
| 11848 | |
| 11849 | /* |
| 11850 | * plug some encoding conversion routines here. |
| 11851 | */ |
| 11852 | if (xmlPushInput(ctxt, pinput) < 0) { |
| 11853 | xmlFreeParserCtxt(ctxt); |
| 11854 | return(NULL); |
| 11855 | } |
| 11856 | if (enc != XML_CHAR_ENCODING_NONE) { |
| 11857 | xmlSwitchEncoding(ctxt, enc); |
| 11858 | } |
| 11859 | |
| 11860 | /* |
| 11861 | * let's parse that entity knowing it's an external subset. |
| 11862 | */ |
| 11863 | ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0"); |
| 11864 | if (ctxt->myDoc == NULL) { |
| 11865 | xmlErrMemory(ctxt); |
| 11866 | return(NULL); |
| 11867 | } |
| 11868 | ctxt->myDoc->properties = XML_DOC_INTERNAL; |
| 11869 | ctxt->myDoc->extSubset = xmlNewDtd(ctxt->myDoc, BAD_CAST "none", |
| 11870 | BAD_CAST "none", BAD_CAST "none"); |
| 11871 | |
| 11872 | xmlParseExternalSubset(ctxt, BAD_CAST "none", BAD_CAST "none"); |
| 11873 | |
| 11874 | if (ctxt->myDoc != NULL) { |
| 11875 | if (ctxt->wellFormed) { |
| 11876 | ret = ctxt->myDoc->extSubset; |
| 11877 | ctxt->myDoc->extSubset = NULL; |
| 11878 | if (ret != NULL) { |
nothing calls this directly
no test coverage detected