* xmlSAXUserParseFile: * @sax: a SAX handler * @user_data: The user data returned on SAX callbacks * @filename: a file name * * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadFile. * * parse an XML file and call the given SAX handler routines. * Automatic support for ZLIB/Compress compressed document is provided * * Returns 0 in case of success or a error number otherwise */
| 12986 | * Returns 0 in case of success or a error number otherwise |
| 12987 | */ |
| 12988 | int |
| 12989 | xmlSAXUserParseFile(xmlSAXHandlerPtr sax, void *user_data, |
| 12990 | const char *filename) { |
| 12991 | int ret = 0; |
| 12992 | xmlParserCtxtPtr ctxt; |
| 12993 | |
| 12994 | ctxt = xmlCreateFileParserCtxt(filename); |
| 12995 | if (ctxt == NULL) return -1; |
| 12996 | if (sax != NULL) { |
| 12997 | if (sax->initialized == XML_SAX2_MAGIC) { |
| 12998 | *ctxt->sax = *sax; |
| 12999 | } else { |
| 13000 | memset(ctxt->sax, 0, sizeof(*ctxt->sax)); |
| 13001 | memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1)); |
| 13002 | } |
| 13003 | ctxt->userData = user_data; |
| 13004 | } |
| 13005 | |
| 13006 | xmlParseDocument(ctxt); |
| 13007 | |
| 13008 | if (ctxt->wellFormed) |
| 13009 | ret = 0; |
| 13010 | else { |
| 13011 | if (ctxt->errNo != 0) |
| 13012 | ret = ctxt->errNo; |
| 13013 | else |
| 13014 | ret = -1; |
| 13015 | } |
| 13016 | if (ctxt->myDoc != NULL) { |
| 13017 | xmlFreeDoc(ctxt->myDoc); |
| 13018 | ctxt->myDoc = NULL; |
| 13019 | } |
| 13020 | xmlFreeParserCtxt(ctxt); |
| 13021 | |
| 13022 | return ret; |
| 13023 | } |
| 13024 | #endif /* LIBXML_SAX1_ENABLED */ |
| 13025 | |
| 13026 | /************************************************************************ |
nothing calls this directly
no test coverage detected