FreeCalypso > hg > freecalypso-tools
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/l1filter/main.c Tue Nov 09 23:14:22 2021 +0000 @@ -0,0 +1,87 @@ +/* + * This module contains the main() function for l1trace-filter. + */ + +#include <sys/types.h> +#include <sys/errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include "exitcodes.h" + +extern char *socket_pathname; +extern char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; +extern int sock; + +char **filter_list; + +main(argc, argv) + char **argv; +{ + extern int optind; + extern char *optarg; + int c, sopt = 0; + fd_set fds; + + while ((c = getopt(argc, argv, "B:l:p:s:w:")) != EOF) + switch (c) { + case 'B': + rvinterf_Bopt = optarg; + continue; + case 'l': + rvinterf_lopt = optarg; + continue; + case 'p': + rvinterf_ttyport = optarg; + continue; + case 's': + socket_pathname = optarg; + sopt++; + continue; + case 'w': + rvinterf_wopt = optarg; + continue; + case '?': + default: + /* error msg already printed */ + exit(ERROR_USAGE); + } + if (!argv[optind]) { + fprintf(stderr, "error: no filter keywords specified\n"); + exit(ERROR_USAGE); + } + if (rvinterf_ttyport) { + if (sopt) { + fprintf(stderr, + "%s error: -p and -s options are mutually exclusive\n", + argv[0]); + exit(ERROR_USAGE); + } + launch_rvinterf(0); + } else { + if (rvinterf_Bopt || rvinterf_lopt || rvinterf_wopt) { + fprintf(stderr, +"%s error: -B, -l and -w options are meaningful only when launching rvinterf\n", + argv[0]); + exit(ERROR_USAGE); + } + connect_local_socket(); + } + + filter_list = argv + optind; + init(); + for (;;) { + FD_ZERO(&fds); + FD_SET(sock, &fds); + c = select(sock+1, &fds, 0, 0, 0); + if (c < 0) { + if (errno == EINTR) + continue; + perror("select"); + exit(ERROR_UNIX); + } + if (FD_ISSET(sock, &fds)) + handle_rvinterf_input(); + fflush(stdout); + } +}