FreeCalypso > hg > fc-pcsc-tools
annotate libcommon/globalopts.c @ 110:2aa92dfcb4b5
fc-simtool iccid, imsi, spn: support output redirection
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 19 Feb 2021 06:59:56 +0000 |
parents | 91bcf84a5323 |
children |
rev | line source |
---|---|
34
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements parsing of global command line options. |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <unistd.h> |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 extern unsigned select_reader_num; |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 parse_global_options(argc, argv) |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 char **argv; |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 extern char *optarg; |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int c; |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 while ((c = getopt(argc, argv, "+p:")) != EOF) { |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 switch (c) { |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 case 'p': |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 select_reader_num = atoi(optarg); |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 continue; |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 case '?': |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 default: |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* error msg already printed */ |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 exit(1); |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 return(0); |
91bcf84a5323
-p reader selection implemented in fc-pcsc-atr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |