static void vnc_connect(VncDisplay *vd, int csock)

{

    VncState *vs = qemu_mallocz(sizeof(VncState));

    int i;



    vs->csock = csock;

    vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));

    for (i = 0; i < VNC_STAT_ROWS; ++i) {

        vs->lossy_rect[i] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t));

    }



    VNC_DEBUG("New client on socket %d\n", csock);

    dcl->idle = 0;

    socket_set_nonblock(vs->csock);

    qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);



    vnc_client_cache_addr(vs);

    vnc_qmp_event(vs, QEVENT_VNC_CONNECTED);



    vs->vd = vd;

    vs->ds = vd->ds;

    vs->last_x = -1;

    vs->last_y = -1;



    vs->as.freq = 44100;

    vs->as.nchannels = 2;

    vs->as.fmt = AUD_FMT_S16;

    vs->as.endianness = 0;



#ifdef CONFIG_VNC_THREAD

    qemu_mutex_init(&vs->output_mutex);

#endif



    QTAILQ_INSERT_HEAD(&vd->clients, vs, next);



    vga_hw_update();



    vnc_write(vs, "RFB 003.008\n", 12);

    vnc_flush(vs);

    vnc_read_when(vs, protocol_version, 12);

    reset_keys(vs);

    if (vs->vd->lock_key_sync)

        vs->led = qemu_add_led_event_handler(kbd_leds, vs);



    vs->mouse_mode_notifier.notify = check_pointer_type_change;

    qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);



    vnc_init_timer(vd);



    /* vs might be free()ed here */

}

static void vnc_connect(VncDisplay *vd, int csock)

{

    VncState *vs = qemu_mallocz(sizeof(VncState));

    int i;



    vs->csock = csock;

    vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));

    for (i = 0; i < VNC_STAT_ROWS; ++i) {

        vs->lossy_rect[i] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t));

    }



    VNC_DEBUG("New client on socket %d\n", csock);

    dcl->idle = 0;

    socket_set_nonblock(vs->csock);

    qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs);



    vnc_client_cache_addr(vs);

    vnc_qmp_event(vs, QEVENT_VNC_CONNECTED);



    vs->vd = vd;

    vs->ds = vd->ds;

    vs->last_x = -1;

    vs->last_y = -1;



    vs->as.freq = 44100;

    vs->as.nchannels = 2;

    vs->as.fmt = AUD_FMT_S16;

    vs->as.endianness = 0;



#ifdef CONFIG_VNC_THREAD

    qemu_mutex_init(&vs->output_mutex);

#endif



    QTAILQ_INSERT_HEAD(&vd->clients, vs, next);



    vga_hw_update();



    vnc_write(vs, "RFB 003.008\n", 12);

    vnc_flush(vs);

    vnc_read_when(vs, protocol_version, 12);

    reset_keys(vs);

    if (vs->vd->lock_key_sync)

        vs->led = qemu_add_led_event_handler(kbd_leds, vs);



    vs->mouse_mode_notifier.notify = check_pointer_type_change;

    qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);



    vnc_init_timer(vd);



    

}

static void FUNC_0(VncDisplay *VAR_0, int VAR_1)

{

    VncState *vs = qemu_mallocz(sizeof(VncState));

    int VAR_2;



    vs->VAR_1 = VAR_1;

    vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect));

    for (VAR_2 = 0; VAR_2 < VNC_STAT_ROWS; ++VAR_2) {

        vs->lossy_rect[VAR_2] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t));

    }



    VNC_DEBUG("New client on socket %d\n", VAR_1);

    dcl->idle = 0;

    socket_set_nonblock(vs->VAR_1);

    qemu_set_fd_handler2(vs->VAR_1, NULL, vnc_client_read, NULL, vs);



    vnc_client_cache_addr(vs);

    vnc_qmp_event(vs, QEVENT_VNC_CONNECTED);



    vs->VAR_0 = VAR_0;

    vs->ds = VAR_0->ds;

    vs->last_x = -1;

    vs->last_y = -1;



    vs->as.freq = 44100;

    vs->as.nchannels = 2;

    vs->as.fmt = AUD_FMT_S16;

    vs->as.endianness = 0;



#ifdef CONFIG_VNC_THREAD

    qemu_mutex_init(&vs->output_mutex);

#endif



    QTAILQ_INSERT_HEAD(&VAR_0->clients, vs, next);



    vga_hw_update();



    vnc_write(vs, "RFB 003.008\n", 12);

    vnc_flush(vs);

    vnc_read_when(vs, protocol_version, 12);

    reset_keys(vs);

    if (vs->VAR_0->lock_key_sync)

        vs->led = qemu_add_led_event_handler(kbd_leds, vs);



    vs->mouse_mode_notifier.notify = check_pointer_type_change;

    qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);



    vnc_init_timer(VAR_0);



    

}

static void FUNC_0(VncDisplay *VAR_0, int VAR_1)
{ VncState *vs = qemu_mallocz(sizeof(VncState)); int VAR_2; vs->VAR_1 = VAR_1; vs->lossy_rect = qemu_mallocz(VNC_STAT_ROWS * sizeof (*vs->lossy_rect)); for (VAR_2 = 0; VAR_2 < VNC_STAT_ROWS; ++VAR_2) { vs->lossy_rect[VAR_2] = qemu_mallocz(VNC_STAT_COLS * sizeof (uint8_t)); } VNC_DEBUG("New client on socket %d\n", VAR_1); dcl->idle = 0; socket_set_nonblock(vs->VAR_1); qemu_set_fd_handler2(vs->VAR_1, NULL, vnc_client_read, NULL, vs); vnc_client_cache_addr(vs); vnc_qmp_event(vs, QEVENT_VNC_CONNECTED); vs->VAR_0 = VAR_0; vs->ds = VAR_0->ds; vs->last_x = -1; vs->last_y = -1; vs->as.freq = 44100; vs->as.nchannels = 2; vs->as.fmt = AUD_FMT_S16; vs->as.endianness = 0; #ifdef CONFIG_VNC_THREAD
qemu_mutex_init(&vs->output_mutex); #endif
QTAILQ_INSERT_HEAD(&VAR_0->clients, vs, next); vga_hw_update(); vnc_write(vs, "RFB 003.008\n", 12); vnc_flush(vs); vnc_read_when(vs, protocol_version, 12); reset_keys(vs); if (vs->VAR_0->lock_key_sync)
vs->led = qemu_add_led_event_handler(kbd_leds, vs); vs->mouse_mode_notifier.notify = check_pointer_type_change; qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier); vnc_init_timer(VAR_0); }