MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / htmlCreateDocParserCtxt

Function htmlCreateDocParserCtxt

Externals/LibXML/HTMLparser.c:4407–4453  ·  view source on GitHub ↗

* htmlCreateDocParserCtxt: * @cur: a pointer to an array of xmlChar * @encoding: a free form C string describing the HTML document encoding, or NULL * * Create a parser context for an HTML document. * * TODO: check the need to add encoding handling there * * Returns the new parser context or NULL */

Source from the content-addressed store, hash-verified

4405 * Returns the new parser context or NULL
4406 */
4407static htmlParserCtxtPtr
4408htmlCreateDocParserCtxt(const xmlChar *cur, const char *encoding) {
4409 int len;
4410 htmlParserCtxtPtr ctxt;
4411
4412 if (cur == NULL)
4413 return(NULL);
4414 len = xmlStrlen(cur);
4415 ctxt = htmlCreateMemoryParserCtxt((char *)cur, len);
4416 if (ctxt == NULL)
4417 return(NULL);
4418
4419 if (encoding != NULL) {
4420 xmlCharEncoding enc;
4421 xmlCharEncodingHandlerPtr handler;
4422
4423 if (ctxt->input->encoding != NULL)
4424 xmlFree((xmlChar *) ctxt->input->encoding);
4425 ctxt->input->encoding = xmlStrdup((const xmlChar *) encoding);
4426
4427 enc = xmlParseCharEncoding(encoding);
4428 /*
4429 * registered set of known encodings
4430 */
4431 if (enc != XML_CHAR_ENCODING_ERROR) {
4432 xmlSwitchEncoding(ctxt, enc);
4433 if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
4434 htmlParseErr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
4435 "Unsupported encoding %s\n",
4436 (const xmlChar *) encoding, NULL);
4437 }
4438 } else {
4439 /*
4440 * fallback for unknown encodings
4441 */
4442 handler = xmlFindCharEncodingHandler((const char *) encoding);
4443 if (handler != NULL) {
4444 xmlSwitchToEncoding(ctxt, handler);
4445 } else {
4446 htmlParseErr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
4447 "Unsupported encoding %s\n",
4448 (const xmlChar *) encoding, NULL);
4449 }
4450 }
4451 }
4452 return(ctxt);
4453}
4454
4455#ifdef LIBXML_PUSH_ENABLED
4456/************************************************************************

Callers 2

htmlSAXParseDocFunction · 0.85
htmlReadDocFunction · 0.85

Calls 8

xmlStrlenFunction · 0.85
xmlStrdupFunction · 0.85
xmlParseCharEncodingFunction · 0.85
xmlSwitchEncodingFunction · 0.85
htmlParseErrFunction · 0.85
xmlSwitchToEncodingFunction · 0.85

Tested by

no test coverage detected