1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
13 |
|
#include <sys/uio.h> |
14 |
|
|
15 |
|
#ifndef HDSUF |
16 |
< |
#define HDSUF ".hdisp" |
16 |
> |
#define HDSUF ".hdi" |
17 |
|
#endif |
18 |
|
|
19 |
+ |
#ifndef FNONBLK |
20 |
+ |
#define FNONBLK O_NONBLOCK |
21 |
+ |
#endif |
22 |
+ |
|
23 |
|
static int inp_flags; |
24 |
|
static int dpd[3]; |
25 |
|
static FILE *dpout; |
57 |
|
if (readinp) |
58 |
|
close(atoi(fd0)); |
59 |
|
close(atoi(fd1)); |
60 |
+ |
/* check if outside */ |
61 |
+ |
if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS)) |
62 |
+ |
disp_result(DS_OUTSECT, 0, NULL); |
63 |
+ |
/* send eye separation if specified */ |
64 |
+ |
if (vdef(EYESEP)) { |
65 |
+ |
char fbuf[32]; |
66 |
+ |
sprintf(fbuf, "%.9e", vflt(EYESEP)); |
67 |
+ |
disp_result(DS_EYESEP, strlen(fbuf)+1, fbuf); |
68 |
+ |
} |
69 |
|
/* write out hologram grids */ |
70 |
|
for (i = 0; hdlist[i] != NULL; i++) |
71 |
|
disp_result(DS_ADDHOLO, sizeof(HDGRID), (char *)hdlist[i]); |
109 |
|
return(2); /* acceptable failure */ |
110 |
|
} |
111 |
|
if (msg.nbytes) { /* get the message body */ |
112 |
+ |
if (msg.nbytes < 0) |
113 |
+ |
error(INTERNAL, "anti-message from display process"); |
114 |
|
buf = (char *)malloc(msg.nbytes); |
115 |
|
if (buf == NULL) |
116 |
|
error(SYSTEM, "out of memory in disp_check"); |
117 |
< |
if (fcntl(dpd[0], F_SETFL, inp_flags=0) < 0) |
117 |
> |
if (inp_flags != 0 && fcntl(dpd[0], F_SETFL, inp_flags=0) < 0) |
118 |
|
goto fcntlerr; |
119 |
|
if (readbuf(dpd[0], buf, msg.nbytes) != msg.nbytes) |
120 |
|
goto readerr; |
128 |
|
case DR_NEWSET: /* new calculation set */ |
129 |
|
if (msg.nbytes % sizeof(PACKHEAD)) |
130 |
|
error(INTERNAL, "bad DR_NEWSET from display process"); |
131 |
< |
disp_result(DS_STARTIMM, 0, NULL); |
131 |
> |
if (msg.nbytes) |
132 |
> |
disp_result(DS_STARTIMM, 0, NULL); |
133 |
|
bundle_set(BS_NEW, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); |
134 |
< |
disp_result(DS_ENDIMM, 0, NULL); |
135 |
< |
disp_flush(); |
134 |
> |
if (msg.nbytes) { |
135 |
> |
disp_result(DS_ENDIMM, 0, NULL); |
136 |
> |
disp_flush(); |
137 |
> |
} |
138 |
|
break; |
139 |
|
case DR_ADDSET: /* add to calculation set */ |
140 |
+ |
if (!msg.nbytes) |
141 |
+ |
break; |
142 |
|
if (msg.nbytes % sizeof(PACKHEAD)) |
143 |
|
error(INTERNAL, "bad DR_ADDSET from display process"); |
144 |
|
disp_result(DS_STARTIMM, 0, NULL); |
145 |
|
bundle_set(BS_ADD, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); |
146 |
|
disp_result(DS_ENDIMM, 0, NULL); |
147 |
< |
disp_check(0); /* hack -- delete usu. follows add */ |
147 |
> |
disp_flush(); |
148 |
|
break; |
149 |
|
case DR_ADJSET: /* adjust calculation set members */ |
150 |
+ |
if (!msg.nbytes) |
151 |
+ |
break; |
152 |
|
if (msg.nbytes % sizeof(PACKHEAD)) |
153 |
|
error(INTERNAL, "bad DR_ADJSET from display process"); |
154 |
|
disp_result(DS_STARTIMM, 0, NULL); |
157 |
|
disp_flush(); |
158 |
|
break; |
159 |
|
case DR_DELSET: /* delete from calculation set */ |
160 |
+ |
if (!msg.nbytes) |
161 |
+ |
break; |
162 |
|
if (msg.nbytes % sizeof(PACKHEAD)) |
163 |
|
error(INTERNAL, "bad DR_DELSET from display process"); |
164 |
|
bundle_set(BS_DEL, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); |
165 |
|
break; |
166 |
+ |
case DR_VIEWPOINT: /* set target eye position */ |
167 |
+ |
if (msg.nbytes != sizeof(VIEWPOINT)) |
168 |
+ |
error(INTERNAL, "bad DR_VIEWPOINT from display process"); |
169 |
+ |
copystruct(&myeye, (VIEWPOINT *)buf); |
170 |
+ |
break; |
171 |
|
case DR_ATTEN: /* block for priority request */ |
172 |
|
if (msg.nbytes) |
173 |
|
error(INTERNAL, "bad DR_ATTEN from display process"); |
240 |
|
char *p; |
241 |
|
{ |
242 |
|
MSGHEAD msg; |
243 |
< |
|
243 |
> |
/* consistency checks */ |
244 |
> |
#ifdef DEBUG |
245 |
> |
if (nbytes < 0 || nbytes > 0 & p == NULL) |
246 |
> |
error(CONSISTENCY, "bad buffer handed to disp_result"); |
247 |
> |
#endif |
248 |
|
if (dpout == NULL) |
249 |
|
return; |
250 |
|
msg.type = type; |