FreeCalypso > hg > freecalypso-hwlab
annotate simtool/atr.c @ 137:c331560c15a4
fc-uicc-tool: dir command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 04 Feb 2021 04:27:09 +0000 |
parents | b57cf64ece29 |
children |
rev | line source |
---|---|
85
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <stdio.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <stdlib.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include <pcsclite.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <winscard.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <reader.h> |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "globals.h" |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #define MAX_ATR_BYTES 33 |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 retrieve_atr() |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 { |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 u_char atrbuf[MAX_ATR_BYTES]; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 LONG rv; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 DWORD dwAttrLen; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 unsigned n; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 dwAttrLen = MAX_ATR_BYTES; |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, atrbuf, &dwAttrLen); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (rv != SCARD_S_SUCCESS) { |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 fprintf(stderr, "SCardGetAttrib for ATR: %s\n", |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 pcsc_stringify_error(rv)); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return(-1); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 printf("ATR:"); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 for (n = 0; n < dwAttrLen; n++) |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 printf(" %02X", atrbuf[n]); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 putchar('\n'); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 return(0); |
b57cf64ece29
fc-simtool project started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |