FreeCalypso > hg > fc-sim-tools
annotate pcsc/atrmain.c @ 13:7c26eac6ab00
simtool/main.c: fix reader name and ATR display logic
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Mar 2021 07:22:13 +0000 |
parents | 11f4f8a8fa33 |
children |
rev | line source |
---|---|
1
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <stdio.h> |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <stdlib.h> |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <pcsclite.h> |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include <winscard.h> |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 extern SCARDCONTEXT hContext; |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 extern SCARDHANDLE hCard; |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 extern char *selected_reader; |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 main(argc, argv) |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 char **argv; |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 { |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 parse_reader_select_opt(argc, argv); |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 setup_pcsc_context(); |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 get_reader_list(); |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 select_reader_by_num(); |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 printf("Card reader name: %s\n", selected_reader); |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 connect_to_card(); |
2
11f4f8a8fa33
pcsc: ATR code refactoring
Mychaela Falconia <falcon@freecalypso.org>
parents:
1
diff
changeset
|
19 retrieve_atr("ATR:"); |
1
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 SCardDisconnect(hCard, SCARD_UNPOWER_CARD); |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 SCardReleaseContext(hContext); |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 exit(0); |
f7a03e53bb2c
fc-pcsc-atr ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } |