2
* Copyright © 2010 Christian Persch
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public License as
6
* published by the Free Software Foundation; either version 2.1 of the
7
* License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
26
GCancellable *cancellable;
28
} RsvgXmlInputStreamContext;
30
/* this should use gsize, but libxml2 is borked */
32
context_read (RsvgXmlInputStreamContext *context,
38
if (*(context->error))
41
n_read = g_input_stream_read (context->stream, buffer, (gsize) len,
51
context_close (RsvgXmlInputStreamContext *context)
55
/* Don't overwrite a previous error */
56
ret = g_input_stream_close (context->stream, context->cancellable,
57
*(context->error) == NULL ? context->error : NULL);
59
g_object_unref (context->stream);
60
if (context->cancellable)
61
g_object_unref (context->cancellable);
62
g_slice_free (RsvgXmlInputStreamContext, context);
68
* _rsvg_xml_input_buffer_new_from_stream:
69
* @context: a #xmlParserCtxtPtr
70
* @input_stream: a #GInputStream
72
* Returns: a new #xmlParserInputPtr wrapping @input_stream
74
xmlParserInputBufferPtr
75
_rsvg_xml_input_buffer_new_from_stream (GInputStream *stream,
76
GCancellable *cancellable,
81
RsvgXmlInputStreamContext *context;
83
g_return_val_if_fail (G_IS_INPUT_STREAM (stream), NULL);
84
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
85
g_return_val_if_fail (error != NULL, NULL);
87
context = g_slice_new (RsvgXmlInputStreamContext);
88
context->stream = g_object_ref (stream);
89
context->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
90
context->error = error;
92
return xmlParserInputBufferCreateIO ((xmlInputReadCallback) context_read,
93
(xmlInputCloseCallback) context_close,