FreeCalypso > hg > freecalypso-reveng
comparison pircharge/main.c @ 228:fec90990f613
pirchgdbg started
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 19 Dec 2017 02:58:38 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
227:bb86424f78e6 | 228:fec90990f613 |
---|---|
1 #include <sys/types.h> | |
2 #include <sys/errno.h> | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
5 #include <unistd.h> | |
6 #include <rvinterf/exitcodes.h> | |
7 | |
8 char *socket_pathname = "/tmp/rvinterf_socket"; | |
9 int sock; | |
10 | |
11 int adccal_a, adccal_b; | |
12 | |
13 main(argc, argv) | |
14 char **argv; | |
15 { | |
16 extern int optind; | |
17 extern char *optarg; | |
18 int c, sopt = 0; | |
19 fd_set fds; | |
20 | |
21 while ((c = getopt(argc, argv, "s:")) != EOF) | |
22 switch (c) { | |
23 case 's': | |
24 socket_pathname = optarg; | |
25 sopt++; | |
26 continue; | |
27 case '?': | |
28 default: | |
29 /* error msg already printed */ | |
30 exit(ERROR_USAGE); | |
31 } | |
32 if (argc != optind + 2) { | |
33 fprintf(stderr, "usage: %s adccal-a adccal-b\n", argv[0]); | |
34 exit(ERROR_USAGE); | |
35 } | |
36 adccal_a = atoi(argv[optind]); | |
37 adccal_b = atoi(argv[optind+1]); | |
38 | |
39 connect_local_socket(); | |
40 init(); | |
41 for (;;) { | |
42 FD_ZERO(&fds); | |
43 FD_SET(sock, &fds); | |
44 c = select(sock+1, &fds, 0, 0, 0); | |
45 if (c < 0) { | |
46 if (errno == EINTR) | |
47 continue; | |
48 perror("select"); | |
49 exit(ERROR_UNIX); | |
50 } | |
51 if (FD_ISSET(sock, &fds)) | |
52 handle_rvinterf_input(); | |
53 fflush(stdout); | |
54 } | |
55 } |