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

Function xmllintExternalEntityLoader

ThirdParty/libxml2/vtklibxml2/xmllint.c:229–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227static xmlExternalEntityLoader defaultEntityLoader = NULL;
228
229static xmlParserInputPtr
230xmllintExternalEntityLoader(const char *URL, const char *ID,
231 xmlParserCtxtPtr ctxt) {
232 xmlParserInputPtr ret;
233 warningSAXFunc warning = NULL;
234 errorSAXFunc err = NULL;
235
236 int i;
237 const char *lastsegment = URL;
238 const char *iter = URL;
239
240 if ((nbpaths > 0) && (iter != NULL)) {
241 while (*iter != 0) {
242 if (*iter == '/')
243 lastsegment = iter + 1;
244 iter++;
245 }
246 }
247
248 if ((ctxt != NULL) && (ctxt->sax != NULL)) {
249 warning = ctxt->sax->warning;
250 err = ctxt->sax->error;
251 ctxt->sax->warning = NULL;
252 ctxt->sax->error = NULL;
253 }
254
255 if (defaultEntityLoader != NULL) {
256 ret = defaultEntityLoader(URL, ID, ctxt);
257 if (ret != NULL) {
258 if (warning != NULL)
259 ctxt->sax->warning = warning;
260 if (err != NULL)
261 ctxt->sax->error = err;
262 if (load_trace) {
263 fprintf \
264 (ERR_STREAM,
265 "Loaded URL=\"%s\" ID=\"%s\"\n",
266 URL ? URL : "(null)",
267 ID ? ID : "(null)");
268 }
269 return(ret);
270 }
271 }
272 for (i = 0;i < nbpaths;i++) {
273 xmlChar *newURL;
274
275 newURL = xmlStrdup((const xmlChar *) paths[i]);
276 newURL = xmlStrcat(newURL, (const xmlChar *) "/");
277 newURL = xmlStrcat(newURL, (const xmlChar *) lastsegment);
278 if (newURL != NULL) {
279 ret = defaultEntityLoader((const char *)newURL, ID, ctxt);
280 if (ret != NULL) {
281 if (warning != NULL)
282 ctxt->sax->warning = warning;
283 if (err != NULL)
284 ctxt->sax->error = err;
285 if (load_trace) {
286 fprintf \

Callers

nothing calls this directly

Calls 3

fprintfFunction · 0.85
xmlStrdupFunction · 0.85
xmlStrcatFunction · 0.85

Tested by

no test coverage detected