FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etmsync/simplemain.c @ 916:8e1c55cf7989
fc-getpirimei implemented, compiles
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Tue, 08 Sep 2015 18:59:29 +0000 |
parents | |
children |
rev | line source |
---|---|
916
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This module contains the main() function for simple etmsync programs |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * that execute a single operation without a command dispatcher. |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <unistd.h> |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include "exitcodes.h" |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 extern char *socket_pathname; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 main(argc, argv) |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 char **argv; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 { |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 extern int optind; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 extern char *optarg; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 int c, sopt = 0; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 while ((c = getopt(argc, argv, "B:l:p:s:w:")) != EOF) |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 switch (c) { |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 case 'B': |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 rvinterf_Bopt = optarg; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 continue; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 case 'l': |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 rvinterf_lopt = optarg; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 continue; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 case 'p': |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 rvinterf_ttyport = optarg; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 continue; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 case 's': |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 socket_pathname = optarg; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 sopt++; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 continue; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 case 'w': |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 rvinterf_wopt = optarg; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 continue; |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 case '?': |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 default: |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 /* error msg already printed */ |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 exit(ERROR_USAGE); |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 } |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 if (rvinterf_ttyport) { |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 if (sopt) { |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 fprintf(stderr, |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 "%s error: -p and -s options are mutually exclusive\n", |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 argv[0]); |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 exit(ERROR_USAGE); |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 } |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 launch_rvinterf(); |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 } else { |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) { |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 fprintf(stderr, |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n", |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 argv[0]); |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 exit(ERROR_USAGE); |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 } |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 connect_local_socket(); |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 } |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 return single_op_main(argc - optind, argv + optind); |
8e1c55cf7989
fc-getpirimei implemented, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 } |