annotate rvinterf/etmsync/launchrvif.c @ 909:16ed75e266f2

rvinterf LCD output inversion option implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 07 Sep 2015 17:25:30 +0000
parents 909f00c15f27
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
275
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module implements the optional "behind the scenes" invokation
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * of rvinterf from fc-fsio etc.
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <sys/socket.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdio.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <stdlib.h>
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <unistd.h>
276
909f00c15f27 more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 275
diff changeset
11 #include "exitcodes.h"
275
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 static char rvinterf_pathname[] = "/usr/local/bin/rvinterf";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 extern int sock;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 launch_rvinterf()
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 int sp[2], rc;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 char *rvif_argv[11], Sarg[16], **ap;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sp);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 if (rc < 0) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 perror("socketpair");
276
909f00c15f27 more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 275
diff changeset
27 exit(ERROR_UNIX);
275
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 sock = sp[0];
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 sprintf(Sarg, "-S%d", sp[1]);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 ap = rvif_argv;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 *ap++ = "rvinterf";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 *ap++ = Sarg;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 *ap++ = "-n";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 if (rvinterf_Bopt) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 *ap++ = "-B";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 *ap++ = rvinterf_Bopt;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 if (rvinterf_lopt) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 *ap++ = "-l";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 *ap++ = rvinterf_lopt;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 if (rvinterf_wopt) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 *ap++ = "-w";
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 *ap++ = rvinterf_wopt;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 *ap++ = rvinterf_ttyport;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 *ap = 0;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 rc = vfork();
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 if (rc < 0) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 perror("vfork for launching rvinterf");
276
909f00c15f27 more fc-fsio foundation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 275
diff changeset
52 exit(ERROR_UNIX);
275
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 if (!rc) {
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 /* we are in the child - do the exec */
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 close(sp[0]);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 execv(rvinterf_pathname, rvif_argv);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 perror(rvinterf_pathname);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 _exit(1);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 }
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 close(sp[1]);
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 return 0;
cedf09b6b5ac started laying the foundation for fc-fsio host utility
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 }