blob: d1c5dc9b21cab5358601bc53e3522fad2eb58226 [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 Veillardc6d4a932002-09-12 15:00:57 +0000112 xmlOutputBufferPtr obj;
113} PyoutputBuffer_Object;
114
115#define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \
116 (((PyURI_Object *)(v))->obj))
117
118typedef struct {
119 PyObject_HEAD
120 xmlParserInputBufferPtr obj;
121} PyinputBuffer_Object;
122
123#define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \
124 (((PyURI_Object *)(v))->obj))
125
126typedef struct {
127 PyObject_HEAD
Daniel Veillard6361da02002-02-23 10:10:33 +0000128 xmlURIPtr obj;
129} PyURI_Object;
130
131/* FILE * have their own internal representation */
Daniel Veillard7db38712002-02-07 16:39:11 +0000132#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
Daniel Veillardbd9afb52002-09-25 22:25:35 +0000133 (PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
Daniel Veillard7db38712002-02-07 16:39:11 +0000134
Daniel Veillard6361da02002-02-23 10:10:33 +0000135
Daniel Veillardd2897fd2002-01-30 16:37:32 +0000136PyObject * libxml_intWrap(int val);
Daniel Veillard4e1b26c2002-02-03 20:13:06 +0000137PyObject * libxml_longWrap(long val);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000138PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
139PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str);
140PyObject * libxml_charPtrWrap(char *str);
141PyObject * libxml_constcharPtrWrap(const char *str);
Daniel Veillardc575b992002-02-08 13:28:40 +0000142PyObject * libxml_charPtrConstWrap(const char *str);
143PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str);
Daniel Veillardd2897fd2002-01-30 16:37:32 +0000144PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
145PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
146PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000147PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns);
148PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns);
149PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns);
Daniel Veillard96fe0952002-01-30 20:52:23 +0000150PyObject * libxml_doubleWrap(double val);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000151PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt);
Daniel Veillard3ce52572002-02-03 15:08:05 +0000152PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt);
Daniel Veillard7db38712002-02-07 16:39:11 +0000153PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000154PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj);
Daniel Veillard7db38712002-02-07 16:39:11 +0000155PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj);
Daniel Veillard6361da02002-02-23 10:10:33 +0000156PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri);
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000157PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer);
158PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer);
Daniel Veillard0e298ad2003-02-04 16:14:33 +0000159#ifdef LIBXML_REGEXP_ENABLED
Daniel Veillardbd9afb52002-09-25 22:25:35 +0000160PyObject * libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp);
Daniel Veillard0e298ad2003-02-04 16:14:33 +0000161#endif /* LIBXML_REGEXP_ENABLED */
Daniel Veillard0eb38c72002-12-14 23:00:35 +0000162PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
Daniel Veillard417be3a2003-01-20 21:26:34 +0000163PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
Daniel Veillard96fe0952002-01-30 20:52:23 +0000164
Daniel Veillard3ce52572002-02-03 15:08:05 +0000165xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);