annotate pircharge/main.c @ 338:b730c7844233

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