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

Function xmlLoadEntityContent

ThirdParty/libxml2/vtklibxml2/parser.c:7914–8033  ·  view source on GitHub ↗

* xmlLoadEntityContent: * @ctxt: an XML parser context * @entity: an unloaded system entity * * Load the original content of the given system entity from the * ExternalID/SystemID given. This is to be used for Included in Literal * http://www.w3.org/TR/REC-xml/#inliteral processing of entities references * * Returns 0 in case of success and -1 in case of failure */

Source from the content-addressed store, hash-verified

7912 * Returns 0 in case of success and -1 in case of failure
7913 */
7914static int
7915xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
7916 xmlParserInputPtr oldinput, input = NULL;
7917 xmlParserInputPtr *oldinputTab;
7918 const xmlChar *oldencoding;
7919 xmlChar *content = NULL;
7920 size_t length, i;
7921 int oldinputNr, oldinputMax;
7922 int ret = -1;
7923 int res;
7924
7925 if ((ctxt == NULL) || (entity == NULL) ||
7926 ((entity->etype != XML_EXTERNAL_PARAMETER_ENTITY) &&
7927 (entity->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY)) ||
7928 (entity->content != NULL)) {
7929 xmlFatalErr(ctxt, XML_ERR_ARGUMENT,
7930 "xmlLoadEntityContent parameter error");
7931 return(-1);
7932 }
7933
7934 input = xmlLoadExternalEntity((char *) entity->URI,
7935 (char *) entity->ExternalID, ctxt);
7936 if (input == NULL)
7937 return(-1);
7938
7939 oldinput = ctxt->input;
7940 oldinputNr = ctxt->inputNr;
7941 oldinputMax = ctxt->inputMax;
7942 oldinputTab = ctxt->inputTab;
7943 oldencoding = ctxt->encoding;
7944
7945 ctxt->input = NULL;
7946 ctxt->inputNr = 0;
7947 ctxt->inputMax = 1;
7948 ctxt->encoding = NULL;
7949 ctxt->inputTab = xmlMalloc(sizeof(xmlParserInputPtr));
7950 if (ctxt->inputTab == NULL) {
7951 xmlErrMemory(ctxt);
7952 xmlFreeInputStream(input);
7953 goto error;
7954 }
7955
7956 xmlBufResetInput(input->buf->buffer, input);
7957
7958 inputPush(ctxt, input);
7959
7960 xmlDetectEncoding(ctxt);
7961
7962 /*
7963 * Parse a possible text declaration first
7964 */
7965 if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
7966 xmlParseTextDecl(ctxt);
7967 /*
7968 * An XML-1.0 document can't reference an entity not XML-1.0
7969 */
7970 if ((xmlStrEqual(ctxt->version, BAD_CAST "1.0")) &&
7971 (!xmlStrEqual(ctxt->input->version, BAD_CAST "1.0"))) {

Callers 1

Calls 15

xmlFatalErrFunction · 0.85
xmlLoadExternalEntityFunction · 0.85
xmlErrMemoryFunction · 0.85
xmlFreeInputStreamFunction · 0.85
xmlBufResetInputFunction · 0.85
inputPushFunction · 0.85
xmlDetectEncodingFunction · 0.85
xmlParseTextDeclFunction · 0.85
xmlStrEqualFunction · 0.85
xmlBufShrinkFunction · 0.85
xmlParserInputBufferGrowFunction · 0.85
xmlCtxtErrIOFunction · 0.85

Tested by

no test coverage detected