FreeCalypso > hg > fc-pcsc-tools
comparison simtool/main.c @ 1:2071b28cd0c7
simtool: first refactored version
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 11 Feb 2021 23:04:28 +0000 |
| parents | |
| children | 78f93e3c9ebf |
comparison
equal
deleted
inserted
replaced
| 0:f7145c77b7fb | 1:2071b28cd0c7 |
|---|---|
| 1 #include <sys/types.h> | |
| 2 #include <stdio.h> | |
| 3 #include <stdlib.h> | |
| 4 #include <pcsclite.h> | |
| 5 #include <winscard.h> | |
| 6 #include "cardif.h" | |
| 7 | |
| 8 main(argc, argv) | |
| 9 char **argv; | |
| 10 { | |
| 11 char command[512]; | |
| 12 int rc; | |
| 13 | |
| 14 setup_pcsc_context(); | |
| 15 get_reader_name(); | |
| 16 printf("Card reader name: %s\n", reader_name_buf); | |
| 17 connect_to_card(); | |
| 18 retrieve_atr(); | |
| 19 if (argc >= 2) { | |
| 20 rc = dispatch_ready_argv(argc - 1, argv + 1); | |
| 21 if (rc) | |
| 22 error_exit(); | |
| 23 else | |
| 24 good_exit(); | |
| 25 } | |
| 26 for (;;) { | |
| 27 if (isatty(0)) { | |
| 28 fputs("simtool> ", stdout); | |
| 29 fflush(stdout); | |
| 30 } | |
| 31 if (!fgets(command, sizeof command, stdin)) | |
| 32 good_exit(); | |
| 33 simtool_dispatch_cmd(command, 0); | |
| 34 } | |
| 35 } |
