long vnc_client_read_ws(VncState *vs)

{

    int ret, err;

    uint8_t *payload;

    size_t payload_size, frame_size;

    VNC_DEBUG("Read websocket %p size %zd offset %zd\n", vs->ws_input.buffer,

            vs->ws_input.capacity, vs->ws_input.offset);

    buffer_reserve(&vs->ws_input, 4096);

    ret = vnc_client_read_buf(vs, buffer_end(&vs->ws_input), 4096);

    if (!ret) {

        return 0;

    }

    vs->ws_input.offset += ret;



    /* make sure that nothing is left in the ws_input buffer */

    do {

        err = vncws_decode_frame(&vs->ws_input, &payload,

                              &payload_size, &frame_size);

        if (err <= 0) {

            return err;

        }



        buffer_reserve(&vs->input, payload_size);

        buffer_append(&vs->input, payload, payload_size);



        buffer_advance(&vs->ws_input, frame_size);

    } while (vs->ws_input.offset > 0);



    return ret;

}

long vnc_client_read_ws(VncState *vs)

{

    int ret, err;

    uint8_t *payload;

    size_t payload_size, frame_size;

    VNC_DEBUG("Read websocket %p size %zd offset %zd\n", vs->ws_input.buffer,

            vs->ws_input.capacity, vs->ws_input.offset);

    buffer_reserve(&vs->ws_input, 4096);

    ret = vnc_client_read_buf(vs, buffer_end(&vs->ws_input), 4096);

    if (!ret) {

        return 0;

    }

    vs->ws_input.offset += ret;



    

    do {

        err = vncws_decode_frame(&vs->ws_input, &payload,

                              &payload_size, &frame_size);

        if (err <= 0) {

            return err;

        }



        buffer_reserve(&vs->input, payload_size);

        buffer_append(&vs->input, payload, payload_size);



        buffer_advance(&vs->ws_input, frame_size);

    } while (vs->ws_input.offset > 0);



    return ret;

}

    size_t payload_size, frame_size;         err = vncws_decode_frame(&vs->ws_input, &payload,                               &payload_size, &frame_size);         if (err <= 0) {             return err;         buffer_reserve(&vs->input, payload_size);         buffer_append(&vs->input, payload, payload_size);         buffer_advance(&vs->ws_input, frame_size);
long FUNC_0(VncState *VAR_0)

{

    int VAR_1, VAR_2;

    uint8_t *payload;

    size_t payload_size, frame_size;

    VNC_DEBUG("Read websocket %p size %zd offset %zd\n", VAR_0->ws_input.buffer,

            VAR_0->ws_input.capacity, VAR_0->ws_input.offset);

    buffer_reserve(&VAR_0->ws_input, 4096);

    VAR_1 = vnc_client_read_buf(VAR_0, buffer_end(&VAR_0->ws_input), 4096);

    if (!VAR_1) {

        return 0;

    }

    VAR_0->ws_input.offset += VAR_1;



    

    do {

        VAR_2 = vncws_decode_frame(&VAR_0->ws_input, &payload,

                              &payload_size, &frame_size);

        if (VAR_2 <= 0) {

            return VAR_2;

        }



        buffer_reserve(&VAR_0->input, payload_size);

        buffer_append(&VAR_0->input, payload, payload_size);



        buffer_advance(&VAR_0->ws_input, frame_size);

    } while (VAR_0->ws_input.offset > 0);



    return VAR_1;

}

long FUNC_0(VncState *VAR_0)
{ int VAR_1, VAR_2; uint8_t *payload; size_t payload_size, frame_size; VNC_DEBUG("Read websocket %p size %zd offset %zd\n", VAR_0->ws_input.buffer,
VAR_0->ws_input.capacity, VAR_0->ws_input.offset); buffer_reserve(&VAR_0->ws_input, 4096); VAR_1 = vnc_client_read_buf(VAR_0, buffer_end(&VAR_0->ws_input), 4096); if (!VAR_1) { return 0; } VAR_0->ws_input.offset += VAR_1; do { VAR_2 = vncws_decode_frame(&VAR_0->ws_input, &payload,
&payload_size, &frame_size); if (VAR_2 <= 0) { return VAR_2; } buffer_reserve(&VAR_0->input, payload_size); buffer_append(&VAR_0->input, payload, payload_size); buffer_advance(&VAR_0->ws_input, frame_size); } while (VAR_0->ws_input.offset > 0); return VAR_1; }