| 1 |
– |
/* Copyright (c) 1998 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. |
| 6 |
|
*/ |
| 19 |
|
#define FSIZDEF 0.125 /* default focus frame size */ |
| 20 |
|
#endif |
| 21 |
|
|
| 22 |
+ |
#if defined(freebsd) |
| 23 |
+ |
#define fbufcnt(f) ((f)->_r) |
| 24 |
+ |
#elif defined(__GNUC__) |
| 25 |
+ |
#define fbufcnt(f) ((f)->_IO_read_end - (f)->_IO_read_ptr) |
| 26 |
+ |
#else |
| 27 |
+ |
#define fbufcnt(f) ((f)->_cnt) |
| 28 |
+ |
#endif |
| 29 |
+ |
|
| 30 |
|
HOLO *hdlist[HDMAX+1]; /* global holodeck list */ |
| 31 |
|
|
| 32 |
< |
char *hdofn[HDMAX+1]; /* holodeck section octree list */ |
| 32 |
> |
char *hdgfn[HDMAX]; /* holodeck section geometry list */ |
| 33 |
> |
char *hdpfn[HDMAX]; /* section portal list */ |
| 34 |
|
|
| 35 |
|
char cmdlist[DC_NCMDS][8] = DC_INIT; |
| 36 |
|
|
| 45 |
|
FILE *sstdin, *sstdout; /* server's standard input and output */ |
| 46 |
|
|
| 47 |
|
#ifdef DEBUG |
| 42 |
– |
#include <sys/types.h> |
| 48 |
|
extern time_t time(); |
| 49 |
|
static time_t tmodesw; |
| 50 |
|
static time_t timm, tadd; |
| 60 |
|
int argc; |
| 61 |
|
char *argv[]; |
| 62 |
|
{ |
| 58 |
– |
extern int eputs(); |
| 63 |
|
int rdy, inp, res = 0, pause = 0; |
| 64 |
|
|
| 65 |
|
progname = argv[0]; |
| 158 |
|
int n; |
| 159 |
|
register int i; |
| 160 |
|
/* see if we can avoid select call */ |
| 161 |
+ |
if (hdlist[0] == NULL) |
| 162 |
+ |
return(RDY_SRV); /* initialize first */ |
| 163 |
|
flgs = 0; /* flag what's ready already */ |
| 164 |
< |
if (imm_mode || stdin->_cnt > 0) |
| 164 |
> |
if (imm_mode || fbufcnt(stdin) > 0) |
| 165 |
|
flgs |= RDY_SRV; |
| 166 |
< |
if (sstdin != NULL && sstdin->_cnt > 0) |
| 166 |
> |
if (sstdin != NULL && fbufcnt(sstdin) > 0) |
| 167 |
|
flgs |= RDY_SIN; |
| 168 |
|
if (odev.inpready) |
| 169 |
|
flgs |= RDY_DEV; |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
|
| 204 |
< |
add_holo(hdg, ofn) /* register a new holodeck section */ |
| 204 |
> |
add_holo(hdg, gfn, pfn) /* register a new holodeck section */ |
| 205 |
|
HDGRID *hdg; |
| 206 |
< |
char *ofn; |
| 206 |
> |
char *gfn, *pfn; |
| 207 |
|
{ |
| 208 |
|
VIEW nv; |
| 209 |
|
double d; |
| 218 |
|
error(SYSTEM, "out of memory in add_holo"); |
| 219 |
|
bcopy((char *)hdg, (char *)hdlist[hd], sizeof(HDGRID)); |
| 220 |
|
hdcompgrid(hdlist[hd]); |
| 221 |
< |
hdofn[hd] = savestr(ofn); |
| 221 |
> |
hdgfn[hd] = savestr(gfn); |
| 222 |
> |
hdpfn[hd] = pfn && *pfn ? savestr(pfn) : (char *)NULL; |
| 223 |
|
if (hd) |
| 224 |
|
return; |
| 225 |
|
/* set initial viewpoint */ |
| 274 |
|
static VIEW viewhist[VIEWHISTLEN]; |
| 275 |
|
static unsigned nhist; |
| 276 |
|
VIEW *dv; |
| 277 |
< |
int i, res[2], *slist; |
| 277 |
> |
int i, res[2]; |
| 278 |
> |
int2 *slist; |
| 279 |
|
char *err; |
| 280 |
|
/* restore previous view? */ |
| 281 |
|
if (v == NULL) { |
| 308 |
|
goto again; /* poss. overloading dev_section()? */ |
| 309 |
|
} |
| 310 |
|
DCHECK(*slist < 0, WARNING, "no visible sections in new_view"); |
| 311 |
< |
while (*slist >= 0) |
| 312 |
< |
dev_section(hdofn[*slist++]); |
| 311 |
> |
for ( ; *slist >= 0; slist++) |
| 312 |
> |
dev_section(hdgfn[*slist], hdpfn[*slist]); |
| 313 |
|
} |
| 314 |
< |
dev_section(NULL); /* end section list */ |
| 314 |
> |
dev_section(NULL,NULL); /* end section list */ |
| 315 |
|
dev_flush(); /* update display */ |
| 316 |
|
/* update server */ |
| 317 |
|
imm_mode = beam_sync(odev.firstuse) > 0; |
| 479 |
|
if (buf == NULL) |
| 480 |
|
buf = (char *)malloc(bufsiz=msg.nbytes); |
| 481 |
|
else |
| 482 |
< |
buf = (char *)realloc(buf, bufsiz=msg.nbytes); |
| 482 |
> |
buf = (char *)realloc((void *)buf, |
| 483 |
> |
bufsiz=msg.nbytes); |
| 484 |
|
if (buf == NULL) |
| 485 |
|
error(SYSTEM, "out of memory in serv_result"); |
| 486 |
|
} |
| 495 |
|
disp_bundle((PACKHEAD *)buf); |
| 496 |
|
break; |
| 497 |
|
case DS_ADDHOLO: |
| 498 |
< |
if (msg.nbytes <= sizeof(HDGRID)) |
| 498 |
> |
if (msg.nbytes < sizeof(HDGRID)+2) |
| 499 |
|
error(INTERNAL, "bad holodeck record from server"); |
| 500 |
< |
add_holo((HDGRID *)buf, buf+sizeof(HDGRID)); |
| 500 |
> |
add_holo((HDGRID *)buf, buf+sizeof(HDGRID), |
| 501 |
> |
buf+sizeof(HDGRID)+strlen(buf+sizeof(HDGRID))+1); |
| 502 |
|
break; |
| 503 |
|
case DS_OUTSECT: |
| 504 |
|
do_outside = 1; |
| 509 |
|
break; |
| 510 |
|
case DS_STARTIMM: |
| 511 |
|
case DS_ENDIMM: |
| 512 |
+ |
if (!(imm_mode = msg.type==DS_STARTIMM)) |
| 513 |
+ |
dev_flush(); |
| 514 |
|
#ifdef DEBUG |
| 515 |
|
{ |
| 516 |
|
time_t tnow = time(NULL); |
| 519 |
|
tmodesw = tnow; |
| 520 |
|
} |
| 521 |
|
#endif |
| 510 |
– |
if (!(imm_mode = msg.type==DS_STARTIMM)) |
| 511 |
– |
dev_flush(); |
| 522 |
|
goto noargs; |
| 523 |
|
case DS_ACKNOW: |
| 524 |
|
case DS_SHUTDOWN: |
| 567 |
|
} |
| 568 |
|
|
| 569 |
|
|
| 570 |
+ |
void |
| 571 |
|
eputs(s) /* put error message to stderr */ |
| 572 |
|
register char *s; |
| 573 |
|
{ |
| 587 |
|
} |
| 588 |
|
|
| 589 |
|
|
| 590 |
+ |
void |
| 591 |
|
quit(code) /* clean up and exit */ |
| 592 |
|
int code; |
| 593 |
|
{ |
| 594 |
+ |
if (code) |
| 595 |
+ |
exit(code); |
| 596 |
|
if (odev.v.type) |
| 597 |
|
dev_close(); |
| 598 |
< |
exit(code); |
| 598 |
> |
exit(0); |
| 599 |
|
} |