1 |
– |
/* Copyright (c) 1999 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Holodeck display process communication |
6 |
|
*/ |
7 |
|
|
8 |
|
#include "rholo.h" |
9 |
|
#include "rhdisp.h" |
10 |
+ |
#include "rtprocess.h" |
11 |
|
#include <sys/uio.h> |
12 |
+ |
#include <string.h> |
13 |
|
|
14 |
|
#ifndef HDSUF |
15 |
|
#define HDSUF ".hdi" |
23 |
|
#endif |
24 |
|
|
25 |
|
static int inp_flags; |
26 |
< |
static int dpd[3]; |
26 |
> |
static SUBPROC dpd; |
27 |
|
static FILE *dpout; |
28 |
|
|
29 |
|
|
34 |
|
int i, n, len; |
35 |
|
|
36 |
|
if (!strcmp(dname, SLAVENAME)) { |
37 |
< |
dpd[0] = 0; /* read from stdin */ |
37 |
> |
dpd.r = 0; /* read from stdin */ |
38 |
|
dpout = stdout; /* write to stdout */ |
39 |
< |
dpd[2] = -1; /* we're the slave process */ |
39 |
> |
dpd.running = 0; /* we're the slave procees */ |
40 |
|
} else { |
41 |
|
/* get full display program name */ |
42 |
|
#ifdef DEVPATH |
54 |
|
cmd[0] = buf; |
55 |
|
cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; |
56 |
|
cmd[4] = NULL; |
57 |
< |
i = open_process(dpd, cmd); |
57 |
> |
i = open_process(&dpd, cmd); |
58 |
|
if (i <= 0) |
59 |
|
error(USER, "cannot start display process"); |
60 |
< |
if ((dpout = fdopen(dpd[1], "w")) == NULL) |
60 |
> |
if ((dpout = fdopen(dpd.w, "w")) == NULL) |
61 |
|
error(SYSTEM, "problem opening display pipe"); |
62 |
|
/* close dup'ed stdin and stdout */ |
63 |
|
if (readinp) |
64 |
|
close(atoi(fd0)); |
65 |
|
close(atoi(fd1)); |
66 |
|
} |
67 |
< |
dpd[1] = -1; /* causes ignored error in close_process() */ |
67 |
> |
dpd.w = -1; /* causes ignored error in close_process() */ |
68 |
|
inp_flags = 0; |
69 |
|
/* check if outside */ |
70 |
|
if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS)) |
76 |
|
} |
77 |
|
/* write out hologram grids & octrees */ |
78 |
|
for (i = 0; hdlist[i] != NULL; i++) { |
79 |
< |
bcopy((char *)hdlist[i], buf, sizeof(HDGRID)); |
79 |
> |
memcpy(buf, (void *)hdlist[i], sizeof(HDGRID)); |
80 |
|
len = sizeof(HDGRID); |
81 |
|
n = vdef(GEOMETRY); |
82 |
|
sfn = i<n ? nvalue(GEOMETRY,i) : |
114 |
|
/* check read blocking */ |
115 |
|
if (block != (inp_flags == 0)) { |
116 |
|
inp_flags = block ? 0 : FNONBLK; |
117 |
< |
if (fcntl(dpd[0], F_SETFL, inp_flags) < 0) |
117 |
> |
if (fcntl(dpd.r, F_SETFL, inp_flags) < 0) |
118 |
|
goto fcntlerr; |
119 |
|
} |
120 |
|
/* read message header */ |
121 |
< |
n = read(dpd[0], (char *)&msg, sizeof(MSGHEAD)); |
121 |
> |
n = read(dpd.r, (char *)&msg, sizeof(MSGHEAD)); |
122 |
|
if (n != sizeof(MSGHEAD)) { |
123 |
|
if (n >= 0) { |
124 |
|
dpout = NULL; |
134 |
|
buf = (char *)malloc(msg.nbytes); |
135 |
|
if (buf == NULL) |
136 |
|
error(SYSTEM, "out of memory in disp_check"); |
137 |
< |
if (inp_flags != 0 && fcntl(dpd[0], F_SETFL, inp_flags=0) < 0) |
137 |
> |
if (inp_flags != 0 && fcntl(dpd.r, F_SETFL, inp_flags=0) < 0) |
138 |
|
goto fcntlerr; |
139 |
< |
if (readbuf(dpd[0], buf, msg.nbytes) != msg.nbytes) |
139 |
> |
if (readbuf(dpd.r, buf, msg.nbytes) != msg.nbytes) |
140 |
|
goto readerr; |
141 |
|
} |
142 |
|
switch (msg.type) { /* take appropriate action */ |
252 |
|
disp_result(DS_SHUTDOWN, 0, NULL); |
253 |
|
fclose(dpout); |
254 |
|
dpout = NULL; |
255 |
< |
return(dpd[2]<0 ? 0 : close_process(dpd)); |
255 |
> |
return(dpd.running ? close_process(&dpd) : 0); |
256 |
> |
|
257 |
|
} |
258 |
|
|
259 |
|
|