source: trunk/src/ifd/proto-escape.c @ 964

Revision 964, 1.8 KB checked in by aj, 5 years ago (diff)

indent changes only.

Line 
1/*
2 * Escape protocol - simply pass everything to the reader driver's escape()
3 *
4 * This is required for exporting access to vendor-specific CCID extensions,
5 * such as the Omnikey CardMan 5121 RFID support.
6 *
7 * The higher-level applications select a virtual slot (the last available slot
8 * number).  This virtual slot will automatically get the IFD_PROTOCOL_ESCAPE
9 * assgigned to it and can then be used to transceive() data to/from the CCID.
10 *
11 * It's a bit ugly, but I was unable to come up with something cleaner.
12 *
13 * Copyright (C) 2005, Harald Welte <laforge@gnumonks.org>
14 */
15
16#include "internal.h"
17#include <unistd.h>
18#include <stdlib.h>
19#include <string.h>
20
21static int escape_init(ifd_protocol_t * prot)
22{
23        ifd_reader_t *reader = prot->reader;
24        const ifd_driver_t *drv;
25
26        if (!reader || !(drv = reader->driver)
27            || !drv->ops || !drv->ops->escape)
28                return -1;
29        return 0;
30}
31
32static void escape_release(ifd_protocol_t * prot)
33{
34        /* NOP */
35}
36
37static int escape_set_param(ifd_protocol_t * prot, int type, long value)
38{
39        ct_error("set_pameter not supported");
40        return -1;
41}
42
43static int escape_get_param(ifd_protocol_t * prot, int type, long *result)
44{
45        ct_error("get_pameter not supported");
46        return -1;
47}
48
49static int
50escape_transceive(ifd_protocol_t * prot, int dad,
51                  const void *sbuf, size_t slen, void *rbuf, size_t rlen)
52{
53        ifd_reader_t *reader = prot->reader;
54        const ifd_driver_t *drv = reader->driver;
55
56        return drv->ops->escape(reader, dad, sbuf, slen, rbuf, rlen);
57}
58
59struct ifd_protocol_ops ifd_protocol_esc = {
60        IFD_PROTOCOL_ESCAPE,    /* id */
61        "escape",               /* name */
62        sizeof(ifd_protocol_t), /* size */
63        escape_init,            /* init */
64        escape_release,         /* release */
65        escape_set_param,       /* set_param */
66        escape_get_param,       /* get_param */
67        NULL,                   /* resynchronize */
68        escape_transceive,      /* transceive */
69        NULL,                   /* sync_read */
70        NULL,                   /* sync_write */
71};
Note: See TracBrowser for help on using the repository browser.