FreeCalypso > hg > fc-sim-tools
comparison pcsc/atrfunc.c @ 2:11f4f8a8fa33
pcsc: ATR code refactoring
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Mar 2021 01:22:37 +0000 |
parents | f7a03e53bb2c |
children |
comparison
equal
deleted
inserted
replaced
1:f7a03e53bb2c | 2:11f4f8a8fa33 |
---|---|
8 extern SCARDCONTEXT hContext; | 8 extern SCARDCONTEXT hContext; |
9 extern SCARDHANDLE hCard; | 9 extern SCARDHANDLE hCard; |
10 | 10 |
11 #define MAX_ATR_BYTES 33 | 11 #define MAX_ATR_BYTES 33 |
12 | 12 |
13 retrieve_atr(decor) | 13 retrieve_atr(head) |
14 char *head; | |
14 { | 15 { |
15 u_char atrbuf[MAX_ATR_BYTES]; | 16 u_char atrbuf[MAX_ATR_BYTES]; |
16 LONG rv; | 17 LONG rv; |
17 DWORD dwAttrLen; | 18 DWORD dwAttrLen; |
18 unsigned n; | 19 unsigned n; |
23 fprintf(stderr, "SCardGetAttrib for ATR: %s\n", | 24 fprintf(stderr, "SCardGetAttrib for ATR: %s\n", |
24 pcsc_stringify_error(rv)); | 25 pcsc_stringify_error(rv)); |
25 SCardReleaseContext(hContext); | 26 SCardReleaseContext(hContext); |
26 exit(1); | 27 exit(1); |
27 } | 28 } |
28 if (decor) | 29 fputs(head, stdout); |
29 printf("ATR:"); | |
30 for (n = 0; n < dwAttrLen; n++) { | 30 for (n = 0; n < dwAttrLen; n++) { |
31 if (decor) | 31 printf(" %02X", atrbuf[n]); |
32 putchar(' '); | |
33 printf("%02X", atrbuf[n]); | |
34 } | 32 } |
35 putchar('\n'); | 33 putchar('\n'); |
36 return(0); | 34 return(0); |
37 } | 35 } |