annotate simtool/main.c @ 85:c179deb9bb39

uicc/writecmd.c: forgot to update #include header set
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 11 Apr 2021 02:48:22 +0000
parents 3fe1954f5dec
children
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[];
46
e2ef4b8e4136 main tools: display spenh info when serial back end is used
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
7 extern char be_extra_info[];
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 main(argc, argv)
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 char **argv;
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 {
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 extern int optind;
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 char command[512];
77
3fe1954f5dec fc-simtool batch stdin mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 46
diff changeset
14 int rc, batch_stdin;
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 parse_global_options(argc, argv);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 launch_backend();
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 collect_backend_init_strings();
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (argc > optind) {
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 rc = dispatch_ready_argv(argc - optind, argv + optind);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (rc)
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 exit(1);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 else
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 good_exit();
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
13
7c26eac6ab00 simtool/main.c: fix reader name and ATR display logic
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
26 if (be_reader_name[0])
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 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
28 if (be_atr_string[0])
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 printf("ATR: %s\n", be_atr_string);
46
e2ef4b8e4136 main tools: display spenh info when serial back end is used
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
30 if (be_extra_info[0])
e2ef4b8e4136 main tools: display spenh info when serial back end is used
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
31 puts(be_extra_info);
77
3fe1954f5dec fc-simtool batch stdin mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 46
diff changeset
32 batch_stdin = !isatty(0);
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 for (;;) {
77
3fe1954f5dec fc-simtool batch stdin mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 46
diff changeset
34 if (!batch_stdin) {
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 fputs("simtool> ", stdout);
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 fflush(stdout);
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 if (!fgets(command, sizeof command, stdin))
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 good_exit();
77
3fe1954f5dec fc-simtool batch stdin mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 46
diff changeset
40 if (batch_stdin)
3fe1954f5dec fc-simtool batch stdin mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 46
diff changeset
41 printf("Stdin command: %s", command);
3fe1954f5dec fc-simtool batch stdin mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 46
diff changeset
42 rc = simtool_dispatch_cmd(command, 0);
3fe1954f5dec fc-simtool batch stdin mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 46
diff changeset
43 if (batch_stdin && rc)
3fe1954f5dec fc-simtool batch stdin mode implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 46
diff changeset
44 exit(1);
10
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
ddd767f6e15b fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }