comparison rvinterf/etmsync/fsiomain.c @ 0:e7502631a0f9

initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Jun 2016 00:13:35 +0000
parents
children c6469ecfea56
comparison
equal deleted inserted replaced
-1:000000000000 0:e7502631a0f9
1 /*
2 * This module contains the main() function for fc-fsio.
3 */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include "exitcodes.h"
9
10 extern char *socket_pathname;
11 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
12
13 main(argc, argv)
14 char **argv;
15 {
16 extern int optind;
17 extern char *optarg;
18 int c, sopt = 0;
19 char command[512];
20
21 while ((c = getopt(argc, argv, "B:l:p:s:w:")) != EOF)
22 switch (c) {
23 case 'B':
24 rvinterf_Bopt = optarg;
25 continue;
26 case 'l':
27 rvinterf_lopt = optarg;
28 continue;
29 case 'p':
30 rvinterf_ttyport = optarg;
31 continue;
32 case 's':
33 socket_pathname = optarg;
34 sopt++;
35 continue;
36 case 'w':
37 rvinterf_wopt = optarg;
38 continue;
39 case '?':
40 default:
41 usage: fprintf(stderr,
42 "usage: %s [options] [command]\n", argv[0]);
43 exit(ERROR_USAGE);
44 }
45 if (rvinterf_ttyport) {
46 if (sopt) {
47 fprintf(stderr,
48 "%s error: -p and -s options are mutually exclusive\n",
49 argv[0]);
50 exit(ERROR_USAGE);
51 }
52 launch_rvinterf();
53 } else {
54 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
55 fprintf(stderr,
56 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
57 argv[0]);
58 exit(ERROR_USAGE);
59 }
60 connect_local_socket();
61 }
62
63 setlinebuf(stdout);
64 if (argv[optind])
65 return dispatch_ready_argv(argc - optind, argv + optind);
66 for (;;) {
67 if (isatty(0)) {
68 rx_control(0);
69 fputs("fsio> ", stdout);
70 fflush(stdout);
71 }
72 if (!fgets(command, sizeof command, stdin))
73 exit(0);
74 parse_and_dispatch_cmd(command, 0);
75 }
76 }