rsvg_handle_write (RsvgHandle * handle, const guchar * buf, gsize count, GError ** error)
{
    RsvgHandlePrivate *priv;

    rsvg_return_val_if_fail (handle, FALSE, error);
    priv = handle->priv;

    rsvg_return_val_if_fail (!priv->is_closed, FALSE, error);

    if (priv->first_write) {
        priv->first_write = FALSE;

        /* test for GZ marker. todo: store the first 2 bytes in the odd circumstance that someone calls
         * write() in 1 byte increments */
        if ((count >= 2) && (buf[0] == (guchar) 0x1f) && (buf[1] == (guchar) 0x8b)) {
#if GLIB_CHECK_VERSION (2, 24, 0)
            priv->data_input_stream = g_memory_input_stream_new ();
#elif defined (HAVE_GSF)
            priv->gzipped_data = GSF_OUTPUT (gsf_output_memory_new ());
#else
            g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                                 "GZip compressed SVG not supported");
            return FALSE;
#endif
        }
    }

#if GLIB_CHECK_VERSION (2, 24, 0)
    if (priv->data_input_stream) {
        g_memory_input_stream_add_data ((GMemoryInputStream *) priv->data_input_stream,
                                        g_memdup (buf, count), count, (GDestroyNotify) g_free);
        return TRUE;
    }
#elif defined (HAVE_GSF)
    if (priv->gzipped_data)
        return gsf_output_write (handle->priv->gzipped_data, count, buf);
#endif

    return rsvg_handle_write_impl (handle, buf, count, error);
}
rsvg_handle_write (RsvgHandle * handle, const guchar * buf, gsize count, GError ** error)
{
    RsvgHandlePrivate *priv;

    rsvg_return_val_if_fail (handle, FALSE, error);
    priv = handle->priv;

    rsvg_return_val_if_fail (!priv->is_closed, FALSE, error);

    if (priv->first_write) {
        priv->first_write = FALSE;

         
        if ((count >= 2) && (buf[0] == (guchar) 0x1f) && (buf[1] == (guchar) 0x8b)) {
#if GLIB_CHECK_VERSION (2, 24, 0)
            priv->data_input_stream = g_memory_input_stream_new ();
#elif defined (HAVE_GSF)
            priv->gzipped_data = GSF_OUTPUT (gsf_output_memory_new ());
#else
            g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                                 "GZip compressed SVG not supported");
            return FALSE;
#endif
        }
    }

#if GLIB_CHECK_VERSION (2, 24, 0)
    if (priv->data_input_stream) {
        g_memory_input_stream_add_data ((GMemoryInputStream *) priv->data_input_stream,
                                        g_memdup (buf, count), count, (GDestroyNotify) g_free);
        return TRUE;
    }
#elif defined (HAVE_GSF)
    if (priv->gzipped_data)
        return gsf_output_write (handle->priv->gzipped_data, count, buf);
#endif

    return rsvg_handle_write_impl (handle, buf, count, error);
}