comparison rvinterf/tmsh/main.c @ 70:2c6dca514a20

fc-tmsh works like fc-shell and fc-fsio now, following the -p convention
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 26 Oct 2016 23:33:21 +0000
parents 21a79f465d6a
children 27c41e4b21ae
comparison
equal deleted inserted replaced
69:2159f260ed13 70:2c6dca514a20
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include "exitcodes.h" 10 #include "exitcodes.h"
11 11
12 char *socket_pathname = "/tmp/rvinterf_socket"; 12 char *socket_pathname = "/tmp/rvinterf_socket";
13 char *rvinterf_ttyport;
13 int ttyhacks, dflag; 14 int ttyhacks, dflag;
14 15
15 int sock; 16 int sock;
16 17
17 extern char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; 18 extern char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
19 main(argc, argv) 20 main(argc, argv)
20 char **argv; 21 char **argv;
21 { 22 {
22 extern int optind; 23 extern int optind;
23 extern char *optarg; 24 extern char *optarg;
24 int c; 25 int c, sopt = 0;
25 fd_set fds; 26 fd_set fds;
26 27
27 while ((c = getopt(argc, argv, "B:dl:s:w:")) != EOF) 28 while ((c = getopt(argc, argv, "B:dl:p:s:w:")) != EOF)
28 switch (c) { 29 switch (c) {
29 case 'B': 30 case 'B':
30 rvinterf_Bopt = optarg; 31 rvinterf_Bopt = optarg;
31 continue; 32 continue;
32 case 'd': 33 case 'd':
33 dflag++; 34 dflag++;
34 continue; 35 continue;
35 case 'l': 36 case 'l':
36 rvinterf_lopt = optarg; 37 rvinterf_lopt = optarg;
37 continue; 38 continue;
39 case 'p':
40 rvinterf_ttyport = optarg;
41 continue;
38 case 's': 42 case 's':
39 socket_pathname = optarg; 43 socket_pathname = optarg;
44 sopt++;
40 continue; 45 continue;
41 case 'w': 46 case 'w':
42 rvinterf_wopt = optarg; 47 rvinterf_wopt = optarg;
43 continue; 48 continue;
44 case '?': 49 case '?':
45 default: 50 default:
46 usage: fprintf(stderr, 51 usage: fprintf(stderr,
47 "usage: %s [options] [ttyport]\n", argv[0]); 52 "usage: %s [options] [command]\n", argv[0]);
48 exit(ERROR_USAGE); 53 exit(ERROR_USAGE);
49 } 54 }
50 switch (argc - optind) { 55 if (rvinterf_ttyport) {
51 case 0: 56 if (sopt) {
52 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
53 fprintf(stderr, 57 fprintf(stderr,
54 "%s: -B, -l and -w options are meaningful only when launching rvinterf\n", 58 "%s error: -p and -s options are mutually exclusive\n",
55 argv[0]); 59 argv[0]);
56 exit(ERROR_USAGE); 60 exit(ERROR_USAGE);
57 } 61 }
58 break; 62 launch_rvinterf(rvinterf_ttyport);
59 case 1: 63 } else {
60 launch_rvinterf(argv[optind]); 64 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
61 break; 65 fprintf(stderr,
62 default: 66 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
63 goto usage; 67 argv[0]);
68 exit(ERROR_USAGE);
69 }
70 connect_local_socket();
64 } 71 }
65 72
66 ttyhacks = isatty(0) && !dflag; 73 ttyhacks = isatty(0) && !dflag;
67 init(); 74 init();
68 tty_init(); 75 tty_init();