comparison rvinterf/etmsync/simplemain.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 e40bb5a6c6b9
comparison
equal deleted inserted replaced
-1:000000000000 0:e7502631a0f9
1 /*
2 * This module contains the main() function for simple etmsync programs
3 * that execute a single operation without a command dispatcher.
4 */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include "exitcodes.h"
10
11 extern char *socket_pathname;
12 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
13
14 main(argc, argv)
15 char **argv;
16 {
17 extern int optind;
18 extern char *optarg;
19 int c, sopt = 0;
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 /* error msg already printed */
42 exit(ERROR_USAGE);
43 }
44 if (rvinterf_ttyport) {
45 if (sopt) {
46 fprintf(stderr,
47 "%s error: -p and -s options are mutually exclusive\n",
48 argv[0]);
49 exit(ERROR_USAGE);
50 }
51 launch_rvinterf();
52 } else {
53 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
54 fprintf(stderr,
55 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
56 argv[0]);
57 exit(ERROR_USAGE);
58 }
59 connect_local_socket();
60 }
61
62 return single_op_main(argc - optind, argv + optind);
63 }