--- ray/src/hd/rhdisp.c 1998/12/20 20:39:31 3.38 +++ ray/src/hd/rhdisp.c 2003/05/13 17:58:33 3.45 @@ -1,9 +1,6 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rhdisp.c,v 3.45 2003/05/13 17:58:33 greg Exp $"; #endif - /* * Holodeck display process. */ @@ -22,6 +19,14 @@ static char SCCSid[] = "$SunId$ SGI"; #define FSIZDEF 0.125 /* default focus frame size */ #endif +#if defined(freebsd) +#define fbufcnt(f) ((f)->_r) +#elif defined(__GNUC__) +#define fbufcnt(f) ((f)->_IO_read_end - (f)->_IO_read_ptr) +#else +#define fbufcnt(f) ((f)->_cnt) +#endif + HOLO *hdlist[HDMAX+1]; /* global holodeck list */ char *hdgfn[HDMAX]; /* holodeck section geometry list */ @@ -40,7 +45,6 @@ char *progname; /* global argv[0] */ FILE *sstdin, *sstdout; /* server's standard input and output */ #ifdef DEBUG -#include extern time_t time(); static time_t tmodesw; static time_t timm, tadd; @@ -56,7 +60,6 @@ main(argc, argv) int argc; char *argv[]; { - extern int eputs(); int rdy, inp, res = 0, pause = 0; progname = argv[0]; @@ -155,10 +158,12 @@ disp_wait() /* wait for more input */ int n; register int i; /* see if we can avoid select call */ + if (hdlist[0] == NULL) + return(RDY_SRV); /* initialize first */ flgs = 0; /* flag what's ready already */ - if (imm_mode || stdin->_cnt > 0) + if (imm_mode || fbufcnt(stdin) > 0) flgs |= RDY_SRV; - if (sstdin != NULL && sstdin->_cnt > 0) + if (sstdin != NULL && fbufcnt(sstdin) > 0) flgs |= RDY_SIN; if (odev.inpready) flgs |= RDY_DEV; @@ -211,7 +216,7 @@ char *gfn, *pfn; hdlist[hd] = (HOLO *)malloc(sizeof(HOLO)); if (hdlist[hd] == NULL) error(SYSTEM, "out of memory in add_holo"); - bcopy((char *)hdg, (char *)hdlist[hd], sizeof(HDGRID)); + bcopy((void *)hdg, (void *)hdlist[hd], sizeof(HDGRID)); hdcompgrid(hdlist[hd]); hdgfn[hd] = savestr(gfn); hdpfn[hd] = pfn && *pfn ? savestr(pfn) : (char *)NULL; @@ -269,7 +274,8 @@ register VIEW *v; static VIEW viewhist[VIEWHISTLEN]; static unsigned nhist; VIEW *dv; - int i, res[2], *slist; + int i, res[2]; + int2 *slist; char *err; /* restore previous view? */ if (v == NULL) { @@ -473,7 +479,8 @@ serv_result() /* get next server result and process if (buf == NULL) buf = (char *)malloc(bufsiz=msg.nbytes); else - buf = (char *)realloc(buf, bufsiz=msg.nbytes); + buf = (char *)realloc((void *)buf, + bufsiz=msg.nbytes); if (buf == NULL) error(SYSTEM, "out of memory in serv_result"); } @@ -502,6 +509,8 @@ serv_result() /* get next server result and process break; case DS_STARTIMM: case DS_ENDIMM: + if (!(imm_mode = msg.type==DS_STARTIMM)) + dev_flush(); #ifdef DEBUG { time_t tnow = time(NULL); @@ -510,8 +519,6 @@ serv_result() /* get next server result and process tmodesw = tnow; } #endif - if (!(imm_mode = msg.type==DS_STARTIMM)) - dev_flush(); goto noargs; case DS_ACKNOW: case DS_SHUTDOWN: @@ -560,6 +567,7 @@ char *p; } +void eputs(s) /* put error message to stderr */ register char *s; { @@ -579,6 +587,7 @@ register char *s; } +void quit(code) /* clean up and exit */ int code; {