| 1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
| 1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
| 30 |
|
|
| 31 |
|
FILE *sstdin, *sstdout; /* server's standard input and output */ |
| 32 |
|
|
| 33 |
+ |
#ifdef DEBUG |
| 34 |
+ |
#include <sys/types.h> |
| 35 |
+ |
extern time_t time(); |
| 36 |
+ |
static time_t tmodesw; |
| 37 |
+ |
static time_t timm, tadd; |
| 38 |
+ |
static long nimmrays, naddrays; |
| 39 |
+ |
#endif |
| 40 |
+ |
|
| 41 |
|
#define RDY_SRV 01 |
| 42 |
|
#define RDY_DEV 02 |
| 43 |
|
#define RDY_SIN 04 |
| 63 |
|
sstdin = fdopen(inp, "r"); |
| 64 |
|
/* set command error vector */ |
| 65 |
|
erract[COMMAND].pf = eputs; |
| 66 |
+ |
#ifdef DEBUG |
| 67 |
+ |
tmodesw = time(NULL); |
| 68 |
+ |
#endif |
| 69 |
|
/* enter main loop */ |
| 70 |
|
do { |
| 71 |
|
rdy = disp_wait(); |
| 121 |
|
break; |
| 122 |
|
} |
| 123 |
|
} while (res != DS_SHUTDOWN); |
| 124 |
+ |
#ifdef DEBUG |
| 125 |
+ |
if (timm && nimmrays) |
| 126 |
+ |
fprintf(stderr, |
| 127 |
+ |
"%s: %.1f rays recalled/second (%ld rays total)\n", |
| 128 |
+ |
progname, (double)nimmrays/timm, nimmrays); |
| 129 |
+ |
if (tadd && naddrays) |
| 130 |
+ |
fprintf(stderr, |
| 131 |
+ |
"%s: %.1f rays calculated/second (%ld rays total)\n", |
| 132 |
+ |
progname, (double)naddrays/tadd, naddrays); |
| 133 |
+ |
#endif |
| 134 |
|
/* all done */ |
| 135 |
|
quit(0); |
| 136 |
|
} |
| 159 |
|
n = odev.ifd+1; |
| 160 |
|
if (sstdin != NULL) { |
| 161 |
|
FD_SET(fileno(sstdin), &readset); |
| 162 |
+ |
FD_SET(fileno(sstdin), &errset); |
| 163 |
|
if (fileno(sstdin) >= n) |
| 164 |
|
n = fileno(sstdin) + 1; |
| 165 |
|
} |
| 174 |
|
flgs |= RDY_SRV; |
| 175 |
|
if (FD_ISSET(odev.ifd, &readset) || FD_ISSET(odev.ifd, &errset)) |
| 176 |
|
flgs |= RDY_DEV; |
| 177 |
< |
if (sstdin != NULL && FD_ISSET(fileno(sstdin), &readset)) |
| 177 |
> |
if (sstdin != NULL && (FD_ISSET(fileno(sstdin), &readset) || |
| 178 |
> |
FD_ISSET(fileno(sstdin), &errset))) |
| 179 |
|
flgs |= RDY_SIN; |
| 180 |
|
return(flgs); |
| 181 |
|
} |
| 235 |
|
VSUM(wp, ro, rd, d); /* might be behind viewpoint */ |
| 236 |
|
dev_value(packra(p)[i].v, wp, rd); |
| 237 |
|
} |
| 238 |
+ |
#ifdef DEBUG |
| 239 |
+ |
if (imm_mode) nimmrays += p->nr; |
| 240 |
+ |
else naddrays += p->nr; |
| 241 |
+ |
#endif |
| 242 |
|
} |
| 243 |
|
|
| 244 |
|
|
| 283 |
|
usr_input() /* get user input and process it */ |
| 284 |
|
{ |
| 285 |
|
VIEW vparams; |
| 286 |
< |
char cmd[128]; |
| 286 |
> |
char cmd[256]; |
| 287 |
|
register char *args; |
| 288 |
|
register int i; |
| 289 |
|
|
| 290 |
< |
if (fgets(cmd, sizeof(cmd), sstdin) == NULL) |
| 291 |
< |
return(DC_QUIT); |
| 290 |
> |
if (fgets(cmd, sizeof(cmd), sstdin) == NULL) { |
| 291 |
> |
fclose(sstdin); |
| 292 |
> |
sstdin = NULL; |
| 293 |
> |
return(0); |
| 294 |
> |
} |
| 295 |
|
for (args = cmd; *args && !isspace(*args); args++) |
| 296 |
|
; |
| 297 |
|
while (isspace(*args)) |
| 328 |
|
break; |
| 329 |
|
case DC_REDRAW: /* redraw from server */ |
| 330 |
|
imm_mode = beam_sync() > 0; |
| 331 |
+ |
dev_clear(); |
| 332 |
|
break; |
| 333 |
|
case DC_KILL: /* kill rtrace process(es) */ |
| 334 |
|
serv_request(DR_KILL, 0, NULL); |
| 397 |
|
break; |
| 398 |
|
case DS_STARTIMM: |
| 399 |
|
case DS_ENDIMM: |
| 400 |
+ |
#ifdef DEBUG |
| 401 |
+ |
if (imm_mode != (msg.type==DS_STARTIMM)) { |
| 402 |
+ |
time_t tnow = time(NULL); |
| 403 |
+ |
if (imm_mode) timm += tnow - tmodesw; |
| 404 |
+ |
else tadd += tnow - tmodesw; |
| 405 |
+ |
tmodesw = tnow; |
| 406 |
+ |
} |
| 407 |
+ |
#endif |
| 408 |
|
imm_mode = msg.type==DS_STARTIMM; |
| 409 |
|
/* fall through */ |
| 410 |
|
case DS_ACKNOW: |