FreeCalypso > hg > fc-sim-tools
annotate simtool/main.c @ 53:fbedb67d234f
serial: fix parity for inverse coding convention
Important note: it is my (Mother Mychaela's) understanding that
SIM cards with inverse coding convention are extremely rare,
and I have never seen such a card. Therefore, our support for
the inverse coding convention will likely remain forever untested.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 21 Mar 2021 20:46:09 +0000 |
parents | e2ef4b8e4136 |
children | 3fe1954f5dec |
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]; |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 int rc; |
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); |
10
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 for (;;) { |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 if (isatty(0)) { |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 fputs("simtool> ", stdout); |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 fflush(stdout); |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (!fgets(command, sizeof command, stdin)) |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 good_exit(); |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 simtool_dispatch_cmd(command, 0); |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 } |
ddd767f6e15b
fc-simtool ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |