annotate simtool/main.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 ddd767f6e15b
children e2ef4b8e4136
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <stdio.h>
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdlib.h>
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <unistd.h>
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 extern char be_reader_name[];
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 extern char be_atr_string[];
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 main(argc, argv)
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 char **argv;
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 {
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 extern int optind;
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 char command[512];
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 int rc;
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 parse_global_options(argc, argv);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 launch_backend();
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 collect_backend_init_strings();
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (argc > optind) {
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 rc = dispatch_ready_argv(argc - optind, argv + optind);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 if (rc)
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 exit(1);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 else
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 good_exit();
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
13
7c26eac6ab00 simtool/main.c: fix reader name and ATR display logic
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
25 if (be_reader_name[0])
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 printf("Card reader name: %s\n", be_reader_name);
13
7c26eac6ab00 simtool/main.c: fix reader name and ATR display logic
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
27 if (be_atr_string[0])
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 printf("ATR: %s\n", be_atr_string);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 for (;;) {
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if (isatty(0)) {
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 fputs("simtool> ", stdout);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 fflush(stdout);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (!fgets(command, sizeof command, stdin))
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 good_exit();
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 simtool_dispatch_cmd(command, 0);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }