2002-02-03 15:08:05 +00:00
# include <Python.h>
2002-01-30 16:37:32 +00:00
# include <libxml/tree.h>
# include <libxml/parser.h>
# include <libxml/parserInternals.h>
# include <libxml/catalog.h>
# include <libxml/threads.h>
# include <libxml/nanoftp.h>
# include <libxml/nanohttp.h>
# include <libxml/uri.h>
# include <libxml/xpath.h>
# include <libxml/xpathInternals.h>
# include <libxml/debugXML.h>
2002-01-30 20:52:23 +00:00
# include <libxml/HTMLparser.h>
# include <libxml/HTMLtree.h>
# include <libxml/xinclude.h>
2002-01-31 20:29:19 +00:00
# include <libxml/xpointer.h>
2002-09-25 22:25:35 +00:00
# include <libxml/xmlunicode.h>
# include <libxml/xmlregexp.h>
# include <libxml/xmlautomata.h>
2002-12-14 23:00:35 +00:00
# include <libxml/xmlreader.h>
2004-08-18 09:13:18 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
2003-02-05 13:19:53 +00:00
# include <libxml/relaxng.h>
2004-08-18 09:13:18 +00:00
# include <libxml/xmlschemas.h>
# endif
2002-12-14 23:00:35 +00:00
2013-04-02 10:27:57 +08:00
/*
* for older versions of Python , we don ' t use PyBytes , but keep PyString
* and don ' t use Capsule but CObjects
*/
# if PY_VERSION_HEX < 0x02070000
# ifndef PyBytes_Check
# define PyBytes_Check PyString_Check
# define PyBytes_Size PyString_Size
# define PyBytes_AsString PyString_AsString
# define PyBytes_AS_STRING PyString_AS_STRING
# define PyBytes_GET_SIZE PyString_GET_SIZE
2013-05-03 22:25:38 +08:00
# endif
# ifndef PyCapsule_New
2013-04-02 10:27:57 +08:00
# define PyCapsule_New PyCObject_FromVoidPtrAndDesc
# define PyCapsule_CheckExact PyCObject_Check
# define PyCapsule_GetPointer(o, n) PyCObject_GetDesc((o))
# endif
# endif
2002-12-14 23:00:35 +00:00
/**
* ATTRIBUTE_UNUSED :
*
* Macro used to signal to GCC unused function parameters
* Repeated here since the definition is not available when
* compiled outside the libxml2 build tree .
*/
# ifdef __GNUC__
# ifdef ATTRIBUTE_UNUSED
# undef ATTRIBUTE_UNUSED
# endif
# ifndef ATTRIBUTE_UNUSED
2002-12-27 11:58:25 +00:00
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# endif /* ATTRIBUTE_UNUSED */
2002-12-14 23:00:35 +00:00
# else
# define ATTRIBUTE_UNUSED
# endif
2002-01-30 20:52:23 +00:00
2002-02-04 00:17:01 +00:00
# define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyxmlNode_Object * ) ( v ) ) - > obj ) )
2002-01-30 20:52:23 +00:00
typedef struct {
PyObject_HEAD
xmlNodePtr obj ;
} PyxmlNode_Object ;
2002-01-30 16:37:32 +00:00
2002-02-04 00:17:01 +00:00
# define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyxmlXPathContext_Object * ) ( v ) ) - > obj ) )
2002-01-31 20:29:19 +00:00
typedef struct {
PyObject_HEAD
xmlXPathContextPtr obj ;
} PyxmlXPathContext_Object ;
2002-02-07 16:39:11 +00:00
# define PyxmlXPathParserContext_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyxmlXPathParserContext_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlXPathParserContextPtr obj ;
} PyxmlXPathParserContext_Object ;
2002-02-04 00:17:01 +00:00
# define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyparserCtxt_Object * ) ( v ) ) - > obj ) )
2002-02-03 15:08:05 +00:00
typedef struct {
PyObject_HEAD
xmlParserCtxtPtr obj ;
} PyparserCtxt_Object ;
2004-11-10 11:55:47 +00:00
# define PyValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyValidCtxt_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlValidCtxtPtr obj ;
} PyValidCtxt_Object ;
2002-02-07 16:39:11 +00:00
# define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \
( ( ( Pycatalog_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlCatalogPtr obj ;
} Pycatalog_Object ;
2003-02-04 16:14:33 +00:00
# ifdef LIBXML_REGEXP_ENABLED
2002-09-25 22:25:35 +00:00
# define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyxmlReg_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlRegexpPtr obj ;
} PyxmlReg_Object ;
2003-02-04 16:14:33 +00:00
# endif /* LIBXML_REGEXP_ENABLED */
2002-09-25 22:25:35 +00:00
2008-05-12 12:58:46 +00:00
# ifdef LIBXML_READER_ENABLED
2002-12-14 23:00:35 +00:00
# define PyxmlTextReader_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyxmlTextReader_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlTextReaderPtr obj ;
} PyxmlTextReader_Object ;
2003-01-20 21:26:34 +00:00
# define PyxmlTextReaderLocator_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyxmlTextReaderLocator_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlTextReaderLocatorPtr obj ;
} PyxmlTextReaderLocator_Object ;
2008-05-12 12:58:46 +00:00
# endif
2003-01-20 21:26:34 +00:00
2002-02-23 10:10:33 +00:00
# define PyURI_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyURI_Object * ) ( v ) ) - > obj ) )
2004-01-06 22:54:57 +00:00
typedef struct {
PyObject_HEAD
xmlErrorPtr obj ;
} PyError_Object ;
# define PyError_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyError_Object * ) ( v ) ) - > obj ) )
2002-09-12 15:00:57 +00:00
typedef struct {
PyObject_HEAD
xmlOutputBufferPtr obj ;
} PyoutputBuffer_Object ;
# define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \
2003-12-04 12:31:49 +00:00
( ( ( PyoutputBuffer_Object * ) ( v ) ) - > obj ) )
2002-09-12 15:00:57 +00:00
typedef struct {
PyObject_HEAD
xmlParserInputBufferPtr obj ;
} PyinputBuffer_Object ;
# define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \
2003-12-04 12:31:49 +00:00
( ( ( PyinputBuffer_Object * ) ( v ) ) - > obj ) )
2002-09-12 15:00:57 +00:00
2002-02-23 10:10:33 +00:00
typedef struct {
PyObject_HEAD
xmlURIPtr obj ;
} PyURI_Object ;
/* FILE * have their own internal representation */
2013-03-29 13:46:24 +08:00
# if PY_MAJOR_VERSION >= 3
FILE * libxml_PyFileGet ( PyObject * f ) ;
void libxml_PyFileRelease ( FILE * f ) ;
# define PyFile_Get(v) (((v) == Py_None) ? NULL : libxml_PyFileGet(v))
# define PyFile_Release(f) libxml_PyFileRelease(f)
# else
2002-02-07 16:39:11 +00:00
# define PyFile_Get(v) (((v) == Py_None) ? NULL : \
2002-09-25 22:25:35 +00:00
( PyFile_Check ( v ) ? ( PyFile_AsFile ( v ) ) : stdout ) )
2013-03-29 13:46:24 +08:00
# define PyFile_Release(f)
# endif
2002-02-07 16:39:11 +00:00
2003-02-09 23:33:36 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
typedef struct {
PyObject_HEAD
xmlRelaxNGPtr obj ;
} PyrelaxNgSchema_Object ;
# define PyrelaxNgSchema_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyrelaxNgSchema_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlRelaxNGParserCtxtPtr obj ;
} PyrelaxNgParserCtxt_Object ;
# define PyrelaxNgParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyrelaxNgParserCtxt_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlRelaxNGValidCtxtPtr obj ;
} PyrelaxNgValidCtxt_Object ;
# define PyrelaxNgValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PyrelaxNgValidCtxt_Object * ) ( v ) ) - > obj ) )
2004-08-18 09:13:18 +00:00
typedef struct {
PyObject_HEAD
xmlSchemaPtr obj ;
} PySchema_Object ;
# define PySchema_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PySchema_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlSchemaParserCtxtPtr obj ;
} PySchemaParserCtxt_Object ;
# define PySchemaParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PySchemaParserCtxt_Object * ) ( v ) ) - > obj ) )
typedef struct {
PyObject_HEAD
xmlSchemaValidCtxtPtr obj ;
} PySchemaValidCtxt_Object ;
# define PySchemaValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
( ( ( PySchemaValidCtxt_Object * ) ( v ) ) - > obj ) )
2003-02-09 23:33:36 +00:00
# endif /* LIBXML_SCHEMAS_ENABLED */
2002-02-23 10:10:33 +00:00
2002-01-30 16:37:32 +00:00
PyObject * libxml_intWrap ( int val ) ;
2002-02-03 20:13:06 +00:00
PyObject * libxml_longWrap ( long val ) ;
2002-01-31 20:29:19 +00:00
PyObject * libxml_xmlCharPtrWrap ( xmlChar * str ) ;
PyObject * libxml_constxmlCharPtrWrap ( const xmlChar * str ) ;
PyObject * libxml_charPtrWrap ( char * str ) ;
PyObject * libxml_constcharPtrWrap ( const char * str ) ;
2002-02-08 13:28:40 +00:00
PyObject * libxml_charPtrConstWrap ( const char * str ) ;
PyObject * libxml_xmlCharPtrConstWrap ( const xmlChar * str ) ;
2002-01-30 16:37:32 +00:00
PyObject * libxml_xmlDocPtrWrap ( xmlDocPtr doc ) ;
PyObject * libxml_xmlNodePtrWrap ( xmlNodePtr node ) ;
PyObject * libxml_xmlAttrPtrWrap ( xmlAttrPtr attr ) ;
2002-01-31 20:29:19 +00:00
PyObject * libxml_xmlNsPtrWrap ( xmlNsPtr ns ) ;
PyObject * libxml_xmlAttributePtrWrap ( xmlAttributePtr ns ) ;
PyObject * libxml_xmlElementPtrWrap ( xmlElementPtr ns ) ;
2002-01-30 20:52:23 +00:00
PyObject * libxml_doubleWrap ( double val ) ;
2002-01-31 20:29:19 +00:00
PyObject * libxml_xmlXPathContextPtrWrap ( xmlXPathContextPtr ctxt ) ;
2002-02-03 15:08:05 +00:00
PyObject * libxml_xmlParserCtxtPtrWrap ( xmlParserCtxtPtr ctxt ) ;
2002-02-07 16:39:11 +00:00
PyObject * libxml_xmlXPathParserContextPtrWrap ( xmlXPathParserContextPtr ctxt ) ;
2002-01-31 20:29:19 +00:00
PyObject * libxml_xmlXPathObjectPtrWrap ( xmlXPathObjectPtr obj ) ;
2004-11-10 11:55:47 +00:00
PyObject * libxml_xmlValidCtxtPtrWrap ( xmlValidCtxtPtr valid ) ;
2002-02-07 16:39:11 +00:00
PyObject * libxml_xmlCatalogPtrWrap ( xmlCatalogPtr obj ) ;
2002-02-23 10:10:33 +00:00
PyObject * libxml_xmlURIPtrWrap ( xmlURIPtr uri ) ;
2002-09-12 15:00:57 +00:00
PyObject * libxml_xmlOutputBufferPtrWrap ( xmlOutputBufferPtr buffer ) ;
PyObject * libxml_xmlParserInputBufferPtrWrap ( xmlParserInputBufferPtr buffer ) ;
2003-02-04 16:14:33 +00:00
# ifdef LIBXML_REGEXP_ENABLED
2002-09-25 22:25:35 +00:00
PyObject * libxml_xmlRegexpPtrWrap ( xmlRegexpPtr regexp ) ;
2003-02-04 16:14:33 +00:00
# endif /* LIBXML_REGEXP_ENABLED */
2008-05-12 12:58:46 +00:00
# ifdef LIBXML_READER_ENABLED
2002-12-14 23:00:35 +00:00
PyObject * libxml_xmlTextReaderPtrWrap ( xmlTextReaderPtr reader ) ;
2003-01-20 21:26:34 +00:00
PyObject * libxml_xmlTextReaderLocatorPtrWrap ( xmlTextReaderLocatorPtr locator ) ;
2008-05-12 12:58:46 +00:00
# endif
2002-01-30 20:52:23 +00:00
2002-02-03 15:08:05 +00:00
xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert ( PyObject * obj ) ;
2003-02-09 23:33:36 +00:00
# ifdef LIBXML_SCHEMAS_ENABLED
PyObject * libxml_xmlRelaxNGPtrWrap ( xmlRelaxNGPtr ctxt ) ;
PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap ( xmlRelaxNGParserCtxtPtr ctxt ) ;
PyObject * libxml_xmlRelaxNGValidCtxtPtrWrap ( xmlRelaxNGValidCtxtPtr valid ) ;
2004-08-18 09:13:18 +00:00
PyObject * libxml_xmlSchemaPtrWrap ( xmlSchemaPtr ctxt ) ;
PyObject * libxml_xmlSchemaParserCtxtPtrWrap ( xmlSchemaParserCtxtPtr ctxt ) ;
PyObject * libxml_xmlSchemaValidCtxtPtrWrap ( xmlSchemaValidCtxtPtr valid ) ;
2003-02-09 23:33:36 +00:00
# endif /* LIBXML_SCHEMAS_ENABLED */
2004-01-06 22:54:57 +00:00
PyObject * libxml_xmlErrorPtrWrap ( xmlErrorPtr error ) ;
2004-08-22 13:11:39 +00:00
PyObject * libxml_xmlSchemaSetValidErrors ( PyObject * self , PyObject * args ) ;
2013-02-25 15:54:25 +08:00
PyObject * libxml_xmlRegisterInputCallback ( PyObject * self , PyObject * args ) ;
PyObject * libxml_xmlUnregisterInputCallback ( PyObject * self , PyObject * args ) ;
2013-03-29 13:46:24 +08:00
PyObject * libxml_xmlNodeRemoveNsDef ( PyObject * self , PyObject * args ) ;