comparison rvinterf/etmsync/fsiomain.c @ 276:909f00c15f27

more fc-fsio foundation
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 23 Feb 2014 21:31:30 +0000
parents cedf09b6b5ac
children e23fc1228efd
comparison
equal deleted inserted replaced
275:cedf09b6b5ac 276:909f00c15f27
2 * This module contains the main() function for fc-fsio. 2 * This module contains the main() function for fc-fsio.
3 */ 3 */
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <unistd.h>
8 #include "exitcodes.h"
7 9
8 char *socket_pathname = "/tmp/rvinterf_socket"; 10 char *socket_pathname = "/tmp/rvinterf_socket";
9 int sock; 11 int sock;
10 12
11 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; 13 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
14 char **argv; 16 char **argv;
15 { 17 {
16 extern int optind; 18 extern int optind;
17 extern char *optarg; 19 extern char *optarg;
18 int c, sopt = 0; 20 int c, sopt = 0;
21 char command[512];
19 22
20 while ((c = getopt(argc, argv, "B:l:p:s:w:")) != EOF) 23 while ((c = getopt(argc, argv, "B:l:p:s:w:")) != EOF)
21 switch (c) { 24 switch (c) {
22 case 'B': 25 case 'B':
23 rvinterf_Bopt = optarg; 26 rvinterf_Bopt = optarg;
37 continue; 40 continue;
38 case '?': 41 case '?':
39 default: 42 default:
40 usage: fprintf(stderr, 43 usage: fprintf(stderr,
41 "usage: %s [options] [command]\n", argv[0]); 44 "usage: %s [options] [command]\n", argv[0]);
42 exit(1); 45 exit(ERROR_USAGE);
43 } 46 }
44 if (rvinterf_ttyport) { 47 if (rvinterf_ttyport) {
45 if (sopt) { 48 if (sopt) {
46 fprintf(stderr, 49 fprintf(stderr,
47 "%s error: -p and -s options are mutually exclusive\n", 50 "%s error: -p and -s options are mutually exclusive\n",
48 argv[0]); 51 argv[0]);
49 exit(1); 52 exit(ERROR_USAGE);
50 } 53 }
51 launch_rvinterf(); 54 launch_rvinterf();
52 } else { 55 } else {
53 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) { 56 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
54 fprintf(stderr, 57 fprintf(stderr,
55 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n", 58 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
56 argv[0]); 59 argv[0]);
57 exit(1); 60 exit(ERROR_USAGE);
58 } 61 }
59 connect_local_socket(); 62 connect_local_socket();
60 } 63 }
61 64
62 65 for (;;) {
66 if (isatty(0)) {
67 fputs("fsio> ", stdout);
68 fflush(stdout);
69 }
70 if (!fgets(command, sizeof command, stdin))
71 exit(0);
72 parse_and_dispatch_cmd(command, 0);
73 }
63 } 74 }