FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/fsiomain.c @ 1032:6e7dd5e52650
gsm-fw feature tch-reroute: B_PLAY_UL (uplink substitution) bug fixed
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 01 Jun 2016 01:24:15 +0000 |
parents | 7b805007dcfc |
children |
rev | line source |
---|---|
275
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This module contains the main() function for fc-fsio. |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <stdio.h> |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdlib.h> |
276
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
7 #include <unistd.h> |
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
8 #include "exitcodes.h" |
275
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 |
915
7b805007dcfc
etmsync: slight "main" refactoring in preparation for multiple programs
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
296
diff
changeset
|
10 extern char *socket_pathname; |
275
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 main(argc, argv) |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 char **argv; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 { |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 extern int optind; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 extern char *optarg; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 int c, sopt = 0; |
276
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
19 char command[512]; |
275
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 while ((c = getopt(argc, argv, "B:l:p:s:w:")) != EOF) |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 switch (c) { |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 case 'B': |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 rvinterf_Bopt = optarg; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 continue; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 case 'l': |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 rvinterf_lopt = optarg; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 continue; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 case 'p': |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 rvinterf_ttyport = optarg; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 continue; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 case 's': |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 socket_pathname = optarg; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 sopt++; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 continue; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 case 'w': |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 rvinterf_wopt = optarg; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 continue; |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 case '?': |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 default: |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 usage: fprintf(stderr, |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 "usage: %s [options] [command]\n", argv[0]); |
276
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
43 exit(ERROR_USAGE); |
275
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 } |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 if (rvinterf_ttyport) { |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 if (sopt) { |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 fprintf(stderr, |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 "%s error: -p and -s options are mutually exclusive\n", |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 argv[0]); |
276
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
50 exit(ERROR_USAGE); |
275
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 } |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 launch_rvinterf(); |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } else { |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) { |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 fprintf(stderr, |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n", |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 argv[0]); |
276
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
58 exit(ERROR_USAGE); |
275
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 } |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 connect_local_socket(); |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 } |
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 |
296
792f164b63a6
fc-fsio: cpout now works the way it should
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
280
diff
changeset
|
63 setlinebuf(stdout); |
280
f304f9bcde3b
fc-fsio: single command invokation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
277
diff
changeset
|
64 if (argv[optind]) |
f304f9bcde3b
fc-fsio: single command invokation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
277
diff
changeset
|
65 return dispatch_ready_argv(argc - optind, argv + optind); |
276
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
66 for (;;) { |
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
67 if (isatty(0)) { |
277
e23fc1228efd
fc-fsio: low-level rvinterf link implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
276
diff
changeset
|
68 rx_control(0); |
276
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
69 fputs("fsio> ", stdout); |
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
70 fflush(stdout); |
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
71 } |
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
72 if (!fgets(command, sizeof command, stdin)) |
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
73 exit(0); |
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
74 parse_and_dispatch_cmd(command, 0); |
909f00c15f27
more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
275
diff
changeset
|
75 } |
275
cedf09b6b5ac
started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 } |