int vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)

{

    int old_offset, new_offset, bytes_written;



    vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_ZLIB);



    // remember where we put in the follow-up size

    old_offset = vs->output.offset;

    vnc_write_s32(vs, 0);



    // compress the stream

    vnc_zlib_start(vs);

    vnc_raw_send_framebuffer_update(vs, x, y, w, h);

    bytes_written = vnc_zlib_stop(vs);



    if (bytes_written == -1)

        return 0;



    // hack in the size

    new_offset = vs->output.offset;

    vs->output.offset = old_offset;

    vnc_write_u32(vs, bytes_written);

    vs->output.offset = new_offset;



    return 1;

}

int vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)

{

    int old_offset, new_offset, bytes_written;



    vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_ZLIB);



    

    old_offset = vs->output.offset;

    vnc_write_s32(vs, 0);



    

    vnc_zlib_start(vs);

    vnc_raw_send_framebuffer_update(vs, x, y, w, h);

    bytes_written = vnc_zlib_stop(vs);



    if (bytes_written == -1)

        return 0;



    

    new_offset = vs->output.offset;

    vs->output.offset = old_offset;

    vnc_write_u32(vs, bytes_written);

    vs->output.offset = new_offset;



    return 1;

}

int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)

{

    int VAR_5, VAR_6, VAR_7;



    vnc_framebuffer_update(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VNC_ENCODING_ZLIB);



    

    VAR_5 = VAR_0->output.offset;

    vnc_write_s32(VAR_0, 0);



    

    vnc_zlib_start(VAR_0);

    vnc_raw_send_framebuffer_update(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);

    VAR_7 = vnc_zlib_stop(VAR_0);



    if (VAR_7 == -1)

        return 0;



    

    VAR_6 = VAR_0->output.offset;

    VAR_0->output.offset = VAR_5;

    vnc_write_u32(VAR_0, VAR_7);

    VAR_0->output.offset = VAR_6;



    return 1;

}

int FUNC_0(VncState *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4)
{ int VAR_5, VAR_6, VAR_7; vnc_framebuffer_update(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VNC_ENCODING_ZLIB); VAR_5 = VAR_0->output.offset; vnc_write_s32(VAR_0, 0); vnc_zlib_start(VAR_0); vnc_raw_send_framebuffer_update(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); VAR_7 = vnc_zlib_stop(VAR_0); if (VAR_7 == -1)
return 0; VAR_6 = VAR_0->output.offset; VAR_0->output.offset = VAR_5; vnc_write_u32(VAR_0, VAR_7); VAR_0->output.offset = VAR_6; return 1; }