static void ccid_card_vscard_handle_message(PassthruState *card,

    VSCMsgHeader *scr_msg_header)

{

    uint8_t *data = (uint8_t *)&scr_msg_header[1];



    switch (scr_msg_header->type) {

    case VSC_ATR:

        DPRINTF(card, D_INFO, "VSC_ATR %d\n", scr_msg_header->length);

        if (scr_msg_header->length > MAX_ATR_SIZE) {

            error_report("ATR size exceeds spec, ignoring");

            ccid_card_vscard_send_error(card, scr_msg_header->reader_id,

                                        VSC_GENERAL_ERROR);


        }

        memcpy(card->atr, data, scr_msg_header->length);

        card->atr_length = scr_msg_header->length;

        ccid_card_card_inserted(&card->base);

        ccid_card_vscard_send_error(card, scr_msg_header->reader_id,

                                    VSC_SUCCESS);


    case VSC_APDU:

        ccid_card_send_apdu_to_guest(

            &card->base, data, scr_msg_header->length);


    case VSC_CardRemove:

        DPRINTF(card, D_INFO, "VSC_CardRemove\n");

        ccid_card_card_removed(&card->base);

        ccid_card_vscard_send_error(card,

            scr_msg_header->reader_id, VSC_SUCCESS);


    case VSC_Init:

        ccid_card_vscard_handle_init(

            card, scr_msg_header, (VSCMsgInit *)data);


    case VSC_Error:

        ccid_card_card_error(&card->base, *(uint32_t *)data);


    case VSC_ReaderAdd:

        if (ccid_card_ccid_attach(&card->base) < 0) {

            ccid_card_vscard_send_error(card, VSCARD_UNDEFINED_READER_ID,

                                      VSC_CANNOT_ADD_MORE_READERS);

        } else {

            ccid_card_vscard_send_error(card, VSCARD_MINIMAL_READER_ID,

                                        VSC_SUCCESS);

        }


    case VSC_ReaderRemove:

        ccid_card_ccid_detach(&card->base);

        ccid_card_vscard_send_error(card,

            scr_msg_header->reader_id, VSC_SUCCESS);


    default:

        printf("usb-ccid: chardev: unexpected message of type %X\n",

               scr_msg_header->type);

        ccid_card_vscard_send_error(card, scr_msg_header->reader_id,

            VSC_GENERAL_ERROR);

    }

}
static void ccid_card_vscard_handle_message(PassthruState *card,

    VSCMsgHeader *scr_msg_header)

{

    uint8_t *data = (uint8_t *)&scr_msg_header[1];



    switch (scr_msg_header->type) {

    case VSC_ATR:

        DPRINTF(card, D_INFO, "VSC_ATR %d\n", scr_msg_header->length);

        if (scr_msg_header->length > MAX_ATR_SIZE) {

            error_report("ATR size exceeds spec, ignoring");

            ccid_card_vscard_send_error(card, scr_msg_header->reader_id,

                                        VSC_GENERAL_ERROR);


        }

        memcpy(card->atr, data, scr_msg_header->length);

        card->atr_length = scr_msg_header->length;

        ccid_card_card_inserted(&card->base);

        ccid_card_vscard_send_error(card, scr_msg_header->reader_id,

                                    VSC_SUCCESS);


    case VSC_APDU:

        ccid_card_send_apdu_to_guest(

            &card->base, data, scr_msg_header->length);


    case VSC_CardRemove:

        DPRINTF(card, D_INFO, "VSC_CardRemove\n");

        ccid_card_card_removed(&card->base);

        ccid_card_vscard_send_error(card,

            scr_msg_header->reader_id, VSC_SUCCESS);


    case VSC_Init:

        ccid_card_vscard_handle_init(

            card, scr_msg_header, (VSCMsgInit *)data);


    case VSC_Error:

        ccid_card_card_error(&card->base, *(uint32_t *)data);


    case VSC_ReaderAdd:

        if (ccid_card_ccid_attach(&card->base) < 0) {

            ccid_card_vscard_send_error(card, VSCARD_UNDEFINED_READER_ID,

                                      VSC_CANNOT_ADD_MORE_READERS);

        } else {

            ccid_card_vscard_send_error(card, VSCARD_MINIMAL_READER_ID,

                                        VSC_SUCCESS);

        }


    case VSC_ReaderRemove:

        ccid_card_ccid_detach(&card->base);

        ccid_card_vscard_send_error(card,

            scr_msg_header->reader_id, VSC_SUCCESS);


    default:

        printf("usb-ccid: chardev: unexpected message of type %X\n",

               scr_msg_header->type);

        ccid_card_vscard_send_error(card, scr_msg_header->reader_id,

            VSC_GENERAL_ERROR);

    }

}
static void FUNC_0(PassthruState *VAR_0,

    VSCMsgHeader *VAR_1)

