MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlSAX2ResolveEntity

Function xmlSAX2ResolveEntity

ThirdParty/libxml2/vtklibxml2/SAX2.c:402–445  ·  view source on GitHub ↗

* xmlSAX2ResolveEntity: * @ctx: the user data (XML parser context) * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * The entity loader, to control the loading of external entities, * the application can either: * - override this xmlSAX2ResolveEntity() callback in the SAX block * - or better use the xmlSetExternalEntityLoader() function to * s

Source from the content-addressed store, hash-verified

400 * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
401 */
402xmlParserInputPtr
403xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
404{
405 xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
406 xmlParserInputPtr ret = NULL;
407 xmlChar *URI;
408 const xmlChar *base = NULL;
409 int res;
410
411 if (ctx == NULL) return(NULL);
412 if (ctxt->input != NULL)
413 base = BAD_CAST ctxt->input->filename;
414
415 /*
416 * We don't really need the 'directory' struct member, but some
417 * users set it manually to a base URI for memory streams.
418 */
419 if (base == NULL)
420 base = BAD_CAST ctxt->directory;
421
422 if ((xmlStrlen(systemId) > XML_MAX_URI_LENGTH) ||
423 (xmlStrlen(base) > XML_MAX_URI_LENGTH)) {
424 xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
425 return(NULL);
426 }
427 res = xmlBuildURISafe(systemId, base, &URI);
428 if (URI == NULL) {
429 if (res < 0)
430 xmlSAX2ErrMemory(ctxt);
431 else
432 xmlWarnMsg(ctxt, XML_ERR_INVALID_URI,
433 "Can't resolve URI: %s\n", systemId);
434 return(NULL);
435 }
436 if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) {
437 xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
438 } else {
439 ret = xmlLoadExternalEntity((const char *) URI,
440 (const char *) publicId, ctxt);
441 }
442
443 xmlFree(URI);
444 return(ret);
445}
446
447/**
448 * xmlSAX2GetEntity:

Callers 1

resolveEntityFunction · 0.85

Calls 5

xmlStrlenFunction · 0.85
xmlFatalErrFunction · 0.85
xmlBuildURISafeFunction · 0.85
xmlSAX2ErrMemoryFunction · 0.85
xmlLoadExternalEntityFunction · 0.85

Tested by

no test coverage detected