--- ray/src/hd/rholo4.c 1997/12/11 17:40:04 3.12 +++ ray/src/hd/rholo4.c 1998/10/06 18:09:49 3.20 @@ -1,4 +1,4 @@ -/* Copyright (c) 1997 Silicon Graphics, Inc. */ +/* Copyright (c) 1998 Silicon Graphics, Inc. */ #ifndef lint static char SCCSid[] = "$SunId$ SGI"; @@ -13,7 +13,7 @@ static char SCCSid[] = "$SunId$ SGI"; #include #ifndef HDSUF -#define HDSUF ".hdisp" +#define HDSUF ".hdi" #endif static int inp_flags; @@ -53,6 +53,15 @@ char *dname; if (readinp) close(atoi(fd0)); close(atoi(fd1)); + /* check if outside */ + if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS)) + disp_result(DS_OUTSECT, 0, NULL); + /* send eye separation if specified */ + if (vdef(EYESEP)) { + char fbuf[32]; + sprintf(fbuf, "%.9e", vflt(EYESEP)); + disp_result(DS_EYESEP, strlen(fbuf)+1, fbuf); + } /* write out hologram grids */ for (i = 0; hdlist[i] != NULL; i++) disp_result(DS_ADDHOLO, sizeof(HDGRID), (char *)hdlist[i]); @@ -96,10 +105,12 @@ int block; return(2); /* acceptable failure */ } if (msg.nbytes) { /* get the message body */ + if (msg.nbytes < 0) + error(INTERNAL, "anti-message from display process"); buf = (char *)malloc(msg.nbytes); if (buf == NULL) error(SYSTEM, "out of memory in disp_check"); - if (fcntl(dpd[0], F_SETFL, inp_flags=0) < 0) + if (inp_flags != 0 && fcntl(dpd[0], F_SETFL, inp_flags=0) < 0) goto fcntlerr; if (readbuf(dpd[0], buf, msg.nbytes) != msg.nbytes) goto readerr; @@ -113,20 +124,27 @@ int block; case DR_NEWSET: /* new calculation set */ if (msg.nbytes % sizeof(PACKHEAD)) error(INTERNAL, "bad DR_NEWSET from display process"); - disp_result(DS_STARTIMM, 0, NULL); + if (msg.nbytes) + disp_result(DS_STARTIMM, 0, NULL); bundle_set(BS_NEW, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); - disp_result(DS_ENDIMM, 0, NULL); - disp_flush(); + if (msg.nbytes) { + disp_result(DS_ENDIMM, 0, NULL); + disp_flush(); + } break; case DR_ADDSET: /* add to calculation set */ + if (!msg.nbytes) + break; if (msg.nbytes % sizeof(PACKHEAD)) error(INTERNAL, "bad DR_ADDSET from display process"); disp_result(DS_STARTIMM, 0, NULL); bundle_set(BS_ADD, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); disp_result(DS_ENDIMM, 0, NULL); - disp_check(0); /* hack -- delete usu. follows add */ + disp_flush(); break; case DR_ADJSET: /* adjust calculation set members */ + if (!msg.nbytes) + break; if (msg.nbytes % sizeof(PACKHEAD)) error(INTERNAL, "bad DR_ADJSET from display process"); disp_result(DS_STARTIMM, 0, NULL); @@ -135,6 +153,8 @@ int block; disp_flush(); break; case DR_DELSET: /* delete from calculation set */ + if (!msg.nbytes) + break; if (msg.nbytes % sizeof(PACKHEAD)) error(INTERNAL, "bad DR_DELSET from display process"); bundle_set(BS_DEL, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); @@ -145,6 +165,34 @@ int block; /* send acknowledgement */ disp_result(DS_ACKNOW, 0, NULL); return(disp_check(1)); /* block on following request */ + case DR_KILL: /* kill computation process(es) */ + if (msg.nbytes) + error(INTERNAL, "bad DR_KILL from display process"); + if (nprocs > 0) + done_rtrace(); + else + error(WARNING, "no rtrace process to kill"); + break; + case DR_RESTART: /* restart computation process(es) */ + if (msg.nbytes) + error(INTERNAL, "bad DR_RESTART from display process"); + if (ncprocs > nprocs) + new_rtrace(); + else if (nprocs > 0) + error(WARNING, "rtrace already runnning"); + else + error(WARNING, "holodeck not open for writing"); + break; + case DR_CLOBBER: /* clobber holodeck */ + if (msg.nbytes) + error(INTERNAL, "bad DR_CLOBBER from display process"); + if (!force || !ncprocs) + error(WARNING, "request to clobber holodeck denied"); + else { + error(WARNING, "clobbering holodeck contents"); + hdclobber(NULL); + } + break; case DR_SHUTDOWN: /* shut down program */ if (msg.nbytes) error(INTERNAL, "bad DR_SHUTDOWN from display process"); @@ -183,7 +231,11 @@ int type, nbytes; char *p; { MSGHEAD msg; - + /* consistency checks */ +#ifdef DEBUG + if (nbytes < 0 || nbytes > 0 & p == NULL) + error(CONSISTENCY, "bad buffer handed to disp_result"); +#endif if (dpout == NULL) return; msg.type = type;