comparison simtool/atr.c @ 85:b57cf64ece29

fc-simtool project started
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 24 Jan 2021 00:32:10 +0000
parents
children
comparison
equal deleted inserted replaced
84:1d7d8615d628 85:b57cf64ece29
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 "globals.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 }