diff options
Diffstat (limited to 'decode_converter.c')
-rw-r--r-- | decode_converter.c | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/decode_converter.c b/decode_converter.c deleted file mode 100644 index 102d059..0000000 --- a/decode_converter.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "decode_converter.h" - -#include <gio/gio.h> - -static void decode_converter_interface_init(GConverterIface *iface); -static void decode_converter_finalize(GObject *object); - -static GConverterResult decoder_converter_convert(GConverter *converter, - const void *inbuf, gsize inbuf_size, void *outbuf, gsize outbuf_size, - GConverterFlags flags, gsize *bytes_read, gsize *bytes_written, - GError **error); -static void decode_converter_reset(GConverter *converter); - -static GObjectClass *parent_class = NULL; - -G_DEFINE_TYPE_WITH_CODE(DecodeConverter, decode_converter, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE(G_TYPE_CONVERTER, - decode_converter_interface_init)); - -static void decode_converter_class_init(DecodeConverterClass *klass) { - GObjectClass *object_class; - - parent_class = (GObjectClass*)g_type_class_peek_parent(klass); - object_class = (GObjectClass*)klass; - object_class->finalize = decode_converter_finalize; -} - -static void decode_converter_interface_init(GConverterIface *iface) { - iface->convert = decoder_converter_convert; - iface->reset = decode_converter_reset; -} - -static void decode_converter_init(DecodeConverter *self) { -} - -static void decode_converter_finalize(GObject *object) { - DecodeConverter *dc; - - g_assert(CONVERTER_IS_DECODE(object)); - - dc = DECODE_CONVERTER(object); - - dc->decoder.decoder->close(dc->decoder.data); -} - -static GConverterResult decoder_converter_convert(GConverter *converter, - const void *inbuf, gsize inbuf_size, void *outbuf, gsize outbuf_size, - GConverterFlags flags, gsize *bytes_read, gsize *bytes_written, - GError **error) { - DecodeConverter *dc; - - dc = (DecodeConverter*)converter; - - gssize size = dc->decoder.decoder->decode(dc->decoder.data, inbuf, inbuf_size, outbuf, outbuf_size); - - if(size < 0) { - *error = g_error_new(g_quark_from_string("DecodeConverter"), - size, "decode() returned %ld", size); - return G_CONVERTER_ERROR; - } else if(size == 0) { - return G_CONVERTER_FINISHED; - } - *bytes_read = inbuf_size; - *bytes_written = size; - return G_CONVERTER_CONVERTED; -} - -static void decode_converter_reset(GConverter *converter) { - DecodeConverter *dc; - - dc = (DecodeConverter*)converter; - - dc->decoder.decoder->close(&dc->decoder.data); -} - -DecodeConverter *decode_converter_new(const struct decoder_plugin *decoder_plugin) { - DecodeConverter *dc; - - dc = (DecodeConverter*)g_object_new(CONVERTER_TYPE_DECODE, NULL); - - g_assert(dc != NULL); - - dc->decoder.decoder = decoder_plugin; - dc->decoder.decoder->init(&dc->decoder.data); - - return dc; -} |