static void pty_chr_read(void *opaque)

{

    CharDriverState *chr = opaque;

    PtyCharDriver *s = chr->opaque;

    int size, len;

    uint8_t buf[1024];



    len = sizeof(buf);

    if (len > s->read_bytes)

        len = s->read_bytes;

    if (len == 0)

        return;

    size = read(s->fd, buf, len);

    if ((size == -1 && errno == EIO) ||

        (size == 0)) {

        pty_chr_state(chr, 0);

        return;

    }

    if (size > 0) {

        pty_chr_state(chr, 1);

        qemu_chr_read(chr, buf, size);

    }

}

static void pty_chr_read(void *opaque)

{

    CharDriverState *chr = opaque;

    PtyCharDriver *s = chr->opaque;

    int size, len;

    uint8_t buf[1024];



    len = sizeof(buf);

    if (len > s->read_bytes)

        len = s->read_bytes;

    if (len == 0)

        return;

    size = read(s->fd, buf, len);

    if ((size == -1 && errno == EIO) ||

        (size == 0)) {

        pty_chr_state(chr, 0);

        return;

    }

    if (size > 0) {

        pty_chr_state(chr, 1);

        qemu_chr_read(chr, buf, size);

    }

}

static void FUNC_0(void *VAR_0)

{

    CharDriverState *chr = VAR_0;

    PtyCharDriver *s = chr->VAR_0;

    int VAR_1, VAR_2;

    uint8_t buf[1024];



    VAR_2 = sizeof(buf);

    if (VAR_2 > s->read_bytes)

        VAR_2 = s->read_bytes;

    if (VAR_2 == 0)

        return;

    VAR_1 = read(s->fd, buf, VAR_2);

    if ((VAR_1 == -1 && errno == EIO) ||

        (VAR_1 == 0)) {

        pty_chr_state(chr, 0);

        return;

    }

    if (VAR_1 > 0) {

        pty_chr_state(chr, 1);

        qemu_chr_read(chr, buf, VAR_1);

    }

}

static void FUNC_0(void *VAR_0)
{ CharDriverState *chr = VAR_0; PtyCharDriver *s = chr->VAR_0; int VAR_1, VAR_2; uint8_t buf[1024]; VAR_2 = sizeof(buf); if (VAR_2 > s->read_bytes)
VAR_2 = s->read_bytes; if (VAR_2 == 0)
return; VAR_1 = read(s->fd, buf, VAR_2); if ((VAR_1 == -1 && errno == EIO) ||
(VAR_1 == 0)) { pty_chr_state(chr, 0); return; } if (VAR_1 > 0) { pty_chr_state(chr, 1); qemu_chr_read(chr, buf, VAR_1); } }