comparison rvinterf/l1filter/main.c @ 855:ea458ee48691

rvinterf/l1filter: new program written, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 09 Nov 2021 23:14:22 +0000
parents rvinterf/asyncshell/main.c@e40bb5a6c6b9
children
comparison
equal deleted inserted replaced
854:74331b35b1da 855:ea458ee48691
1 /*
2 * This module contains the main() function for l1trace-filter.
3 */
4
5 #include <sys/types.h>
6 #include <sys/errno.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include "exitcodes.h"
11
12 extern char *socket_pathname;
13 extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
14 extern int sock;
15
16 char **filter_list;
17
18 main(argc, argv)
19 char **argv;
20 {
21 extern int optind;
22 extern char *optarg;
23 int c, sopt = 0;
24 fd_set fds;
25
26 while ((c = getopt(argc, argv, "B:l:p:s:w:")) != EOF)
27 switch (c) {
28 case 'B':
29 rvinterf_Bopt = optarg;
30 continue;
31 case 'l':
32 rvinterf_lopt = optarg;
33 continue;
34 case 'p':
35 rvinterf_ttyport = optarg;
36 continue;
37 case 's':
38 socket_pathname = optarg;
39 sopt++;
40 continue;
41 case 'w':
42 rvinterf_wopt = optarg;
43 continue;
44 case '?':
45 default:
46 /* error msg already printed */
47 exit(ERROR_USAGE);
48 }
49 if (!argv[optind]) {
50 fprintf(stderr, "error: no filter keywords specified\n");
51 exit(ERROR_USAGE);
52 }
53 if (rvinterf_ttyport) {
54 if (sopt) {
55 fprintf(stderr,
56 "%s error: -p and -s options are mutually exclusive\n",
57 argv[0]);
58 exit(ERROR_USAGE);
59 }
60 launch_rvinterf(0);
61 } else {
62 if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) {
63 fprintf(stderr,
64 "%s error: -B, -l and -w options are meaningful only when launching rvinterf\n",
65 argv[0]);
66 exit(ERROR_USAGE);
67 }
68 connect_local_socket();
69 }
70
71 filter_list = argv + optind;
72 init();
73 for (;;) {
74 FD_ZERO(&fds);
75 FD_SET(sock, &fds);
76 c = select(sock+1, &fds, 0, 0, 0);
77 if (c < 0) {
78 if (errno == EINTR)
79 continue;
80 perror("select");
81 exit(ERROR_UNIX);
82 }
83 if (FD_ISSET(sock, &fds))
84 handle_rvinterf_input();
85 fflush(stdout);
86 }
87 }