mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
reader: Add callbacks for resource loader
This commit is contained in:
parent
fa2592b384
commit
fd7d9e5eca
@ -426,6 +426,11 @@ XMLPUBFUN void
|
|||||||
xmlTextReaderErrorFunc *f,
|
xmlTextReaderErrorFunc *f,
|
||||||
void **arg);
|
void **arg);
|
||||||
|
|
||||||
|
XMLPUBFUN void
|
||||||
|
xmlTextReaderSetResourceLoader(xmlTextReaderPtr reader,
|
||||||
|
xmlResourceLoader loader,
|
||||||
|
void *data);
|
||||||
|
|
||||||
#endif /* LIBXML_READER_ENABLED */
|
#endif /* LIBXML_READER_ENABLED */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
64
xmlreader.c
64
xmlreader.c
@ -156,6 +156,9 @@ struct _xmlTextReader {
|
|||||||
int parserFlags; /* the set of options set */
|
int parserFlags; /* the set of options set */
|
||||||
/* Structured error handling */
|
/* Structured error handling */
|
||||||
xmlStructuredErrorFunc sErrorFunc; /* callback function */
|
xmlStructuredErrorFunc sErrorFunc; /* callback function */
|
||||||
|
|
||||||
|
xmlResourceLoader resourceLoader;
|
||||||
|
void *resourceCtxt;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NODE_IS_EMPTY 0x1
|
#define NODE_IS_EMPTY 0x1
|
||||||
@ -1446,6 +1449,9 @@ node_found:
|
|||||||
if ((reader->errorFunc != NULL) || (reader->sErrorFunc != NULL))
|
if ((reader->errorFunc != NULL) || (reader->sErrorFunc != NULL))
|
||||||
xmlXIncludeSetErrorHandler(reader->xincctxt,
|
xmlXIncludeSetErrorHandler(reader->xincctxt,
|
||||||
xmlTextReaderStructuredRelay, reader);
|
xmlTextReaderStructuredRelay, reader);
|
||||||
|
if (reader->resourceLoader != NULL)
|
||||||
|
xmlXIncludeSetResourceLoader(reader->xincctxt,
|
||||||
|
reader->resourceLoader, reader->resourceCtxt);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* expand that node and process it
|
* expand that node and process it
|
||||||
@ -4783,6 +4789,47 @@ xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlTextReaderGetErrorHandler:
|
||||||
|
* @reader: the xmlTextReaderPtr used
|
||||||
|
* @f: the callback function or NULL is no callback has been registered
|
||||||
|
* @arg: a user argument
|
||||||
|
*
|
||||||
|
* Retrieve the error callback function and user argument.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
|
||||||
|
xmlTextReaderErrorFunc * f, void **arg)
|
||||||
|
{
|
||||||
|
if (f != NULL)
|
||||||
|
*f = reader->errorFunc;
|
||||||
|
if (arg != NULL)
|
||||||
|
*arg = reader->errorFuncArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlTextReaderSetResourceLoader:
|
||||||
|
* @reader: thr reader
|
||||||
|
* @loader: resource loader
|
||||||
|
* @data: user data which will be passed to the loader
|
||||||
|
*
|
||||||
|
* Register a callback function that will be called to load external
|
||||||
|
* resources like entities.
|
||||||
|
*
|
||||||
|
* Available since 2.14.0.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlTextReaderSetResourceLoader(xmlTextReaderPtr reader,
|
||||||
|
xmlResourceLoader loader, void *data) {
|
||||||
|
if ((reader == NULL) || (reader->ctxt == NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
reader->resourceLoader = loader;
|
||||||
|
reader->resourceCtxt = data;
|
||||||
|
|
||||||
|
xmlCtxtSetResourceLoader(reader->ctxt, loader, data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlTextReaderIsValid:
|
* xmlTextReaderIsValid:
|
||||||
* @reader: the xmlTextReaderPtr used
|
* @reader: the xmlTextReaderPtr used
|
||||||
@ -4807,23 +4854,6 @@ xmlTextReaderIsValid(xmlTextReaderPtr reader)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlTextReaderGetErrorHandler:
|
|
||||||
* @reader: the xmlTextReaderPtr used
|
|
||||||
* @f: the callback function or NULL is no callback has been registered
|
|
||||||
* @arg: a user argument
|
|
||||||
*
|
|
||||||
* Retrieve the error callback function and user argument.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
|
|
||||||
xmlTextReaderErrorFunc * f, void **arg)
|
|
||||||
{
|
|
||||||
if (f != NULL)
|
|
||||||
*f = reader->errorFunc;
|
|
||||||
if (arg != NULL)
|
|
||||||
*arg = reader->errorFuncArg;
|
|
||||||
}
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* New set (2.6.0) of simpler and more flexible APIs *
|
* New set (2.6.0) of simpler and more flexible APIs *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user