diff options
Diffstat (limited to 'bindings/lang_python_wrapper_top.c')
| -rw-r--r-- | bindings/lang_python_wrapper_top.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bindings/lang_python_wrapper_top.c b/bindings/lang_python_wrapper_top.c index 48ecc927..bcf670ec 100644 --- a/bindings/lang_python_wrapper_top.c +++ b/bindings/lang_python_wrapper_top.c @@ -5,6 +5,39 @@ GQuark lasso_wrapper_key; PyMODINIT_FUNC init_lasso(void); +static PyObject* get_pystring_from_xml_node(xmlNode *xmlnode); + +/* utility functions */ + +static PyObject* +get_pystring_from_xml_node(xmlNode *xmlnode) +{ + xmlOutputBufferPtr buf; + char *xmlString; + PyObject *pystring = NULL; + + if (xmlnode == NULL) { + return NULL; + } + + buf = xmlAllocOutputBuffer(NULL); + if (buf == NULL) { + xmlString = NULL; + } else { + xmlNodeDumpOutput(buf, NULL, xmlnode, 0, 1, NULL); + xmlOutputBufferFlush(buf); + if (buf->conv == NULL) { + pystring = PyString_FromString((char*)buf->buffer->content); + } else { + pystring = PyString_FromString((char*)buf->conv->content); + } + xmlOutputBufferClose(buf); + } + + return pystring; +} + +/* wrapper around GObject */ typedef struct { PyObject_HEAD |
