blob: 09fc77fe06f43ebbf8564efd086c7a3381831f5a [file] [log] [blame]
Daniel Veillard3ce52572002-02-03 15:08:05 +00001#include <Python.h>
Daniel Veillardd2897fd2002-01-30 16:37:32 +00002#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>
Daniel Veillard96fe0952002-01-30 20:52:23 +000013#include <libxml/HTMLparser.h>
14#include <libxml/HTMLtree.h>
15#include <libxml/xinclude.h>
Daniel Veillard1971ee22002-01-31 20:29:19 +000016#include <libxml/xpointer.h>
Daniel Veillardbd9afb52002-09-25 22:25:35 +000017#include <libxml/xmlunicode.h>
18#include <libxml/xmlregexp.h>
19#include <libxml/xmlautomata.h>
Daniel Veillard0eb38c72002-12-14 23:00:35 +000020#include <libxml/xmlreader.h>
Daniel Veillard71531f32003-02-05 13:19:53 +000021#include <libxml/relaxng.h>
Daniel Veillard0eb38c72002-12-14 23:00:35 +000022
23/**
24 * ATTRIBUTE_UNUSED:
25 *
26 * Macro used to signal to GCC unused function parameters
27 * Repeated here since the definition is not available when
28 * compiled outside the libxml2 build tree.
29 */
30#ifdef __GNUC__
31#ifdef ATTRIBUTE_UNUSED
32#undef ATTRIBUTE_UNUSED
33#endif
Daniel Veillard0eb38c72002-12-14 23:00:35 +000034#ifndef ATTRIBUTE_UNUSED
Daniel Veillard0e9dafa2002-12-27 11:58:25 +000035#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
36#endif /* ATTRIBUTE_UNUSED */
Daniel Veillard0eb38c72002-12-14 23:00:35 +000037#else
38#define ATTRIBUTE_UNUSED
39#endif
Daniel Veillard96fe0952002-01-30 20:52:23 +000040
Daniel Veillard36eea2d2002-02-04 00:17:01 +000041#define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
42 (((PyxmlNode_Object *)(v))->obj))
Daniel Veillard96fe0952002-01-30 20:52:23 +000043
44typedef struct {
45 PyObject_HEAD
46 xmlNodePtr obj;
47} PyxmlNode_Object;
Daniel Veillardd2897fd2002-01-30 16:37:32 +000048
Daniel Veillard36eea2d2002-02-04 00:17:01 +000049#define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \
50 (((PyxmlXPathContext_Object *)(v))->obj))
51
Daniel Veillard1971ee22002-01-31 20:29:19 +000052typedef struct {
53 PyObject_HEAD
54 xmlXPathContextPtr obj;
55} PyxmlXPathContext_Object;
56
Daniel Veillard7db38712002-02-07 16:39:11 +000057#define PyxmlXPathParserContext_Get(v) (((v) == Py_None) ? NULL : \
58 (((PyxmlXPathParserContext_Object *)(v))->obj))
59
60typedef struct {
61 PyObject_HEAD
62 xmlXPathParserContextPtr obj;
63} PyxmlXPathParserContext_Object;
64
Daniel Veillard36eea2d2002-02-04 00:17:01 +000065#define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \
66 (((PyparserCtxt_Object *)(v))->obj))
67
Daniel Veillard3ce52572002-02-03 15:08:05 +000068typedef struct {
69 PyObject_HEAD
70 xmlParserCtxtPtr obj;
71} PyparserCtxt_Object;
72
Daniel Veillard7db38712002-02-07 16:39:11 +000073#define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \
74 (((Pycatalog_Object *)(v))->obj))
75
76typedef struct {
77 PyObject_HEAD
78 xmlCatalogPtr obj;
79} Pycatalog_Object;
80
Daniel Veillard0e298ad2003-02-04 16:14:33 +000081#ifdef LIBXML_REGEXP_ENABLED
Daniel Veillardbd9afb52002-09-25 22:25:35 +000082#define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \
83 (((PyxmlReg_Object *)(v))->obj))
84
85typedef struct {
86 PyObject_HEAD
87 xmlRegexpPtr obj;
88} PyxmlReg_Object;
Daniel Veillard0e298ad2003-02-04 16:14:33 +000089#endif /* LIBXML_REGEXP_ENABLED */
Daniel Veillardbd9afb52002-09-25 22:25:35 +000090
Daniel Veillard0eb38c72002-12-14 23:00:35 +000091#define PyxmlTextReader_Get(v) (((v) == Py_None) ? NULL : \
92 (((PyxmlTextReader_Object *)(v))->obj))
93
94typedef struct {
95 PyObject_HEAD
96 xmlTextReaderPtr obj;
97} PyxmlTextReader_Object;
98
Daniel Veillard417be3a2003-01-20 21:26:34 +000099#define PyxmlTextReaderLocator_Get(v) (((v) == Py_None) ? NULL : \
100 (((PyxmlTextReaderLocator_Object *)(v))->obj))
101
102typedef struct {
103 PyObject_HEAD
104 xmlTextReaderLocatorPtr obj;
105} PyxmlTextReaderLocator_Object;
106
Daniel Veillard6361da02002-02-23 10:10:33 +0000107#define PyURI_Get(v) (((v) == Py_None) ? NULL : \
108 (((PyURI_Object *)(v))->obj))
109
110typedef struct {
111 PyObject_HEAD
Daniel Veillard46da4642004-01-06 22:54:57 +0000112 xmlErrorPtr obj;
113} PyError_Object;
114
115#define PyError_Get(v) (((v) == Py_None) ? NULL : \
116 (((PyError_Object *)(v))->obj))
117
118typedef struct {
119 PyObject_HEAD
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000120 xmlOutputBufferPtr obj;
121} PyoutputBuffer_Object;
122
123#define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \
Daniel Veillard6cbd6c02003-12-04 12:31:49 +0000124 (((PyoutputBuffer_Object *)(v))->obj))
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000125
126typedef struct {
127 PyObject_HEAD
128 xmlParserInputBufferPtr obj;
129} PyinputBuffer_Object;
130
131#define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \
Daniel Veillard6cbd6c02003-12-04 12:31:49 +0000132 (((PyinputBuffer_Object *)(v))->obj))
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000133
134typedef struct {
135 PyObject_HEAD
Daniel Veillard6361da02002-02-23 10:10:33 +0000136 xmlURIPtr obj;
137} PyURI_Object;
138
139/* FILE * have their own internal representation */
Daniel Veillard7db38712002-02-07 16:39:11 +0000140#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
Daniel Veillardbd9afb52002-09-25 22:25:35 +0000141 (PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
Daniel Veillard7db38712002-02-07 16:39:11 +0000142
Daniel Veillard591b4be2003-02-09 23:33:36 +0000143#ifdef LIBXML_SCHEMAS_ENABLED
144typedef struct {
145 PyObject_HEAD
146 xmlRelaxNGPtr obj;
147} PyrelaxNgSchema_Object;
148
149#define PyrelaxNgSchema_Get(v) (((v) == Py_None) ? NULL : \
150 (((PyrelaxNgSchema_Object *)(v))->obj))
151
152typedef struct {
153 PyObject_HEAD
154 xmlRelaxNGParserCtxtPtr obj;
155} PyrelaxNgParserCtxt_Object;
156
157#define PyrelaxNgParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
158 (((PyrelaxNgParserCtxt_Object *)(v))->obj))
159
160typedef struct {
161 PyObject_HEAD
162 xmlRelaxNGValidCtxtPtr obj;
163} PyrelaxNgValidCtxt_Object;
164
165#define PyrelaxNgValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
166 (((PyrelaxNgValidCtxt_Object *)(v))->obj))
167
168#endif /* LIBXML_SCHEMAS_ENABLED */
Daniel Veillard6361da02002-02-23 10:10:33 +0000169
Daniel Veillardd2897fd2002-01-30 16:37:32 +0000170PyObject * libxml_intWrap(int val);
Daniel Veillard4e1b26c2002-02-03 20:13:06 +0000171PyObject * libxml_longWrap(long val);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000172PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
173PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str);
174PyObject * libxml_charPtrWrap(char *str);
175PyObject * libxml_constcharPtrWrap(const char *str);
Daniel Veillardc575b992002-02-08 13:28:40 +0000176PyObject * libxml_charPtrConstWrap(const char *str);
177PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str);
Daniel Veillardd2897fd2002-01-30 16:37:32 +0000178PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
179PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
180PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000181PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns);
182PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns);
183PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns);
Daniel Veillard96fe0952002-01-30 20:52:23 +0000184PyObject * libxml_doubleWrap(double val);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000185PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt);
Daniel Veillard3ce52572002-02-03 15:08:05 +0000186PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt);
Daniel Veillard7db38712002-02-07 16:39:11 +0000187PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000188PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj);
Daniel Veillard7db38712002-02-07 16:39:11 +0000189PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj);
Daniel Veillard6361da02002-02-23 10:10:33 +0000190PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri);
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000191PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer);
192PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer);
Daniel Veillard0e298ad2003-02-04 16:14:33 +0000193#ifdef LIBXML_REGEXP_ENABLED
Daniel Veillardbd9afb52002-09-25 22:25:35 +0000194PyObject * libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp);
Daniel Veillard0e298ad2003-02-04 16:14:33 +0000195#endif /* LIBXML_REGEXP_ENABLED */
Daniel Veillard0eb38c72002-12-14 23:00:35 +0000196PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
Daniel Veillard417be3a2003-01-20 21:26:34 +0000197PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
Daniel Veillard96fe0952002-01-30 20:52:23 +0000198
Daniel Veillard3ce52572002-02-03 15:08:05 +0000199xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);
Daniel Veillard591b4be2003-02-09 23:33:36 +0000200#ifdef LIBXML_SCHEMAS_ENABLED
201PyObject * libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt);
202PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt);
203PyObject * libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid);
204#endif /* LIBXML_SCHEMAS_ENABLED */
Daniel Veillard46da4642004-01-06 22:54:57 +0000205PyObject * libxml_xmlErrorPtrWrap(xmlErrorPtr error);