~ubuntu-branches/ubuntu/utopic/lasso/utopic-proposed

« back to all changes in this revision

Viewing changes to bindings/java/wrapper_top.c

  • Committer: Package Import Robot
  • Author(s): Frederic Peters
  • Date: 2014-01-07 13:22:21 UTC
  • mfrom: (1.1.11) (7.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20140107132221-htp0go0s9z5lqvj8
Tags: 2.4.0-1
* New upstream version.
* debian/control, debian/rules: use autoreconf
* debian/source/version: switch to 3.0 (quilt)

Show diffs side-by-side

added added

removed removed

Lines of Context:
282
282
 
283
283
 
284
284
/* xmlNode handling */
 
285
static xmlBuffer*
 
286
xmlnode_to_xmlbuffer(xmlNode *node)
 
287
{
 
288
        xmlOutputBufferPtr output_buffer;
 
289
        xmlBuffer *buffer;
 
290
 
 
291
        if (! node)
 
292
                return NULL;
 
293
 
 
294
        buffer = xmlBufferCreate();
 
295
        output_buffer = xmlOutputBufferCreateBuffer(buffer, NULL);
 
296
        xmlNodeDumpOutput(output_buffer, NULL, node, 0, 0, NULL);
 
297
        xmlOutputBufferClose(output_buffer);
 
298
        xmlBufferAdd(buffer, BAD_CAST "", 1);
 
299
 
 
300
        return buffer;
 
301
}
 
302
 
285
303
static int
286
304
xml_node_to_jstring(JNIEnv *env, xmlNode *xmlnode, jstring *jstr) {
287
 
    xmlOutputBufferPtr buf = NULL;
 
305
    xmlBuffer *buffer;
288
306
 
289
307
    g_error_if_fail(env);
290
308
    if (! xmlnode) {
291
309
        *jstr = NULL;
292
310
        return 1;
293
311
    }
294
 
 
295
 
    buf = xmlAllocOutputBuffer(NULL);
296
 
    if (buf) {
297
 
        int ret = 1;
298
 
        xmlNodeDumpOutput(buf, NULL, xmlnode, 0, 1, NULL);
299
 
        xmlOutputBufferFlush(buf);
300
 
        xmlChar *str = NULL;
301
 
        if (buf->conv == NULL) {
302
 
            str = buf->buffer->content;
303
 
        } else {
304
 
            str = buf->conv->content;
305
 
        }
306
 
        ret = string_to_jstring(env, (char*)str, jstr);
307
 
        xmlOutputBufferClose(buf);
308
 
        return ret;
309
 
    } else {
 
312
    buffer = xmlnode_to_xmlbuffer(xmlnode);
 
313
    if (! buffer) {
310
314
        exception(env, "could not alloc an xml output buffer");
311
315
        return 0;
312
316
    }
313
 
    return 1;
 
317
    return string_to_jstring(env, (char*)xmlBufferContent(buffer), jstr);
314
318
}
315
319
 
316
320
/** Convert a java string to an xml node. Return 0 if it failed with an exception