2 #include <libxml/tree.h>
3 #include <libxml/parser.h>
4 #include <libxml/parserInternals.h>
5 #include <libxml/catalog.h>
6 #include <libxml/threads.h>
7 #include <libxml/nanoftp.h>
8 #include <libxml/nanohttp.h>
9 #include <libxml/uri.h>
10 #include <libxml/xpath.h>
11 #include <libxml/xpathInternals.h>
12 #include <libxml/debugXML.h>
13 #include <libxml/HTMLparser.h>
14 #include <libxml/HTMLtree.h>
15 #include <libxml/xinclude.h>
16 #include <libxml/xpointer.h>
17 #include <libxml/xmlunicode.h>
18 #include <libxml/xmlregexp.h>
19 #include <libxml/xmlautomata.h>
20 #include <libxml/xmlreader.h>
21 #ifdef LIBXML_SCHEMAS_ENABLED
22 #include <libxml/relaxng.h>
23 #include <libxml/xmlschemas.h>
27 * for older versions of Python, we don't use PyBytes, but keep PyString
28 * and don't use Capsule but CObjects
30 #if PY_VERSION_HEX < 0x02070000
32 #define PyBytes_Check PyString_Check
33 #define PyBytes_Size PyString_Size
34 #define PyBytes_AsString PyString_AsString
35 #define PyBytes_AS_STRING PyString_AS_STRING
36 #define PyBytes_GET_SIZE PyString_GET_SIZE
39 #define PyCapsule_New PyCObject_FromVoidPtrAndDesc
40 #define PyCapsule_CheckExact PyCObject_Check
41 #define PyCapsule_GetPointer(o, n) PyCObject_GetDesc((o))
48 * Macro used to signal to GCC unused function parameters
49 * Repeated here since the definition is not available when
50 * compiled outside the libxml2 build tree.
53 #ifdef ATTRIBUTE_UNUSED
54 #undef ATTRIBUTE_UNUSED
56 #ifndef ATTRIBUTE_UNUSED
57 #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
58 #endif /* ATTRIBUTE_UNUSED */
60 #define ATTRIBUTE_UNUSED
63 #define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
64 (((PyxmlNode_Object *)(v))->obj))
71 #define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \
72 (((PyxmlXPathContext_Object *)(v))->obj))
76 xmlXPathContextPtr obj;
77 } PyxmlXPathContext_Object;
79 #define PyxmlXPathParserContext_Get(v) (((v) == Py_None) ? NULL : \
80 (((PyxmlXPathParserContext_Object *)(v))->obj))
84 xmlXPathParserContextPtr obj;
85 } PyxmlXPathParserContext_Object;
87 #define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \
88 (((PyparserCtxt_Object *)(v))->obj))
93 } PyparserCtxt_Object;
95 #define PyValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
96 (((PyValidCtxt_Object *)(v))->obj))
101 } PyValidCtxt_Object;
103 #define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \
104 (((Pycatalog_Object *)(v))->obj))
111 #ifdef LIBXML_REGEXP_ENABLED
112 #define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \
113 (((PyxmlReg_Object *)(v))->obj))
119 #endif /* LIBXML_REGEXP_ENABLED */
121 #ifdef LIBXML_READER_ENABLED
122 #define PyxmlTextReader_Get(v) (((v) == Py_None) ? NULL : \
123 (((PyxmlTextReader_Object *)(v))->obj))
127 xmlTextReaderPtr obj;
128 } PyxmlTextReader_Object;
130 #define PyxmlTextReaderLocator_Get(v) (((v) == Py_None) ? NULL : \
131 (((PyxmlTextReaderLocator_Object *)(v))->obj))
135 xmlTextReaderLocatorPtr obj;
136 } PyxmlTextReaderLocator_Object;
139 #define PyURI_Get(v) (((v) == Py_None) ? NULL : \
140 (((PyURI_Object *)(v))->obj))
147 #define PyError_Get(v) (((v) == Py_None) ? NULL : \
148 (((PyError_Object *)(v))->obj))
152 xmlOutputBufferPtr obj;
153 } PyoutputBuffer_Object;
155 #define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \
156 (((PyoutputBuffer_Object *)(v))->obj))
160 xmlParserInputBufferPtr obj;
161 } PyinputBuffer_Object;
163 #define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \
164 (((PyinputBuffer_Object *)(v))->obj))
171 /* FILE * have their own internal representation */
172 #if PY_MAJOR_VERSION >= 3
173 FILE *libxml_PyFileGet(PyObject *f);
174 void libxml_PyFileRelease(FILE *f);
175 #define PyFile_Get(v) (((v) == Py_None) ? NULL : libxml_PyFileGet(v))
176 #define PyFile_Release(f) libxml_PyFileRelease(f)
178 #define PyFile_Get(v) (((v) == Py_None) ? NULL : \
179 (PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
180 #define PyFile_Release(f)
183 #ifdef LIBXML_SCHEMAS_ENABLED
187 } PyrelaxNgSchema_Object;
189 #define PyrelaxNgSchema_Get(v) (((v) == Py_None) ? NULL : \
190 (((PyrelaxNgSchema_Object *)(v))->obj))
194 xmlRelaxNGParserCtxtPtr obj;
195 } PyrelaxNgParserCtxt_Object;
197 #define PyrelaxNgParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
198 (((PyrelaxNgParserCtxt_Object *)(v))->obj))
202 xmlRelaxNGValidCtxtPtr obj;
203 } PyrelaxNgValidCtxt_Object;
205 #define PyrelaxNgValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
206 (((PyrelaxNgValidCtxt_Object *)(v))->obj))
213 #define PySchema_Get(v) (((v) == Py_None) ? NULL : \
214 (((PySchema_Object *)(v))->obj))
218 xmlSchemaParserCtxtPtr obj;
219 } PySchemaParserCtxt_Object;
221 #define PySchemaParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
222 (((PySchemaParserCtxt_Object *)(v))->obj))
226 xmlSchemaValidCtxtPtr obj;
227 } PySchemaValidCtxt_Object;
229 #define PySchemaValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
230 (((PySchemaValidCtxt_Object *)(v))->obj))
232 #endif /* LIBXML_SCHEMAS_ENABLED */
234 PyObject * libxml_intWrap(int val);
235 PyObject * libxml_longWrap(long val);
236 PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
237 PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str);
238 PyObject * libxml_charPtrWrap(char *str);
239 PyObject * libxml_constcharPtrWrap(const char *str);
240 PyObject * libxml_charPtrConstWrap(const char *str);
241 PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str);
242 PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
243 PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
244 PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr);
245 PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns);
246 PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns);
247 PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns);
248 PyObject * libxml_doubleWrap(double val);
249 PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt);
250 PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt);
251 PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt);
252 PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj);
253 PyObject * libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid);
254 PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj);
255 PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri);
256 PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer);
257 PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer);
258 #ifdef LIBXML_REGEXP_ENABLED
259 PyObject * libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp);
260 #endif /* LIBXML_REGEXP_ENABLED */
261 #ifdef LIBXML_READER_ENABLED
262 PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
263 PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
266 xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);
267 #ifdef LIBXML_SCHEMAS_ENABLED
268 PyObject * libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt);
269 PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt);
270 PyObject * libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid);
271 PyObject * libxml_xmlSchemaPtrWrap(xmlSchemaPtr ctxt);
272 PyObject * libxml_xmlSchemaParserCtxtPtrWrap(xmlSchemaParserCtxtPtr ctxt);
273 PyObject * libxml_xmlSchemaValidCtxtPtrWrap(xmlSchemaValidCtxtPtr valid);
274 #endif /* LIBXML_SCHEMAS_ENABLED */
275 PyObject * libxml_xmlErrorPtrWrap(xmlErrorPtr error);
276 PyObject * libxml_xmlSchemaSetValidErrors(PyObject * self, PyObject * args);
277 PyObject * libxml_xmlRegisterInputCallback(PyObject *self, PyObject *args);
278 PyObject * libxml_xmlUnregisterInputCallback(PyObject *self, PyObject *args);
279 PyObject * libxml_xmlNodeRemoveNsDef(PyObject * self, PyObject * args);