root / libcacard / vcard_emul_type.c @ 6f06f178
History | View | Annotate | Download (1.6 kB)
1 |
/*
|
---|---|
2 |
* This file contains utility functions which abstract the different card
|
3 |
* types. The goal is that new card types can easily be added by simply
|
4 |
* changing this file and vcard_emul_type.h. It is currently not a requirement
|
5 |
* to dynamically add new card types.
|
6 |
*
|
7 |
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
8 |
* See the COPYING.LIB file in the top-level directory.
|
9 |
*/
|
10 |
|
11 |
#include <strings.h> |
12 |
#include "vcardt.h" |
13 |
#include "vcard_emul_type.h" |
14 |
#include "cac.h" |
15 |
|
16 |
VCardStatus vcard_init(VReader *vreader, VCard *vcard, |
17 |
VCardEmulType type, const char *params, |
18 |
unsigned char *const *cert, int cert_len[], |
19 |
VCardKey *key[], int cert_count)
|
20 |
{ |
21 |
switch (type) {
|
22 |
case VCARD_EMUL_NONE:
|
23 |
break;
|
24 |
case VCARD_EMUL_CAC:
|
25 |
return cac_card_init(vreader, vcard, params,
|
26 |
cert, cert_len, key, cert_count); |
27 |
/* add new ones here */
|
28 |
default:
|
29 |
break;
|
30 |
} |
31 |
return VCARD_FAIL;
|
32 |
} |
33 |
|
34 |
VCardEmulType vcard_emul_type_select(VReader *vreader) |
35 |
{ |
36 |
#ifdef notdef
|
37 |
/* since there is only one emulator no need to call this function */
|
38 |
if (cac_is_cac_card(vreader) == VCARD_DONE) {
|
39 |
return VCARD_EMUL_CAC;
|
40 |
} |
41 |
#endif
|
42 |
/* return the default */
|
43 |
return VCARD_EMUL_CAC;
|
44 |
} |
45 |
|
46 |
VCardEmulType vcard_emul_type_from_string(const char *type_string) |
47 |
{ |
48 |
if (strcasecmp(type_string, "CAC") == 0) { |
49 |
return VCARD_EMUL_CAC;
|
50 |
} |
51 |
#ifdef USE_PASSTHRU
|
52 |
if (strcasecmp(type_string, "PASSTHRU") == 0) { |
53 |
return VCARD_EMUL_PASSTHRU;
|
54 |
} |
55 |
#endif
|
56 |
return VCARD_EMUL_NONE;
|
57 |
} |