blob: c59b706b6c8535c0518f518a2d135f5338aa6d73 [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>
21
22/**
23 * ATTRIBUTE_UNUSED:
24 *
25 * Macro used to signal to GCC unused function parameters
26 * Repeated here since the definition is not available when
27 * compiled outside the libxml2 build tree.
28 */
29#ifdef __GNUC__
30#ifdef ATTRIBUTE_UNUSED
31#undef ATTRIBUTE_UNUSED
32#endif
Daniel Veillard0eb38c72002-12-14 23:00:35 +000033#ifndef ATTRIBUTE_UNUSED
Daniel Veillard0e9dafa2002-12-27 11:58:25 +000034#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
35#endif /* ATTRIBUTE_UNUSED */
Daniel Veillard0eb38c72002-12-14 23:00:35 +000036#else
37#define ATTRIBUTE_UNUSED
38#endif
Daniel Veillard96fe0952002-01-30 20:52:23 +000039
Daniel Veillard36eea2d2002-02-04 00:17:01 +000040#define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
41 (((PyxmlNode_Object *)(v))->obj))
Daniel Veillard96fe0952002-01-30 20:52:23 +000042
43typedef struct {
44 PyObject_HEAD
45 xmlNodePtr obj;
46} PyxmlNode_Object;
Daniel Veillardd2897fd2002-01-30 16:37:32 +000047
Daniel Veillard36eea2d2002-02-04 00:17:01 +000048#define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \
49 (((PyxmlXPathContext_Object *)(v))->obj))
50
Daniel Veillard1971ee22002-01-31 20:29:19 +000051typedef struct {
52 PyObject_HEAD
53 xmlXPathContextPtr obj;
54} PyxmlXPathContext_Object;
55
Daniel Veillard7db38712002-02-07 16:39:11 +000056#define PyxmlXPathParserContext_Get(v) (((v) == Py_None) ? NULL : \
57 (((PyxmlXPathParserContext_Object *)(v))->obj))
58
59typedef struct {
60 PyObject_HEAD
61 xmlXPathParserContextPtr obj;
62} PyxmlXPathParserContext_Object;
63
Daniel Veillard36eea2d2002-02-04 00:17:01 +000064#define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \
65 (((PyparserCtxt_Object *)(v))->obj))
66
Daniel Veillard3ce52572002-02-03 15:08:05 +000067typedef struct {
68 PyObject_HEAD
69 xmlParserCtxtPtr obj;
70} PyparserCtxt_Object;
71
Daniel Veillard7db38712002-02-07 16:39:11 +000072#define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \
73 (((Pycatalog_Object *)(v))->obj))
74
75typedef struct {
76 PyObject_HEAD
77 xmlCatalogPtr obj;
78} Pycatalog_Object;
79
Daniel Veillardbd9afb52002-09-25 22:25:35 +000080#define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \
81 (((PyxmlReg_Object *)(v))->obj))
82
83typedef struct {
84 PyObject_HEAD
85 xmlRegexpPtr obj;
86} PyxmlReg_Object;
87
Daniel Veillard0eb38c72002-12-14 23:00:35 +000088#define PyxmlTextReader_Get(v) (((v) == Py_None) ? NULL : \
89 (((PyxmlTextReader_Object *)(v))->obj))
90
91typedef struct {
92 PyObject_HEAD
93 xmlTextReaderPtr obj;
94} PyxmlTextReader_Object;
95
Daniel Veillard417be3a2003-01-20 21:26:34 +000096#define PyxmlTextReaderLocator_Get(v) (((v) == Py_None) ? NULL : \
97 (((PyxmlTextReaderLocator_Object *)(v))->obj))
98
99typedef struct {
100 PyObject_HEAD
101 xmlTextReaderLocatorPtr obj;
102} PyxmlTextReaderLocator_Object;
103
Daniel Veillard6361da02002-02-23 10:10:33 +0000104#define PyURI_Get(v) (((v) == Py_None) ? NULL : \
105 (((PyURI_Object *)(v))->obj))
106
107typedef struct {
108 PyObject_HEAD
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000109 xmlOutputBufferPtr obj;
110} PyoutputBuffer_Object;
111
112#define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \
113 (((PyURI_Object *)(v))->obj))
114
115typedef struct {
116 PyObject_HEAD
117 xmlParserInputBufferPtr obj;
118} PyinputBuffer_Object;
119
120#define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \
121 (((PyURI_Object *)(v))->obj))
122
123typedef struct {
124 PyObject_HEAD
Daniel Veillard6361da02002-02-23 10:10:33 +0000125 xmlURIPtr obj;
126} PyURI_Object;
127
128/* FILE * have their own internal representation */
Daniel Veillard7db38712002-02-07 16:39:11 +0000129#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
Daniel Veillardbd9afb52002-09-25 22:25:35 +0000130 (PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
Daniel Veillard7db38712002-02-07 16:39:11 +0000131
Daniel Veillard6361da02002-02-23 10:10:33 +0000132
Daniel Veillardd2897fd2002-01-30 16:37:32 +0000133PyObject * libxml_intWrap(int val);
Daniel Veillard4e1b26c2002-02-03 20:13:06 +0000134PyObject * libxml_longWrap(long val);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000135PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
136PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str);
137PyObject * libxml_charPtrWrap(char *str);
138PyObject * libxml_constcharPtrWrap(const char *str);
Daniel Veillardc575b992002-02-08 13:28:40 +0000139PyObject * libxml_charPtrConstWrap(const char *str);
140PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str);
Daniel Veillardd2897fd2002-01-30 16:37:32 +0000141PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
142PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
143PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000144PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns);
145PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns);
146PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns);
Daniel Veillard96fe0952002-01-30 20:52:23 +0000147PyObject * libxml_doubleWrap(double val);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000148PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt);
Daniel Veillard3ce52572002-02-03 15:08:05 +0000149PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt);
Daniel Veillard7db38712002-02-07 16:39:11 +0000150PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000151PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj);
Daniel Veillard7db38712002-02-07 16:39:11 +0000152PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj);
Daniel Veillard6361da02002-02-23 10:10:33 +0000153PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri);
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000154PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer);
155PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer);
Daniel Veillardbd9afb52002-09-25 22:25:35 +0000156PyObject * libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp);
Daniel Veillard0eb38c72002-12-14 23:00:35 +0000157PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
Daniel Veillard417be3a2003-01-20 21:26:34 +0000158PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
Daniel Veillard96fe0952002-01-30 20:52:23 +0000159
Daniel Veillard3ce52572002-02-03 15:08:05 +0000160xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);