annotate lcdpoll/launchrvif.c @ 9:6c35c9f2ecab

README: update for the fc-host-tools-r8 release
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 18 Mar 2018 21:30:10 +0000
parents 06e900c54ae3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the optional "behind the scenes" invokation
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * of rvinterf from fc-fsio etc.
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/socket.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <unistd.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <rvinterf/exitcodes.h>
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 static char rvinterf_pathname[] = "/opt/freecalypso/bin/rvinterf";
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern int sock;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 launch_rvinterf()
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 int sp[2], rc;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 char *rvif_argv[11], Sarg[16], **ap;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sp);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (rc < 0) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 perror("socketpair");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 exit(ERROR_UNIX);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 sock = sp[0];
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 sprintf(Sarg, "-S%d", sp[1]);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 ap = rvif_argv;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 *ap++ = "rvinterf";
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 *ap++ = Sarg;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 *ap++ = "-n";
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 if (rvinterf_Bopt) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 *ap++ = "-B";
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 *ap++ = rvinterf_Bopt;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (rvinterf_lopt) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 *ap++ = "-l";
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 *ap++ = rvinterf_lopt;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (rvinterf_wopt) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 *ap++ = "-w";
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 *ap++ = rvinterf_wopt;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *ap++ = rvinterf_ttyport;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 *ap = 0;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 rc = vfork();
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 if (rc < 0) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 perror("vfork for launching rvinterf");
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 exit(ERROR_UNIX);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 if (!rc) {
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* we are in the child - do the exec */
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 close(sp[0]);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 execv(rvinterf_pathname, rvif_argv);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 perror(rvinterf_pathname);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 _exit(1);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 close(sp[1]);
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 return 0;
06e900c54ae3 fc-lcdpoll program put together, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 }