void vnc_client_read(void *opaque)

{

    VncState *vs = opaque;

    long ret;



    buffer_reserve(&vs->input, 4096);



#ifdef CONFIG_VNC_TLS

    if (vs->tls.session) {

	ret = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096);

	if (ret < 0) {

	    if (ret == GNUTLS_E_AGAIN)

		errno = EAGAIN;

	    else

		errno = EIO;

	    ret = -1;

	}

    } else

#endif /* CONFIG_VNC_TLS */

	ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0);

    ret = vnc_client_io_error(vs, ret, socket_error());

    if (!ret)

	return;



    vs->input.offset += ret;



    while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {

	size_t len = vs->read_handler_expect;

	int ret;



	ret = vs->read_handler(vs, vs->input.buffer, len);

	if (vs->csock == -1)

	    return;



	if (!ret) {

	    memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));

	    vs->input.offset -= len;

	} else {

	    vs->read_handler_expect = ret;

	}

    }

}

void vnc_client_read(void *opaque)

{

    VncState *vs = opaque;

    long ret;



    buffer_reserve(&vs->input, 4096);



#ifdef CONFIG_VNC_TLS

    if (vs->tls.session) {

	ret = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096);

	if (ret < 0) {

	    if (ret == GNUTLS_E_AGAIN)

		errno = EAGAIN;

	    else

		errno = EIO;

	    ret = -1;

	}

    } else

#endif 

	ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0);

    ret = vnc_client_io_error(vs, ret, socket_error());

    if (!ret)

	return;



    vs->input.offset += ret;



    while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {

	size_t len = vs->read_handler_expect;

	int ret;



	ret = vs->read_handler(vs, vs->input.buffer, len);

	if (vs->csock == -1)

	    return;



	if (!ret) {

	    memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));

	    vs->input.offset -= len;

	} else {

	    vs->read_handler_expect = ret;

	}

    }

}

    VncState *vs = opaque;     ret = vnc_client_io_error(vs, ret, socket_error()); void vnc_client_read(void *opaque)     VncState *vs = opaque;     buffer_reserve(&vs->input, 4096); 	ret = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096); 	ret = recv(vs->csock, buffer_end(&vs->input), 4096, 0);     ret = vnc_client_io_error(vs, ret, socket_error());     if (!ret)
void FUNC_0(void *VAR_0)

{

    VncState *vs = VAR_0;

    long VAR_2;



    buffer_reserve(&vs->input, 4096);



#ifdef CONFIG_VNC_TLS

    if (vs->tls.session) {

	VAR_2 = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096);

	if (VAR_2 < 0) {

	    if (VAR_2 == GNUTLS_E_AGAIN)

		errno = EAGAIN;

	    else

		errno = EIO;

	    VAR_2 = -1;

	}

    } else

#endif 

	VAR_2 = recv(vs->csock, buffer_end(&vs->input), 4096, 0);

    VAR_2 = vnc_client_io_error(vs, VAR_2, socket_error());

    if (!VAR_2)

	return;



    vs->input.offset += VAR_2;



    while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) {

	size_t len = vs->read_handler_expect;

	int VAR_2;



	VAR_2 = vs->read_handler(vs, vs->input.buffer, len);

	if (vs->csock == -1)

	    return;



	if (!VAR_2) {

	    memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len));

	    vs->input.offset -= len;

	} else {

	    vs->read_handler_expect = VAR_2;

	}

    }

}

void FUNC_0(void *VAR_0)
{ VncState *vs = VAR_0; long VAR_2; buffer_reserve(&vs->input, 4096); #ifdef CONFIG_VNC_TLS
if (vs->tls.session) { VAR_2 = gnutls_read(vs->tls.session, buffer_end(&vs->input), 4096); if (VAR_2 < 0) { if (VAR_2 == GNUTLS_E_AGAIN)
errno = EAGAIN; else
errno = EIO; VAR_2 = -1; } } else #endif
VAR_2 = recv(vs->csock, buffer_end(&vs->input), 4096, 0); VAR_2 = vnc_client_io_error(vs, VAR_2, socket_error()); if (!VAR_2)
return; vs->input.offset += VAR_2; while (vs->read_handler && vs->input.offset >= vs->read_handler_expect) { size_t len = vs->read_handler_expect; int VAR_2; VAR_2 = vs->read_handler(vs, vs->input.buffer, len); if (vs->csock == -1)
return; if (!VAR_2) { memmove(vs->input.buffer, vs->input.buffer + len, (vs->input.offset - len)); vs->input.offset -= len; } else { vs->read_handler_expect = VAR_2; } } }