* xmlSAXUserParseMemory: * @sax: a SAX handler * @user_data: The user data returned on SAX callbacks * @buffer: an in-memory XML document input * @size: the length of the XML document in bytes * * DEPRECATED: Use xmlNewSAXParserCtxt and xmlCtxtReadMemory. * * parse an XML in-memory buffer and call the given SAX handler routines. * * Returns 0 in case of success or a error number othe
| 13184 | * Returns 0 in case of success or a error number otherwise |
| 13185 | */ |
| 13186 | int xmlSAXUserParseMemory(xmlSAXHandlerPtr sax, void *user_data, |
| 13187 | const char *buffer, int size) { |
| 13188 | int ret = 0; |
| 13189 | xmlParserCtxtPtr ctxt; |
| 13190 | |
| 13191 | ctxt = xmlCreateMemoryParserCtxt(buffer, size); |
| 13192 | if (ctxt == NULL) return -1; |
| 13193 | if (sax != NULL) { |
| 13194 | if (sax->initialized == XML_SAX2_MAGIC) { |
| 13195 | *ctxt->sax = *sax; |
| 13196 | } else { |
| 13197 | memset(ctxt->sax, 0, sizeof(*ctxt->sax)); |
| 13198 | memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1)); |
| 13199 | } |
| 13200 | ctxt->userData = user_data; |
| 13201 | } |
| 13202 | |
| 13203 | xmlParseDocument(ctxt); |
| 13204 | |
| 13205 | if (ctxt->wellFormed) |
| 13206 | ret = 0; |
| 13207 | else { |
| 13208 | if (ctxt->errNo != 0) |
| 13209 | ret = ctxt->errNo; |
| 13210 | else |
| 13211 | ret = -1; |
| 13212 | } |
| 13213 | if (ctxt->myDoc != NULL) { |
| 13214 | xmlFreeDoc(ctxt->myDoc); |
| 13215 | ctxt->myDoc = NULL; |
| 13216 | } |
| 13217 | xmlFreeParserCtxt(ctxt); |
| 13218 | |
| 13219 | return ret; |
| 13220 | } |
| 13221 | #endif /* LIBXML_SAX1_ENABLED */ |
| 13222 | |
| 13223 | /** |
nothing calls this directly
no test coverage detected