mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-31 06:50:06 +03:00
parser: Add more parser context accessors
This commit is contained in:
parent
8b1f79cea0
commit
cc0cc2d3b7
@ -339,7 +339,7 @@ struct _xmlParserCtxt {
|
||||
/* set line number in element content */
|
||||
int linenumbers XML_DEPRECATED_MEMBER;
|
||||
/* document's own catalog */
|
||||
void *catalogs;
|
||||
void *catalogs XML_DEPRECATED_MEMBER;
|
||||
/* run in recovery mode */
|
||||
int recovery XML_DEPRECATED_MEMBER;
|
||||
/* unused */
|
||||
@ -1334,10 +1334,6 @@ XMLPUBFUN void
|
||||
xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
|
||||
XMLPUBFUN xmlExternalEntityLoader
|
||||
xmlGetExternalEntityLoader(void);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetResourceLoader(xmlParserCtxtPtr ctxt,
|
||||
xmlResourceLoader loader,
|
||||
void *vctxt);
|
||||
XMLPUBFUN xmlParserInputPtr
|
||||
xmlLoadExternalEntity (const char *URL,
|
||||
const char *ID,
|
||||
@ -1398,14 +1394,29 @@ XMLPUBFUN int
|
||||
int size,
|
||||
const char *filename,
|
||||
const char *encoding);
|
||||
XMLPUBFUN int
|
||||
xmlCtxtGetOptions (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int
|
||||
xmlCtxtSetOptions (xmlParserCtxtPtr ctxt,
|
||||
int options);
|
||||
XMLPUBFUN int
|
||||
xmlCtxtGetOptions (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int
|
||||
xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
|
||||
int options);
|
||||
XMLPUBFUN void *
|
||||
xmlCtxtGetPrivate (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetPrivate (xmlParserCtxtPtr ctxt,
|
||||
void *priv);
|
||||
XMLPUBFUN void *
|
||||
xmlCtxtGetCatalogs (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetCatalogs (xmlParserCtxtPtr ctxt,
|
||||
void *catalogs);
|
||||
XMLPUBFUN xmlDictPtr
|
||||
xmlCtxtGetDict (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetDict (xmlParserCtxtPtr ctxt,
|
||||
xmlDictPtr);
|
||||
XMLPUBFUN const xmlChar *
|
||||
xmlCtxtGetVersion (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN const xmlChar *
|
||||
@ -1416,6 +1427,10 @@ XMLPUBFUN void
|
||||
xmlCtxtSetErrorHandler (xmlParserCtxtPtr ctxt,
|
||||
xmlStructuredErrorFunc handler,
|
||||
void *data);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetResourceLoader(xmlParserCtxtPtr ctxt,
|
||||
xmlResourceLoader loader,
|
||||
void *vctxt);
|
||||
XMLPUBFUN void
|
||||
xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,
|
||||
unsigned maxAmpl);
|
||||
|
@ -2873,6 +2873,98 @@ xmlNewSAXParserCtxt(const xmlSAXHandler *sax, void *userData)
|
||||
return(ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCtxtGetPrivate:
|
||||
* ctxt: parser context
|
||||
*
|
||||
* Returns the private application data.
|
||||
*/
|
||||
void *
|
||||
xmlCtxtGetPrivate(xmlParserCtxtPtr ctxt) {
|
||||
if (ctxt == NULL)
|
||||
return(NULL);
|
||||
|
||||
return(ctxt->_private);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCtxtSetPrivate:
|
||||
* ctxt: parser context
|
||||
* priv: private application data
|
||||
*
|
||||
* Set the private application data.
|
||||
*/
|
||||
void
|
||||
xmlCtxtSetPrivate(xmlParserCtxtPtr ctxt, void *priv) {
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
|
||||
ctxt->_private = priv;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCtxtGetCatalogs:
|
||||
* ctxt: parser context
|
||||
*
|
||||
* Returns the local catalogs.
|
||||
*/
|
||||
void *
|
||||
xmlCtxtGetCatalogs(xmlParserCtxtPtr ctxt) {
|
||||
if (ctxt == NULL)
|
||||
return(NULL);
|
||||
|
||||
return(ctxt->catalogs);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCtxtSetCatalogs:
|
||||
* ctxt: parser context
|
||||
* catalogs: catalogs pointer
|
||||
*
|
||||
* Set the local catalogs.
|
||||
*/
|
||||
void
|
||||
xmlCtxtSetCatalogs(xmlParserCtxtPtr ctxt, void *catalogs) {
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
|
||||
ctxt->catalogs = catalogs;
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCtxtGetDict:
|
||||
* ctxt: parser context
|
||||
*
|
||||
* Returns the dictionary.
|
||||
*/
|
||||
xmlDictPtr
|
||||
xmlCtxtGetDict(xmlParserCtxtPtr ctxt) {
|
||||
if (ctxt == NULL)
|
||||
return(NULL);
|
||||
|
||||
return(ctxt->dict);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCtxtSetDict:
|
||||
* ctxt: parser context
|
||||
* dict: dictionary
|
||||
*
|
||||
* Set the dictionary. This should only be done immediately after
|
||||
* creating a parser context.
|
||||
*/
|
||||
void
|
||||
xmlCtxtSetDict(xmlParserCtxtPtr ctxt, xmlDictPtr dict) {
|
||||
if (ctxt == NULL)
|
||||
return;
|
||||
|
||||
if (ctxt->dict != NULL)
|
||||
xmlDictFree(ctxt->dict);
|
||||
|
||||
xmlDictReference(dict);
|
||||
ctxt->dict = dict;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Handling of node information *
|
||||
|
@ -2867,7 +2867,8 @@ libxml_addLocalCatalog(ATTRIBUTE_UNUSED PyObject * self, PyObject * args)
|
||||
ctxt = (xmlParserCtxtPtr) PyparserCtxt_Get(pyobj_ctxt);
|
||||
|
||||
if (URL != NULL) {
|
||||
ctxt->catalogs = xmlCatalogAddLocal(ctxt->catalogs, URL);
|
||||
void *catalogs = xmlCtxtGetCatalogs(ctxt);
|
||||
xmlCtxtSetCatalogs(ctxt, xmlCatalogAddLocal(catalogs, URL));
|
||||
}
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
|
Loading…
x
Reference in New Issue
Block a user