{

    uint8_t *data = (uint8_t *)&VAR_1[1];



    switch (VAR_1->type) {

    case VSC_ATR:

        DPRINTF(VAR_0, D_INFO, "VSC_ATR %d\n", VAR_1->length);

        if (VAR_1->length > MAX_ATR_SIZE) {

            error_report("ATR size exceeds spec, ignoring");

            ccid_card_vscard_send_error(VAR_0, VAR_1->reader_id,

                                        VSC_GENERAL_ERROR);


        }

        memcpy(VAR_0->atr, data, VAR_1->length);

        VAR_0->atr_length = VAR_1->length;

        ccid_card_card_inserted(&VAR_0->base);

        ccid_card_vscard_send_error(VAR_0, VAR_1->reader_id,

                                    VSC_SUCCESS);


    case VSC_APDU:

        ccid_card_send_apdu_to_guest(

            &VAR_0->base, data, VAR_1->length);


    case VSC_CardRemove:

        DPRINTF(VAR_0, D_INFO, "VSC_CardRemove\n");

        ccid_card_card_removed(&VAR_0->base);

        ccid_card_vscard_send_error(VAR_0,

            VAR_1->reader_id, VSC_SUCCESS);


    case VSC_Init:

        ccid_card_vscard_handle_init(

            VAR_0, VAR_1, (VSCMsgInit *)data);


    case VSC_Error:

        ccid_card_card_error(&VAR_0->base, *(uint32_t *)data);


    case VSC_ReaderAdd:

        if (ccid_card_ccid_attach(&VAR_0->base) < 0) {

            ccid_card_vscard_send_error(VAR_0, VSCARD_UNDEFINED_READER_ID,

                                      VSC_CANNOT_ADD_MORE_READERS);

        } else {

            ccid_card_vscard_send_error(VAR_0, VSCARD_MINIMAL_READER_ID,

                                        VSC_SUCCESS);

        }


    case VSC_ReaderRemove:

        ccid_card_ccid_detach(&VAR_0->base);

        ccid_card_vscard_send_error(VAR_0,

            VAR_1->reader_id, VSC_SUCCESS);


    default:

        printf("usb-ccid: chardev: unexpected message of type %X\n",

               VAR_1->type);

        ccid_card_vscard_send_error(VAR_0, VAR_1->reader_id,

            VSC_GENERAL_ERROR);

    }

}
static void FUNC_0(PassthruState *VAR_0,
VSCMsgHeader *VAR_1)
{ uint8_t *data = (uint8_t *)&VAR_1[1]; switch (VAR_1->type) { case VSC_ATR:
DPRINTF(VAR_0, D_INFO, "VSC_ATR %d\n", VAR_1->length); if (VAR_1->length > MAX_ATR_SIZE) { error_report("ATR size exceeds spec, ignoring"); ccid_card_vscard_send_error(VAR_0, VAR_1->reader_id,
VSC_GENERAL_ERROR); } memcpy(VAR_0->atr, data, VAR_1->length); VAR_0->atr_length = VAR_1->length; ccid_card_card_inserted(&VAR_0->base); ccid_card_vscard_send_error(VAR_0, VAR_1->reader_id,
VSC_SUCCESS); case VSC_APDU:
ccid_card_send_apdu_to_guest(
&VAR_0->base, data, VAR_1->length); case VSC_CardRemove:
DPRINTF(VAR_0, D_INFO, "VSC_CardRemove\n"); ccid_card_card_removed(&VAR_0->base); ccid_card_vscard_send_error(VAR_0,
VAR_1->reader_id, VSC_SUCCESS); case VSC_Init:
ccid_card_vscard_handle_init(
VAR_0, VAR_1, (VSCMsgInit *)data); case VSC_Error:
ccid_card_card_error(&VAR_0->base, *(uint32_t *)data); case VSC_ReaderAdd:
if (ccid_card_ccid_attach(&VAR_0->base) < 0) { ccid_card_vscard_send_error(VAR_0, VSCARD_UNDEFINED_READER_ID,
VSC_CANNOT_ADD_MORE_READERS); } else { ccid_card_vscard_send_error(VAR_0, VSCARD_MINIMAL_READER_ID,
VSC_SUCCESS); } case VSC_ReaderRemove:
ccid_card_ccid_detach(&VAR_0->base); ccid_card_vscard_send_error(VAR_0,
VAR_1->reader_id, VSC_SUCCESS); default:
printf("usb-ccid: chardev: unexpected message of type %X\n",
VAR_1->type); ccid_card_vscard_send_error(VAR_0, VAR_1->reader_id,
VSC_GENERAL_ERROR); } }