FreeCalypso > hg > fc-sim-tools
annotate calypso/targetfd.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 | deeeef558279 |
children |
rev | line source |
---|---|
4
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <stdio.h> |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <stdlib.h> |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <unistd.h> |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 int target_fd; |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 parse_target_fd_opt(argc, argv) |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 char **argv; |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 { |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 extern char *optarg; |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 int c; |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 while ((c = getopt(argc, argv, "C:")) != EOF) { |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 switch (c) { |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 case 'C': |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 target_fd = atoi(optarg); |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 continue; |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 case '?': |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 default: |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 /* error msg already printed */ |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 exit(1); |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 } |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (!target_fd) { |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 fprintf(stderr, "error: target fd must be given with -C\n"); |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(1); |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 return(0); |
deeeef558279
fcsim-calypso-be put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |