on_host_init(VSCMsgHeader *mhHeader, VSCMsgInit *incoming)

{

    uint32_t *capabilities = (incoming->capabilities);

    int num_capabilities =

        1 + ((mhHeader->length - sizeof(VSCMsgInit)) / sizeof(uint32_t));

    int i;

    QemuThread thread_id;



    incoming->version = ntohl(incoming->version);

    if (incoming->version != VSCARD_VERSION) {

        if (verbose > 0) {

            printf("warning: host has version %d, we have %d\n",

                verbose, VSCARD_VERSION);

        }

    }

    if (incoming->magic != VSCARD_MAGIC) {

        printf("unexpected magic: got %d, expected %d\n",

            incoming->magic, VSCARD_MAGIC);

        return -1;

    }

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

        capabilities[i] = ntohl(capabilities[i]);

    }

    /* Future: check capabilities */

    /* remove whatever reader might be left in qemu,

     * in case of an unclean previous exit. */

    send_msg(VSC_ReaderRemove, VSCARD_MINIMAL_READER_ID, NULL, 0);

    /* launch the event_thread. This will trigger reader adds for all the

     * existing readers */

    qemu_thread_create(&thread_id, "vsc/event", event_thread, NULL, 0);

    return 0;

}

on_host_init(VSCMsgHeader *mhHeader, VSCMsgInit *incoming)

{

    uint32_t *capabilities = (incoming->capabilities);

    int num_capabilities =

        1 + ((mhHeader->length - sizeof(VSCMsgInit)) / sizeof(uint32_t));

    int i;

    QemuThread thread_id;



    incoming->version = ntohl(incoming->version);

    if (incoming->version != VSCARD_VERSION) {

        if (verbose > 0) {

            printf("warning: host has version %d, we have %d\n",

                verbose, VSCARD_VERSION);

        }

    }

    if (incoming->magic != VSCARD_MAGIC) {

        printf("unexpected magic: got %d, expected %d\n",

            incoming->magic, VSCARD_MAGIC);

        return -1;

    }

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

        capabilities[i] = ntohl(capabilities[i]);

    }

    

    



    send_msg(VSC_ReaderRemove, VSCARD_MINIMAL_READER_ID, NULL, 0);

    



    qemu_thread_create(&thread_id, "vsc/event", event_thread, NULL, 0);

    return 0;

}

FUNC_0(VSCMsgHeader *VAR_0, VSCMsgInit *VAR_1)

{

    uint32_t *capabilities = (VAR_1->capabilities);

    int VAR_2 =

        1 + ((VAR_0->length - sizeof(VSCMsgInit)) / sizeof(uint32_t));

    int VAR_3;

    QemuThread thread_id;



    VAR_1->version = ntohl(VAR_1->version);

    if (VAR_1->version != VSCARD_VERSION) {

        if (verbose > 0) {

            printf("warning: host has version %d, we have %d\n",

                verbose, VSCARD_VERSION);

        }

    }

    if (VAR_1->magic != VSCARD_MAGIC) {

        printf("unexpected magic: got %d, expected %d\n",

            VAR_1->magic, VSCARD_MAGIC);

        return -1;

    }

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

        capabilities[VAR_3] = ntohl(capabilities[VAR_3]);

    }

    

    



    send_msg(VSC_ReaderRemove, VSCARD_MINIMAL_READER_ID, NULL, 0);

    



    qemu_thread_create(&thread_id, "vsc/event", event_thread, NULL, 0);

    return 0;

}

FUNC_0(VSCMsgHeader *VAR_0, VSCMsgInit *VAR_1)
{ uint32_t *capabilities = (VAR_1->capabilities); int VAR_2 =
1 + ((VAR_0->length - sizeof(VSCMsgInit)) / sizeof(uint32_t)); int VAR_3; QemuThread thread_id; VAR_1->version = ntohl(VAR_1->version); if (VAR_1->version != VSCARD_VERSION) { if (verbose > 0) { printf("warning: host has version %d, we have %d\n",
verbose, VSCARD_VERSION); } } if (VAR_1->magic != VSCARD_MAGIC) { printf("unexpected magic: got %d, expected %d\n",
VAR_1->magic, VSCARD_MAGIC); return -1; } for (VAR_3 = 0 ; VAR_3 < VAR_2; ++VAR_3) { capabilities[VAR_3] = ntohl(capabilities[VAR_3]); } send_msg(VSC_ReaderRemove, VSCARD_MINIMAL_READER_ID, NULL, 0); qemu_thread_create(&thread_id, "vsc/event", event_thread, NULL, 0); return 0; }