libxml_wrap.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. #include <Python.h>
  2. #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>
  13. #include <libxml/HTMLparser.h>
  14. #include <libxml/HTMLtree.h>
  15. #include <libxml/xinclude.h>
  16. #include <libxml/xpointer.h>
  17. #include <libxml/xmlunicode.h>
  18. #include <libxml/xmlregexp.h>
  19. #include <libxml/xmlautomata.h>
  20. #include <libxml/xmlreader.h>
  21. #ifdef LIBXML_SCHEMAS_ENABLED
  22. #include <libxml/relaxng.h>
  23. #include <libxml/xmlschemas.h>
  24. #endif
  25. /**
  26. * ATTRIBUTE_UNUSED:
  27. *
  28. * Macro used to signal to GCC unused function parameters
  29. * Repeated here since the definition is not available when
  30. * compiled outside the libxml2 build tree.
  31. */
  32. #ifdef __GNUC__
  33. #ifdef ATTRIBUTE_UNUSED
  34. #undef ATTRIBUTE_UNUSED
  35. #endif
  36. #ifndef ATTRIBUTE_UNUSED
  37. #define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
  38. #endif /* ATTRIBUTE_UNUSED */
  39. #else
  40. #define ATTRIBUTE_UNUSED
  41. #endif
  42. #define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
  43. (((PyxmlNode_Object *)(v))->obj))
  44. typedef struct {
  45. PyObject_HEAD
  46. xmlNodePtr obj;
  47. } PyxmlNode_Object;
  48. #define PyxmlXPathContext_Get(v) (((v) == Py_None) ? NULL : \
  49. (((PyxmlXPathContext_Object *)(v))->obj))
  50. typedef struct {
  51. PyObject_HEAD
  52. xmlXPathContextPtr obj;
  53. } PyxmlXPathContext_Object;
  54. #define PyxmlXPathParserContext_Get(v) (((v) == Py_None) ? NULL : \
  55. (((PyxmlXPathParserContext_Object *)(v))->obj))
  56. typedef struct {
  57. PyObject_HEAD
  58. xmlXPathParserContextPtr obj;
  59. } PyxmlXPathParserContext_Object;
  60. #define PyparserCtxt_Get(v) (((v) == Py_None) ? NULL : \
  61. (((PyparserCtxt_Object *)(v))->obj))
  62. typedef struct {
  63. PyObject_HEAD
  64. xmlParserCtxtPtr obj;
  65. } PyparserCtxt_Object;
  66. #define PyValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
  67. (((PyValidCtxt_Object *)(v))->obj))
  68. typedef struct {
  69. PyObject_HEAD
  70. xmlValidCtxtPtr obj;
  71. } PyValidCtxt_Object;
  72. #define Pycatalog_Get(v) (((v) == Py_None) ? NULL : \
  73. (((Pycatalog_Object *)(v))->obj))
  74. typedef struct {
  75. PyObject_HEAD
  76. xmlCatalogPtr obj;
  77. } Pycatalog_Object;
  78. #ifdef LIBXML_REGEXP_ENABLED
  79. #define PyxmlReg_Get(v) (((v) == Py_None) ? NULL : \
  80. (((PyxmlReg_Object *)(v))->obj))
  81. typedef struct {
  82. PyObject_HEAD
  83. xmlRegexpPtr obj;
  84. } PyxmlReg_Object;
  85. #endif /* LIBXML_REGEXP_ENABLED */
  86. #ifdef LIBXML_READER_ENABLED
  87. #define PyxmlTextReader_Get(v) (((v) == Py_None) ? NULL : \
  88. (((PyxmlTextReader_Object *)(v))->obj))
  89. typedef struct {
  90. PyObject_HEAD
  91. xmlTextReaderPtr obj;
  92. } PyxmlTextReader_Object;
  93. #define PyxmlTextReaderLocator_Get(v) (((v) == Py_None) ? NULL : \
  94. (((PyxmlTextReaderLocator_Object *)(v))->obj))
  95. typedef struct {
  96. PyObject_HEAD
  97. xmlTextReaderLocatorPtr obj;
  98. } PyxmlTextReaderLocator_Object;
  99. #endif
  100. #define PyURI_Get(v) (((v) == Py_None) ? NULL : \
  101. (((PyURI_Object *)(v))->obj))
  102. typedef struct {
  103. PyObject_HEAD
  104. xmlErrorPtr obj;
  105. } PyError_Object;
  106. #define PyError_Get(v) (((v) == Py_None) ? NULL : \
  107. (((PyError_Object *)(v))->obj))
  108. typedef struct {
  109. PyObject_HEAD
  110. xmlOutputBufferPtr obj;
  111. } PyoutputBuffer_Object;
  112. #define PyoutputBuffer_Get(v) (((v) == Py_None) ? NULL : \
  113. (((PyoutputBuffer_Object *)(v))->obj))
  114. typedef struct {
  115. PyObject_HEAD
  116. xmlParserInputBufferPtr obj;
  117. } PyinputBuffer_Object;
  118. #define PyinputBuffer_Get(v) (((v) == Py_None) ? NULL : \
  119. (((PyinputBuffer_Object *)(v))->obj))
  120. typedef struct {
  121. PyObject_HEAD
  122. xmlURIPtr obj;
  123. } PyURI_Object;
  124. /* FILE * have their own internal representation */
  125. #define PyFile_Get(v) (((v) == Py_None) ? NULL : \
  126. (PyFile_Check(v) ? (PyFile_AsFile(v)) : stdout))
  127. #ifdef LIBXML_SCHEMAS_ENABLED
  128. typedef struct {
  129. PyObject_HEAD
  130. xmlRelaxNGPtr obj;
  131. } PyrelaxNgSchema_Object;
  132. #define PyrelaxNgSchema_Get(v) (((v) == Py_None) ? NULL : \
  133. (((PyrelaxNgSchema_Object *)(v))->obj))
  134. typedef struct {
  135. PyObject_HEAD
  136. xmlRelaxNGParserCtxtPtr obj;
  137. } PyrelaxNgParserCtxt_Object;
  138. #define PyrelaxNgParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
  139. (((PyrelaxNgParserCtxt_Object *)(v))->obj))
  140. typedef struct {
  141. PyObject_HEAD
  142. xmlRelaxNGValidCtxtPtr obj;
  143. } PyrelaxNgValidCtxt_Object;
  144. #define PyrelaxNgValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
  145. (((PyrelaxNgValidCtxt_Object *)(v))->obj))
  146. typedef struct {
  147. PyObject_HEAD
  148. xmlSchemaPtr obj;
  149. } PySchema_Object;
  150. #define PySchema_Get(v) (((v) == Py_None) ? NULL : \
  151. (((PySchema_Object *)(v))->obj))
  152. typedef struct {
  153. PyObject_HEAD
  154. xmlSchemaParserCtxtPtr obj;
  155. } PySchemaParserCtxt_Object;
  156. #define PySchemaParserCtxt_Get(v) (((v) == Py_None) ? NULL : \
  157. (((PySchemaParserCtxt_Object *)(v))->obj))
  158. typedef struct {
  159. PyObject_HEAD
  160. xmlSchemaValidCtxtPtr obj;
  161. } PySchemaValidCtxt_Object;
  162. #define PySchemaValidCtxt_Get(v) (((v) == Py_None) ? NULL : \
  163. (((PySchemaValidCtxt_Object *)(v))->obj))
  164. #endif /* LIBXML_SCHEMAS_ENABLED */
  165. PyObject * libxml_intWrap(int val);
  166. PyObject * libxml_longWrap(long val);
  167. PyObject * libxml_xmlCharPtrWrap(xmlChar *str);
  168. PyObject * libxml_constxmlCharPtrWrap(const xmlChar *str);
  169. PyObject * libxml_charPtrWrap(char *str);
  170. PyObject * libxml_constcharPtrWrap(const char *str);
  171. PyObject * libxml_charPtrConstWrap(const char *str);
  172. PyObject * libxml_xmlCharPtrConstWrap(const xmlChar *str);
  173. PyObject * libxml_xmlDocPtrWrap(xmlDocPtr doc);
  174. PyObject * libxml_xmlNodePtrWrap(xmlNodePtr node);
  175. PyObject * libxml_xmlAttrPtrWrap(xmlAttrPtr attr);
  176. PyObject * libxml_xmlNsPtrWrap(xmlNsPtr ns);
  177. PyObject * libxml_xmlAttributePtrWrap(xmlAttributePtr ns);
  178. PyObject * libxml_xmlElementPtrWrap(xmlElementPtr ns);
  179. PyObject * libxml_doubleWrap(double val);
  180. PyObject * libxml_xmlXPathContextPtrWrap(xmlXPathContextPtr ctxt);
  181. PyObject * libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt);
  182. PyObject * libxml_xmlXPathParserContextPtrWrap(xmlXPathParserContextPtr ctxt);
  183. PyObject * libxml_xmlXPathObjectPtrWrap(xmlXPathObjectPtr obj);
  184. PyObject * libxml_xmlValidCtxtPtrWrap(xmlValidCtxtPtr valid);
  185. PyObject * libxml_xmlCatalogPtrWrap(xmlCatalogPtr obj);
  186. PyObject * libxml_xmlURIPtrWrap(xmlURIPtr uri);
  187. PyObject * libxml_xmlOutputBufferPtrWrap(xmlOutputBufferPtr buffer);
  188. PyObject * libxml_xmlParserInputBufferPtrWrap(xmlParserInputBufferPtr buffer);
  189. #ifdef LIBXML_REGEXP_ENABLED
  190. PyObject * libxml_xmlRegexpPtrWrap(xmlRegexpPtr regexp);
  191. #endif /* LIBXML_REGEXP_ENABLED */
  192. #ifdef LIBXML_READER_ENABLED
  193. PyObject * libxml_xmlTextReaderPtrWrap(xmlTextReaderPtr reader);
  194. PyObject * libxml_xmlTextReaderLocatorPtrWrap(xmlTextReaderLocatorPtr locator);
  195. #endif
  196. xmlXPathObjectPtr libxml_xmlXPathObjectPtrConvert(PyObject * obj);
  197. #ifdef LIBXML_SCHEMAS_ENABLED
  198. PyObject * libxml_xmlRelaxNGPtrWrap(xmlRelaxNGPtr ctxt);
  199. PyObject * libxml_xmlRelaxNGParserCtxtPtrWrap(xmlRelaxNGParserCtxtPtr ctxt);
  200. PyObject * libxml_xmlRelaxNGValidCtxtPtrWrap(xmlRelaxNGValidCtxtPtr valid);
  201. PyObject * libxml_xmlSchemaPtrWrap(xmlSchemaPtr ctxt);
  202. PyObject * libxml_xmlSchemaParserCtxtPtrWrap(xmlSchemaParserCtxtPtr ctxt);
  203. PyObject * libxml_xmlSchemaValidCtxtPtrWrap(xmlSchemaValidCtxtPtr valid);
  204. #endif /* LIBXML_SCHEMAS_ENABLED */
  205. PyObject * libxml_xmlErrorPtrWrap(xmlErrorPtr error);
  206. PyObject * libxml_xmlSchemaSetValidErrors(PyObject * self, PyObject * args);