libxml.c revision 38ae7e4efe803ea78b6499cd05a394db32623e41
/*
* libxml.c: this modules implements the main part of the glue of the
* libxml2 library and the Python interpreter. It provides the
* entry points where an automatically generated stub is either
* unpractical or would not match cleanly the Python model.
*
* If compiled with MERGED_MODULES, the entry point will be used to
* initialize both the libxml2 and the libxslt wrappers
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#include <Python.h>
#include <fileobject.h>
/* #include "config.h" */
#include <libxml/xmlmemory.h>
#include <libxml/xmlerror.h>
#include <libxml/xpathInternals.h>
#include <libxml/xmlmemory.h>
#include "libxml_wrap.h"
#include "libxml2-py.h"
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
#include "trio.h"
#define vsnprintf trio_vsnprintf
#endif
/* #define DEBUG */
/* #define DEBUG_SAX */
/* #define DEBUG_XPATH */
/* #define DEBUG_ERROR */
/* #define DEBUG_MEMORY */
/* #define DEBUG_FILES */
/* #define DEBUG_LOADER */
void initlibxml2mod(void);
/**
* TODO:
*
* macro to flag unimplemented blocks
*/
#define TODO \
"Unimplemented block at %s:%d\n", \
/*
* the following vars are used for XPath extensions, but
* are also referenced within the parser cleanup routine.
*/
static int libxml_xpathCallbacksInitialized = 0;
typedef struct libxml_xpathCallback {
typedef libxml_xpathCallback libxml_xpathCallbackArray[];
static int libxml_xpathCallbacksAllocd = 10;
static int libxml_xpathCallbacksNb = 0;
/************************************************************************
* *
* Memory debug interface *
* *
************************************************************************/
#if 0
extern void xmlMemFree(void *ptr);
extern char *xmlMemoryStrdup(const char *str);
#endif
static int libxmlMemoryDebugActivated = 0;
static long libxmlMemoryAllocatedBase = 0;
static int libxmlMemoryDebug = 0;
static void
libxml_xmlErrorInitialize(void); /* forward declare */
PyObject *
{
long ret;
ret = xmlMemUsed();
return (py_retval);
}
PyObject *
{
int activate;
long ret;
return (NULL);
#ifdef DEBUG_MEMORY
#endif
if (activate != 0) {
if (libxmlMemoryDebug == 0) {
/*
* First initialize the library and grab the old memory handlers
* and switch the library to memory debugging
*/
(xmlMallocFunc *) & mallocFunc,
(xmlReallocFunc *) & reallocFunc,
(xmlStrdupFunc *) & strdupFunc);
(reallocFunc == xmlMemRealloc) &&
(strdupFunc == xmlMemoryStrdup)) {
} else {
/*
* cleanup first, because some memory has been
* allocated with the non-debug malloc in xmlInitParser
* when the python module was imported
*/
if (ret < 0)
goto error;
/* reinitialize */
}
ret = 0;
} else if (libxmlMemoryDebugActivated == 0) {
ret = 0;
} else {
}
libxmlMemoryDebug = 1;
} else {
if (libxmlMemoryDebugActivated == 1)
else
ret = 0;
}
return (py_retval);
}
PyObject *
int ix;
long freed = -1;
if (libxmlMemoryDebug) {
freed = xmlMemUsed();
}
/*
* Need to confirm whether we really want to do this (required for
* memcheck) in all cases...
*/
}
}
if (libxmlMemoryDebug) {
freed -= xmlMemUsed();
if (libxmlMemoryAllocatedBase < 0)
}
return(Py_None);
}
PyObject *
{
if (libxmlMemoryDebug != 0)
return (Py_None);
}
/************************************************************************
* *
* Handling Python FILE I/O at the C level *
* The raw I/O attack diectly the File objects, while the *
* other routines address the ioWrapper instance instead *
* *
************************************************************************/
/**
* xmlPythonFileCloseUnref:
* @context: the I/O context
*
* Close an I/O channel
*/
static int
xmlPythonFileCloseRaw (void * context) {
#ifdef DEBUG_FILES
printf("xmlPythonFileCloseUnref\n");
#endif
}
return(0);
}
/**
* xmlPythonFileReadRaw:
* @context: the I/O context
* @buffer: where to drop data
* @len: number of bytes to write
*
* Read @len bytes to @buffer from the Python file in the I/O channel
*
* Returns the number of bytes read
*/
static int
int lenread = -1;
char *data;
#ifdef DEBUG_FILES
#endif
printf("xmlPythonFileReadRaw: result is NULL\n");
return(-1);
} else if (PyString_Check(ret)) {
else
} else {
printf("xmlPythonFileReadRaw: result is not a String\n");
}
return(lenread);
}
/**
* xmlPythonFileRead:
* @context: the I/O context
* @buffer: where to drop data
* @len: number of bytes to write
*
* Read @len bytes to @buffer from the I/O channel.
*
* Returns the number of bytes read
*/
static int
int lenread = -1;
char *data;
#ifdef DEBUG_FILES
#endif
printf("xmlPythonFileRead: result is NULL\n");
return(-1);
} else if (PyString_Check(ret)) {
else
} else {
printf("xmlPythonFileRead: result is not a String\n");
}
return(lenread);
}
/**
* xmlFileWrite:
* @context: the I/O context
* @buffer: where to drop data
* @len: number of bytes to write
*
* Write @len bytes from @buffer to the I/O channel.
*
* Returns the number of bytes written
*/
static int
int written = -1;
#ifdef DEBUG_FILES
#endif
string);
string);
}
printf("xmlPythonFileWrite: result is NULL\n");
return(-1);
} else if (PyInt_Check(ret)) {
} else {
printf("xmlPythonFileWrite: result is not an Int nor None\n");
}
return(written);
}
/**
* xmlPythonFileClose:
* @context: the I/O context
*
* Close an I/O channel
*/
static int
xmlPythonFileClose (void * context) {
#ifdef DEBUG_FILES
printf("xmlPythonFileClose\n");
#endif
}
}
return(0);
}
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlOutputBufferCreatePythonFile:
* @file: a PyFile_Type
* @encoder: the encoding converter or NULL
*
* Create a buffered output for the progressive saving to a PyFile_Type
* buffered C I/O
*
* Returns the new parser output or NULL
*/
static xmlOutputBufferPtr
/* Py_INCREF(file); */
}
return(ret);
}
PyObject *
return(NULL);
}
printf("libxml_xmlCreateOutputBuffer: buffer == NULL\n");
return(py_retval);
}
/**
* libxml_outputBufferGetPythonFile:
* @buffer: the I/O buffer
*
* read the Python I/O from the CObject
*
* Returns the new parser output or NULL
*/
static PyObject *
&buffer))
return(NULL);
"outputBufferGetPythonFile: obj == NULL\n");
return(Py_None);
}
"outputBufferGetPythonFile: not a python file wrapper\n");
return(Py_None);
}
return(Py_None);
}
return(file);
}
static PyObject *
int c_retval;
return(NULL);
/* Buffer may already have been destroyed elsewhere. This is harmless. */
return(Py_None);
}
return(py_retval);
}
static PyObject *
int c_retval;
return(NULL);
return(py_retval);
}
static PyObject *
int c_retval;
char * encoding;
return(NULL);
/* xmlSaveTo() freed the memory pointed to by buf, so record that in the
* Python object. */
return(py_retval);
}
static PyObject *
int c_retval;
char * encoding;
int format;
if (!PyArg_ParseTuple(args, (char *)"OOzi:xmlSaveFormatFileTo", &pyobj_buf, &pyobj_cur, &encoding, &format))
return(NULL);
/* xmlSaveFormatFileTo() freed the memory pointed to by buf, so record that
* in the Python object */
return(py_retval);
}
#endif /* LIBXML_OUTPUT_ENABLED */
/**
* xmlParserInputBufferCreatePythonFile:
* @file: a PyFile_Type
* @encoder: the encoding converter or NULL
*
* Create a buffered output for the progressive saving to a PyFile_Type
* buffered C I/O
*
* Returns the new parser output or NULL
*/
static xmlParserInputBufferPtr
/* Py_INCREF(file); */
}
return(ret);
}
PyObject *
return(NULL);
}
printf("libxml_xmlParserInputBufferCreate: buffer == NULL\n");
return(py_retval);
}
/************************************************************************
* *
* Providing the resolver at the Python level *
* *
************************************************************************/
static PyObject *pythonExternalEntityLoaderObjext;
static xmlParserInputPtr
if (pythonExternalEntityLoaderObjext != NULL) {
#ifdef DEBUG_LOADER
printf("pythonExternalEntityLoader: ready to call\n");
#endif
#ifdef DEBUG_LOADER
printf("pythonExternalEntityLoader: result ");
printf("\n");
#endif
}
#if 0
} else {
printf("pythonExternalEntityLoader: can't read %s\n",
URL);
#endif
}
}
}
}
}
return(result);
}
PyObject *
&loader))
return(NULL);
#ifdef DEBUG_LOADER
printf("libxml_xmlSetEntityLoader\n");
#endif
if (defaultExternalEntityLoader == NULL)
py_retval = PyInt_FromLong(0);
return(py_retval);
}
/************************************************************************
* *
* *
************************************************************************/
static void
{
int i;
int type = 0;
#ifdef DEBUG_SAX
#endif
type = 1;
type = 2;
if (type != 0) {
/*
* the xmllib interface always generate a dictionnary,
* possibly empty
*/
dict = PyDict_New();
} else {
dict = PyDict_New();
i++;
} else {
}
}
}
if (type == 1)
else if (type == 2)
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
pythonStartDocument(void *user_data)
{
#ifdef DEBUG_SAX
printf("pythonStartDocument() called\n");
#endif
result =
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
pythonEndDocument(void *user_data)
{
#ifdef DEBUG_SAX
printf("pythonEndDocument() called\n");
#endif
result =
if (PyErr_Occurred())
PyErr_Print();
}
/*
* The reference to the handler is released there
*/
}
static void
{
#ifdef DEBUG_SAX
#endif
(char *) "s", name);
if (PyErr_Occurred())
PyErr_Print();
(char *) "s", name);
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
{
#ifdef DEBUG_SAX
#endif
(char *) "s", name);
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
{
int type = 0;
#ifdef DEBUG_SAX
#endif
type = 1;
type = 2;
if (type != 0) {
if (type == 1)
else if (type == 2)
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
{
int type = 0;
#ifdef DEBUG_SAX
#endif
type = 1;
type = 2;
if (type != 0) {
if (type == 1)
result =
(char *) "ignorableWhitespace",
else if (type == 2)
result =
}
}
static void
{
#ifdef DEBUG_SAX
#endif
"processingInstruction",
}
}
static void
{
#ifdef DEBUG_SAX
#endif
result =
value);
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
{
char buf[1024];
#ifdef DEBUG_SAX
#endif
buf[1023] = 0;
result =
buf);
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
{
char buf[1024];
#ifdef DEBUG_SAX
#endif
buf[1023] = 0;
result =
buf);
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
{
char buf[1024];
#ifdef DEBUG_SAX
#endif
buf[1023] = 0;
result =
(char *) "s", buf);
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
{
int type = 0;
#ifdef DEBUG_SAX
#endif
type = 1;
type = 2;
if (type != 0) {
if (type == 1)
result =
else if (type == 2)
result =
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
pythonExternalSubset(void *user_data,
{
#ifdef DEBUG_SAX
printf("pythonExternalSubset(%s, %s, %s) called\n",
#endif
result =
systemID);
}
}
static void
pythonEntityDecl(void *user_data,
int type,
{
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
pythonNotationDecl(void *user_data,
{
systemId);
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
pythonAttributeDecl(void *user_data,
int type,
int def,
{
int count;
count = 0;
count++;
}
count = 0;
count++;
}
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
pythonElementDecl(void *user_data,
{
/* TODO: wrap in an elementContent object */
("pythonElementDecl: xmlElementContentPtr wrapper missing !\n");
/* Py_XINCREF(Py_None); isn't the reference just borrowed ??? */
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
const xmlChar * notationName)
{
result =
if (PyErr_Occurred())
PyErr_Print();
}
}
static void
{
#ifdef DEBUG_SAX
printf("pythonInternalSubset(%s, %s, %s) called\n",
#endif
SystemID);
if (PyErr_Occurred())
PyErr_Print();
}
}
static xmlSAXHandler pythonSaxHandler = {
NULL, /* TODO pythonIsStandalone, */
NULL, /* TODO pythonHasInternalSubset, */
NULL, /* TODO pythonHasExternalSubset, */
NULL, /* TODO pythonResolveEntity, */
NULL, /* TODO pythonGetEntity, */
NULL, /* OBSOLETED pythonSetDocumentLocator, */
NULL, /* TODO pythonGetParameterEntity, */
1,
NULL, /* TODO mograte to SAX2 */
NULL,
NULL,
};
/************************************************************************
* *
* Handling of specific parser context *
* *
************************************************************************/
PyObject *
{
const char *chunk;
int size;
const char *URI;
if (!PyArg_ParseTuple
return (NULL);
#ifdef DEBUG
printf("libxml_xmlCreatePushParser(%p, %s, %d, %s) called\n",
#endif
SAX = &pythonSaxHandler;
/* The reference is released in pythonEndDocument() */
}
return (pyret);
}
PyObject *
{
#ifdef LIBXML_HTML_ENABLED
const char *chunk;
int size;
const char *URI;
if (!PyArg_ParseTuple
return (NULL);
#ifdef DEBUG
printf("libxml_htmlCreatePushParser(%p, %s, %d, %s) called\n",
#endif
SAX = &pythonSaxHandler;
/* The reference is released in pythonEndDocument() */
}
return (pyret);
#else
return (Py_None);
#endif /* LIBXML_HTML_ENABLED */
}
PyObject *
{
int recover;
const char *URI;
return (NULL);
#ifdef DEBUG
printf("libxml_xmlSAXParseFile(%p, %s, %d) called\n",
#endif
return (Py_None);
}
SAX = &pythonSaxHandler;
/* The reference is released in pythonEndDocument() */
return (Py_None);
}
PyObject *
{
#ifdef LIBXML_HTML_ENABLED
const char *URI;
const char *encoding;
if (!PyArg_ParseTuple
&encoding))
return (NULL);
#ifdef DEBUG
printf("libxml_htmlSAXParseFile(%p, %s, %s) called\n",
#endif
return (Py_None);
}
SAX = &pythonSaxHandler;
/* The reference is released in pythonEndDocument() */
return (Py_None);
#else
return (Py_None);
#endif /* LIBXML_HTML_ENABLED */
}
/************************************************************************
* *
* Error message callback *
* *
************************************************************************/
/* helper to build a xmlMalloc'ed string from a format and va_list */
/*
* disabled the loop, the repeated call to vsnprintf without reset of ap
* in case the initial buffer was too small segfaulted on x86_64
* we now directly vsnprintf on a large buffer.
*/
static char *
{
int chars;
char *str;
return NULL;
if (chars >= 998)
str[999] = 0;
return str;
}
static void
...)
{
char str[1000];
#ifdef DEBUG_ERROR
#endif
if (libxml_xmlPythonErrorFuncHandler == NULL) {
} else {
str[999] = 0;
}
}
static void
{
#ifdef DEBUG_ERROR
printf("libxml_xmlErrorInitialize() called\n");
#endif
}
static PyObject *
{
if (!PyArg_ParseTuple
&pyobj_ctx))
return (NULL);
#ifdef DEBUG_ERROR
pyobj_f);
#endif
if (libxml_xmlPythonErrorFuncHandler != NULL) {
}
if (libxml_xmlPythonErrorFuncCtxt != NULL) {
}
/* TODO: check f is a function ! */
return (py_retval);
}
/************************************************************************
* *
* Per parserCtxt error handler *
* *
************************************************************************/
typedef struct
{
PyObject *f;
typedef xmlParserCtxtPyCtxt *xmlParserCtxtPyCtxtPtr;
static void
{
#ifdef DEBUG_ERROR
#endif
{
/* TODO: manage for the exception to be propagated... */
PyErr_Print();
}
}
static void
{
libxml_xmlParserCtxtGenericErrorFuncHandler(ctx,XML_PARSER_SEVERITY_ERROR,libxml_buildMessage(msg,ap));
}
static void
{
libxml_xmlParserCtxtGenericErrorFuncHandler(ctx,XML_PARSER_SEVERITY_WARNING,libxml_buildMessage(msg,ap));
}
static void
{
libxml_xmlParserCtxtGenericErrorFuncHandler(ctx,XML_PARSER_SEVERITY_VALIDITY_ERROR,libxml_buildMessage(msg,ap));
}
static void
{
libxml_xmlParserCtxtGenericErrorFuncHandler(ctx,XML_PARSER_SEVERITY_VALIDITY_WARNING,libxml_buildMessage(msg,ap));
}
static PyObject *
{
return(NULL);
return(py_retval);
}
}
else {
}
/* TODO: check f is a function ! */
Py_XDECREF(pyCtxt->f);
}
else {
}
return(py_retval);
}
static PyObject *
{
&pyobj_ctxt))
return(NULL);
Py_XINCREF(pyCtxt->f);
}
else {
/* no python error handler registered */
}
return(py_retval);
}
static PyObject *
return(NULL);
if (pyCtxt) {
Py_XDECREF(pyCtxt->f);
}
}
return(Py_None);
}
/***
* xmlValidCtxt stuff
*/
typedef struct
{
typedef xmlValidCtxtPyCtxt *xmlValidCtxtPyCtxtPtr;
static void
{
#ifdef DEBUG_ERROR
#endif
{
/* TODO: manage for the exception to be propagated... */
PyErr_Print();
}
}
static void
{
#ifdef DEBUG_ERROR
printf("libxml_xmlValidCtxtGenericWarningFuncHandler(%p, %d, %s, ...) called\n", ctx, severity, str);
#endif
{
/* TODO: manage for the exception to be propagated... */
PyErr_Print();
}
}
static void
{
libxml_xmlValidCtxtGenericErrorFuncHandler(ctx,XML_PARSER_SEVERITY_VALIDITY_ERROR,libxml_buildMessage(msg,ap));
}
static void
{
libxml_xmlValidCtxtGenericWarningFuncHandler(ctx,XML_PARSER_SEVERITY_VALIDITY_WARNING,libxml_buildMessage(msg,ap));
}
static PyObject *
{
if (!PyArg_ParseTuple
return (NULL);
#ifdef DEBUG_ERROR
#endif
return(py_retval);
}
/* TODO: check warn and error is a function ! */
return (py_retval);
}
static PyObject *
return(NULL);
{
}
return(Py_None);
}
/************************************************************************
* *
* Per xmlTextReader error handler *
* *
************************************************************************/
typedef struct
{
PyObject *f;
typedef xmlTextReaderPyCtxt *xmlTextReaderPyCtxtPtr;
static void
const char *msg,
int severity,
{
{
/* TODO: manage for the exception to be propagated... */
PyErr_Print();
}
}
static PyObject *
{
void *arg;
if (!PyArg_ParseTuple(args, (char *)"OOO:xmlTextReaderSetErrorHandler", &pyobj_reader, &pyobj_f, &pyobj_arg))
return(NULL);
/* clear previous error handler */
if (f == (xmlTextReaderErrorFunc) libxml_xmlTextReaderErrorCallback) {
/* ok, it's our error handler! */
Py_XDECREF(pyCtxt->f);
}
else {
/*
* there already an arg, and it's not ours,
* there is definitely something wrong going on here...
* we don't know how to free it, so we bail out...
*/
return(py_retval);
}
}
/* set new error handler */
{
return(py_retval);
}
pyCtxt);
}
return(py_retval);
}
static PyObject *
{
void *arg;
return(NULL);
if (f == (xmlTextReaderErrorFunc)libxml_xmlTextReaderErrorCallback) {
/* ok, it's our error handler! */
Py_XINCREF(pyCtxt->f);
}
else
{
/* f is null or it's not our error handler */
}
return(py_retval);
}
static PyObject *
void *arg;
return(NULL);
if (!PyCObject_Check(pyobj_reader)) {
return(Py_None);
}
return(Py_None);
}
if (f == (xmlTextReaderErrorFunc) libxml_xmlTextReaderErrorCallback) {
/* ok, it's our error handler! */
Py_XDECREF(pyCtxt->f);
}
/*
* else, something wrong happened, because the error handler is
* not owned by the python bindings...
*/
}
return(Py_None);
}
/************************************************************************
* *
* XPath extensions *
* *
************************************************************************/
static void
{
int i;
return;
return;
#ifdef DEBUG_XPATH
ns_uri);
#endif
/*
* Find the function, it should be there it was there at lookup
*/
for (i = 0; i < libxml_xpathCallbacksNb; i++) {
if ( /* TODO (ctxt == libxml_xpathCallbacks[i].ctx) && */
}
}
if (current_function == NULL) {
("libxml_xmlXPathFuncCallback: internal error %s not found !\n",
name);
return;
}
for (i = nargs - 1; i >= 0; i--) {
}
}
static xmlXPathFunction
{
int i;
#ifdef DEBUG_XPATH
printf("libxml_xmlXPathFuncLookupFunc(%p, %s, %s) called\n",
#endif
/*
* This is called once only. The address is then stored in the
* XPath expression evaluation, the proper object to call can
* then still be found using the execution context function
* and functionURI fields.
*/
for (i = 0; i < libxml_xpathCallbacksNb; i++) {
return (libxml_xmlXPathFuncCallback);
}
}
return (NULL);
}
static void
{
int i;
if (libxml_xpathCallbacksInitialized != 0)
return;
#ifdef DEBUG_XPATH
printf("libxml_xpathCallbacksInitialized called\n");
#endif
for (i = 0; i < libxml_xpathCallbacksAllocd; i++) {
}
}
PyObject *
{
int c_retval = 0;
int i;
if (!PyArg_ParseTuple
return (NULL);
if (libxml_xpathCallbacksInitialized == 0)
return (py_retval);
}
#ifdef DEBUG_XPATH
printf("libxml_registerXPathFunction(%p, %s, %s) called\n",
#endif
for (i = 0; i < libxml_xpathCallbacksNb; i++) {
c_retval = 1;
goto done;
}
}
}
i = libxml_xpathCallbacksNb++;
c_retval = 1;
done:
return (py_retval);
}
/************************************************************************
* *
* Global properties access *
* *
************************************************************************/
static PyObject *
{
return NULL;
#ifdef DEBUG
#endif
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:{
break;
}
case XML_ATTRIBUTE_NODE:{
break;
}
case XML_NAMESPACE_DECL:{
break;
}
default:
break;
}
return resultobj;
}
static PyObject *
{
return NULL;
#ifdef DEBUG
#endif
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
break;
case XML_ATTRIBUTE_NODE:{
break;
}
case XML_NAMESPACE_DECL:
break;
default:
break;
}
return resultobj;
}
static PyObject *
{
return NULL;
else
return resultobj;
}
static PyObject *
{
return NULL;
#ifdef DEBUG
#endif
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
break;
case XML_ATTRIBUTE_NODE:{
break;
}
case XML_NAMESPACE_DECL:{
break;
}
default:
break;
}
return resultobj;
}
static PyObject *
{
return NULL;
#ifdef DEBUG
#endif
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
break;
case XML_ATTRIBUTE_NODE:{
}
case XML_NAMESPACE_DECL:
break;
default:
break;
}
return resultobj;
}
static PyObject *
{
return NULL;
#ifdef DEBUG
#endif
case XML_ELEMENT_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
case XML_DTD_NODE:
break;
case XML_ATTRIBUTE_NODE:{
break;
}
default:
break;
}
return resultobj;
}
static PyObject *
{
return NULL;
#ifdef DEBUG
#endif
case XML_ELEMENT_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
case XML_DTD_NODE:
break;
case XML_ATTRIBUTE_NODE:{
}
default:
break;
}
return resultobj;
}
static PyObject *
{
return NULL;
#ifdef DEBUG
#endif
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
break;
case XML_ATTRIBUTE_NODE:{
}
break;
case XML_ENTITY_DECL:
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
break;
default:
break;
}
return resultobj;
}
static PyObject *
{
return NULL;
#ifdef DEBUG
#endif
case XML_ELEMENT_NODE:
break;
case XML_ATTRIBUTE_NODE:
break;
case XML_TEXT_NODE:
break;
case XML_CDATA_SECTION_NODE:
break;
case XML_ENTITY_REF_NODE:
break;
case XML_ENTITY_NODE:
break;
case XML_PI_NODE:
break;
case XML_COMMENT_NODE:
break;
case XML_DOCUMENT_NODE:
break;
case XML_DOCUMENT_TYPE_NODE:
break;
case XML_DOCUMENT_FRAG_NODE:
break;
case XML_NOTATION_NODE:
break;
case XML_HTML_DOCUMENT_NODE:
break;
case XML_DTD_NODE:
break;
case XML_ELEMENT_DECL:
break;
case XML_ATTRIBUTE_DECL:
break;
case XML_ENTITY_DECL:
break;
case XML_NAMESPACE_DECL:
break;
case XML_XINCLUDE_START:
break;
case XML_XINCLUDE_END:
break;
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
break;
#endif
}
#ifdef DEBUG
#endif
return resultobj;
}
/************************************************************************
* *
* Specific accessor functions *
* *
************************************************************************/
PyObject *
{
if (!PyArg_ParseTuple
return (NULL);
return (Py_None);
}
return (py_retval);
}
PyObject *
{
if (!PyArg_ParseTuple
return (NULL);
return (Py_None);
}
c_retval = 0;
}
else {
else
c_retval = 0;
break;
}
}
}
return (py_retval);
}
PyObject *
{
return (NULL);
return (Py_None);
}
return (py_retval);
}
#ifdef LIBXML_OUTPUT_ENABLED
/************************************************************************
* *
* Serialization front-end *
* *
************************************************************************/
static PyObject *
{
const char *encoding;
int format;
int len;
return (NULL);
return (Py_None);
}
#ifdef LIBXML_HTML_ENABLED
return (Py_None);
}
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
return (Py_None);
}
} else {
}
(void) xmlOutputBufferClose(buf);
#endif /* LIBXML_HTML_ENABLED */
} else {
else
return (Py_None);
}
}
return (Py_None);
}
} else {
}
(void) xmlOutputBufferClose(buf);
#ifdef LIBXML_HTML_ENABLED
return (Py_None);
}
}
/*
* Fallback to HTML or ASCII when the encoding is unspecified
*/
return (Py_None);
}
} else {
}
(void) xmlOutputBufferClose(buf);
#endif /* LIBXML_HTML_ENABLED */
} else {
return (Py_None);
}
}
return (py_retval);
}
static PyObject *
{
const char *encoding;
int format;
int len;
return (NULL);
return (PyInt_FromLong((long) -1));
}
return (PyInt_FromLong((long) -1));
}
return (PyInt_FromLong((long) -1));
}
} else {
}
#ifdef LIBXML_HTML_ENABLED
}
#endif /* LIBXML_HTML_ENABLED */
return (PyInt_FromLong((long) -1));
}
}
}
#ifdef LIBXML_HTML_ENABLED
#endif /* LIBXML_HTML_ENABLED */
} else {
}
return (PyInt_FromLong((long) len));
}
#endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************
* *
* Extra stuff *
* *
************************************************************************/
PyObject *
{
return (NULL);
#ifdef DEBUG
#endif
return (Py_None);
}
return (py_retval);
}
/************************************************************************
* *
* Local Catalog stuff *
* *
************************************************************************/
static PyObject *
{
return(NULL);
}
#ifdef DEBUG
#endif
return (Py_None);
}
#ifdef LIBXML_SCHEMAS_ENABLED
/************************************************************************
* *
* RelaxNG error handler registration *
* *
************************************************************************/
typedef struct
{
static void
{
#ifdef DEBUG_ERROR
#endif
{
/* TODO: manage for the exception to be propagated... */
PyErr_Print();
}
}
static void
{
#ifdef DEBUG_ERROR
#endif
{
/* TODO: manage for the exception to be propagated... */
PyErr_Print();
}
}
static void
{
}
static void
{
}
static PyObject *
{
if (!PyArg_ParseTuple
(args, (char *) "OOO|O:xmlRelaxNGSetValidErrors", &pyobj_ctx, &pyobj_error, &pyobj_warn, &pyobj_arg))
return (NULL);
#ifdef DEBUG_ERROR
#endif
{
return(py_retval);
}
{
/* first time to set the error handlers */
return(py_retval);
}
}
/* TODO: check warn and error is a function ! */
xmlRelaxNGSetValidErrors(ctxt, &libxml_xmlRelaxNGValidityErrorFunc, &libxml_xmlRelaxNGValidityWarningFunc, pyCtxt);
return (py_retval);
}
static PyObject *
return(NULL);
{
{
}
}
return(Py_None);
}
typedef struct
{
static void
{
#ifdef DEBUG_ERROR
#endif
{
/* TODO: manage for the exception to be propagated... */
PyErr_Print();
}
}
static void
{
#ifdef DEBUG_ERROR
#endif
{
/* TODO: manage for the exception to be propagated... */
PyErr_Print();
}
}
static void
{
}
static void
{
}
PyObject *
{
if (!PyArg_ParseTuple
(args, (char *) "OOO|O:xmlSchemaSetValidErrors", &pyobj_ctx, &pyobj_error, &pyobj_warn, &pyobj_arg))
return (NULL);
#ifdef DEBUG_ERROR
#endif
{
return(py_retval);
}
{
/* first time to set the error handlers */
return(py_retval);
}
}
/* TODO: check warn and error is a function ! */
xmlSchemaSetValidErrors(ctxt, &libxml_xmlSchemaValidityErrorFunc, &libxml_xmlSchemaValidityWarningFunc, pyCtxt);
return(py_retval);
}
static PyObject *
{
return(NULL);
{
{
}
}
return(Py_None);
}
#endif
#ifdef LIBXML_C14N_ENABLED
#ifdef LIBXML_OUTPUT_ENABLED
/************************************************************************
* *
* XML Canonicalization c14n *
* *
************************************************************************/
static int
{
int is_tuple = 0;
if (PyTuple_Check(py_nodeset))
is_tuple = 1;
else if (PyList_Check(py_nodeset))
is_tuple = 0;
else if (py_nodeset == Py_None) {
return 0;
}
else {
"must be a tuple or list of nodes.");
return -1;
}
return -1;
}
* sizeof(xmlNodePtr));
return -1;
}
{
int idx;
if (pynode)
}
}
return 0;
}
static int
{
/* NOTE: the array should be freed, but the strings are shared
with the python strings and so must not be freed. */
int is_tuple = 0;
int count;
int init_index = 0;
if (PyTuple_Check(py_strings))
is_tuple = 1;
else if (PyList_Check(py_strings))
is_tuple = 0;
else if (py_strings == Py_None) {
return 0;
}
else {
"must be a tuple or list of strings.");
return -1;
}
return -1;
}
{
int idx;
char* s = PyString_AsString
if (s)
else {
"must be a tuple or list of strings.");
return -1;
}
}
}
return 0;
}
static PyObject *
{
int exclusive;
int with_comments;
int result;
return (NULL);
if (!doc) {
return NULL;
}
if (exclusive) {
if (result < 0) {
if (nodes) {
}
return NULL;
}
}
&doc_txt);
if (nodes) {
}
if (prefixes) {
}
if (result < 0) {
"libxml2 xmlC14NDocDumpMemory failure.");
return NULL;
}
else {
result);
return py_retval;
}
}
static PyObject *
{
int exclusive;
int with_comments;
int result;
int len;
&py_file))
return (NULL);
if (!doc) {
return NULL;
}
return NULL;
}
return NULL;
}
if (exclusive) {
if (result < 0) {
if (nodes) {
}
return NULL;
}
}
buf);
if (nodes) {
}
if (prefixes) {
}
if (result < 0) {
"libxml2 xmlC14NDocSaveTo failure.");
return NULL;
}
else
return PyInt_FromLong((long) len);
}
#endif
#endif
static PyObject *
char *str;
return NULL;
}
static PyObject *
return NULL;
/* To compare two node objects, we compare their pointer addresses */
else
return Py_BuildValue((char *)"i", 0);
}
static PyObject *
return NULL;
/* For simplicity, we use the node pointer address as a hash value */
return PyLong_FromVoidPtr(node1);
}
/************************************************************************
* *
* The registration stuff *
* *
************************************************************************/
static PyMethodDef libxmlMethods[] = {
#include "libxml2-export.c"
#ifdef LIBXML_OUTPUT_ENABLED
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_SCHEMAS_ENABLED
#endif
#ifdef LIBXML_C14N_ENABLED
#ifdef LIBXML_OUTPUT_ENABLED
#endif
#endif
};
#ifdef MERGED_MODULES
extern void initlibxsltmod(void);
#endif
void
initlibxml2mod(void)
{
static int initialized = 0;
if (initialized != 0)
return;
/* intialize the python extension module */
/* initialize libxml2 */
initialized = 1;
#ifdef MERGED_MODULES
#endif
}