blob: 56950e91bb049075815e0abba774764e4f37edc3 [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 Veillard0e298ad2003-02-04 16:14:33 +000080#ifdef LIBXML_REGEXP_ENABLED
Daniel Veillardbd9afb52002-09-25 22:25:35 +000081#define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \
82 (((PyxmlReg_Object *)(v))->obj))
83
84typedef struct {
85 PyObject_HEAD
86 xmlRegexpPtr obj;
87} PyxmlReg_Object;
Daniel Veillard0e298ad2003-02-04 16:14:33 +000088#endif /* LIBXML_REGEXP_ENABLED */
Daniel Veillardbd9afb52002-09-25 22:25:35 +000089
Daniel Veillard0eb38c72002-12-14 23:00:35 +000090#define PyxmlTextReader_Get(v) (((v) == Py_None) ? NULL : \
91 (((PyxmlTextReader_Object *)(v))->obj))
92
93typedef struct {
94 PyObject_HEAD
95 xmlTextReaderPtr obj;
96} PyxmlTextReader_Object;
97
Daniel Veillard417be3a2003-01-20 21:26:34 +000098#define PyxmlTextReaderLocator_Get(v) (((v) == Py_None) ? NULL : \
99 (((PyxmlTextReaderLocator_Object *)(v))->obj))
100
101typedef struct {
102 PyObject_HEAD
103 xmlTextReaderLocatorPtr obj;
104} PyxmlTextReaderLocator_Object;
105
Daniel Veillard6361da02002-02-23 10:10:33 +0000106#define PyURI_Get(v) (((v) == Py_None) ? NULL : \
107 (((PyURI_Object *)(v))->obj))
108
109typedef struct {
110 PyObject_HEAD
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000111 xmlOutputBufferPtr obj;
112} PyoutputBuffer_Object;
113
114#define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \
115 (((PyURI_Object *)(v))->obj))
116
117typedef struct {
118 PyObject_HEAD
119 xmlParserInputBufferPtr obj;
120} PyinputBuffer_Object;
121
122#define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \
123 (((PyURI_Object *)(v))->obj))
124
125typedef struct {
126 PyObject_HEAD
Daniel Veillard6361da02002-02-23 10:10:33 +0000127 xmlURIPtr obj;
128} PyURI_Object;
129
130/* FILE * have their own internal representation */
Daniel Veillard7db38712002-02-07 16:39:11 +0000131#define PyFile_Get(v) (((v) == Py_None) ? NULL : \
Daniel Veillardbd9afb52002-09-25 22:25:35 +0000132 (PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
Daniel Veillard7db38712002-02-07 16:39:11 +0000133
Daniel Veillard6361da02002-02-23 10:10:33 +0000134
Daniel Veillardd2897fd2002-01-30 16:37:32 +0000135PyObject * libxml_intWrap(int val);
Daniel Veillard4e1b26c2002-02-03 20:13:06 +0000136PyObject * libxml_longWrap(long val);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000137PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
138PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str);
139PyObject * libxml_charPtrWrap(char *str);
140PyObject * libxml_constcharPtrWrap(const char *str);
Daniel Veillardc575b992002-02-08 13:28:40 +0000141PyObject * libxml_charPtrConstWrap(const char *str);
142PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str);
Daniel Veillardd2897fd2002-01-30 16:37:32 +0000143PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
144PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
145PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000146PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns);
147PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns);
148PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns);
Daniel Veillard96fe0952002-01-30 20:52:23 +0000149PyObject * libxml_doubleWrap(double val);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000150PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt);
Daniel Veillard3ce52572002-02-03 15:08:05 +0000151PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt);
Daniel Veillard7db38712002-02-07 16:39:11 +0000152PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt);
Daniel Veillard1971ee22002-01-31 20:29:19 +0000153PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj);
Daniel Veillard7db38712002-02-07 16:39:11 +0000154PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj);
Daniel Veillard6361da02002-02-23 10:10:33 +0000155PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri);
Daniel Veillardc6d4a932002-09-12 15:00:57 +0000156PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer);
157PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer);
Daniel Veillard0e298ad2003-02-04 16:14:33 +0000158#ifdef LIBXML_REGEXP_ENABLED
Daniel Veillardbd9afb52002-09-25 22:25:35 +0000159PyObject * libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp);
Daniel Veillard0e298ad2003-02-04 16:14:33 +0000160#endif /* LIBXML_REGEXP_ENABLED */
Daniel Veillard0eb38c72002-12-14 23:00:35 +0000161PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
Daniel Veillard417be3a2003-01-20 21:26:34 +0000162PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
Daniel Veillard96fe0952002-01-30 20:52:23 +0000163
Daniel Veillard3ce52572002-02-03 15:08:05 +0000164xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);