FreeCalypso > hg > freecalypso-sw
annotate rvinterf/etm/launchrvif.c @ 229:24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 25 Jan 2014 23:56:47 +0000 |
parents | 2847b6cbd915 |
children |
rev | line source |
---|---|
197
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This module implements the optional "behind the scenes" invokation |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * of rvinterf from fc-tmsh. |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/types.h> |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <sys/socket.h> |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdio.h> |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdlib.h> |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <unistd.h> |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 static char rvinterf_pathname[] = "/usr/local/bin/rvinterf"; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 extern int sock; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
200
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
197
diff
changeset
|
16 char *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; |
197
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 launch_rvinterf(ttyport) |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 char *ttyport; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 { |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 int sp[2], rc; |
200
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
197
diff
changeset
|
22 char *rvif_argv[11], Sarg[16], **ap; |
197
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sp); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 if (rc < 0) { |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 perror("socketpair"); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 exit(1); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 } |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 sock = sp[0]; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 sprintf(Sarg, "-S%d", sp[1]); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 ap = rvif_argv; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 *ap++ = "rvinterf"; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 *ap++ = Sarg; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 *ap++ = "-n"; |
200
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
197
diff
changeset
|
35 if (rvinterf_Bopt) { |
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
197
diff
changeset
|
36 *ap++ = "-B"; |
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
197
diff
changeset
|
37 *ap++ = rvinterf_Bopt; |
2847b6cbd915
fc-tmsh rvinterf invokation mode: support passing -B as well
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
197
diff
changeset
|
38 } |
197
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 if (rvinterf_lopt) { |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 *ap++ = "-l"; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 *ap++ = rvinterf_lopt; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 } |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 if (rvinterf_wopt) { |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 *ap++ = "-w"; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 *ap++ = rvinterf_wopt; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 } |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 *ap++ = ttyport; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 *ap = 0; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 rc = vfork(); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 if (rc < 0) { |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 perror("vfork for launching rvinterf"); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 exit(1); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 if (!rc) { |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 /* we are in the child - do the exec */ |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 close(sp[0]); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 execv(rvinterf_pathname, rvif_argv); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 perror(rvinterf_pathname); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 _exit(1); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 } |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 close(sp[1]); |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 return 0; |
fa7174faa9aa
fc-tmsh: option to invoke rvinterf "behind the scenes"
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 } |