FreeCalypso > hg > fc-pcsc-tools
comparison libcommon/atr.c @ 0:f7145c77b7fb
starting libcommon: factored out of fc-simtool
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 11 Feb 2021 22:28:45 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f7145c77b7fb |
---|---|
1 #include <sys/types.h> | |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 #include <pcsclite.h> | |
5 #include <winscard.h> | |
6 #include <reader.h> | |
7 #include "cardif.h" | |
8 | |
9 #define MAX_ATR_BYTES 33 | |
10 | |
11 retrieve_atr() | |
12 { | |
13 u_char atrbuf[MAX_ATR_BYTES]; | |
14 LONG rv; | |
15 DWORD dwAttrLen; | |
16 unsigned n; | |
17 | |
18 dwAttrLen = MAX_ATR_BYTES; | |
19 rv = SCardGetAttrib(hCard, SCARD_ATTR_ATR_STRING, atrbuf, &dwAttrLen); | |
20 if (rv != SCARD_S_SUCCESS) { | |
21 fprintf(stderr, "SCardGetAttrib for ATR: %s\n", | |
22 pcsc_stringify_error(rv)); | |
23 return(-1); | |
24 } | |
25 printf("ATR:"); | |
26 for (n = 0; n < dwAttrLen; n++) | |
27 printf(" %02X", atrbuf[n]); | |
28 putchar('\n'); | |
29 return(0); | |
30 } |