FreeCalypso > hg > freecalypso-hwlab
comparison simtool/main.c @ 124:6c4567dd8946
fc-simtool: add non-interactive one-shot command (or script) mode
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Jan 2021 18:56:34 +0000 |
parents | b391204d3cd5 |
children |
comparison
equal
deleted
inserted
replaced
123:b391204d3cd5 | 124:6c4567dd8946 |
---|---|
7 | 7 |
8 main(argc, argv) | 8 main(argc, argv) |
9 char **argv; | 9 char **argv; |
10 { | 10 { |
11 char command[512]; | 11 char command[512]; |
12 int rc; | |
12 | 13 |
13 setup_pcsc_context(); | 14 setup_pcsc_context(); |
14 get_reader_name(); | 15 get_reader_name(); |
15 printf("Card reader name: %s\n", reader_name_buf); | 16 printf("Card reader name: %s\n", reader_name_buf); |
16 connect_to_card(); | 17 connect_to_card(); |
17 retrieve_atr(); | 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 } | |
18 for (;;) { | 26 for (;;) { |
19 if (isatty(0)) { | 27 if (isatty(0)) { |
20 fputs("simtool> ", stdout); | 28 fputs("simtool> ", stdout); |
21 fflush(stdout); | 29 fflush(stdout); |
22 } | 30 } |
23 if (!fgets(command, sizeof command, stdin)) | 31 if (!fgets(command, sizeof command, stdin)) |
24 cmd_exit(); | 32 good_exit(); |
25 simtool_dispatch_cmd(command, 0); | 33 simtool_dispatch_cmd(command, 0); |
26 } | 34 } |
27 } | 35 } |