10 |
|
|
11 |
|
#include "rholo.h" |
12 |
|
#include "random.h" |
13 |
– |
#include "paths.h" |
13 |
|
#include <signal.h> |
14 |
|
#include <sys/types.h> |
15 |
|
#include <sys/stat.h> |
21 |
|
|
22 |
|
char *progname; /* our program name */ |
23 |
|
char *hdkfile; /* holodeck file name */ |
24 |
< |
char froot[MAXPATH]; /* root file name */ |
24 |
> |
char froot[256]; /* root file name */ |
25 |
|
|
26 |
|
int nowarn = 0; /* turn warnings off? */ |
27 |
|
|
106 |
|
/* check settings */ |
107 |
|
checkvalues(); |
108 |
|
/* load RIF if any */ |
109 |
< |
if (vdef(RIF)) |
111 |
< |
getradfile(vval(RIF)); |
109 |
> |
getradfile(); |
110 |
|
/* set defaults */ |
111 |
|
setdefaults(&hdg); |
112 |
|
/* holodeck exists? */ |
120 |
|
/* check settings */ |
121 |
|
checkvalues(); |
122 |
|
/* load RIF if any */ |
123 |
< |
if (vdef(RIF)) |
126 |
< |
getradfile(vval(RIF)); |
123 |
> |
getradfile(); |
124 |
|
/* set defaults */ |
125 |
|
setdefaults(NULL); |
126 |
|
} |
510 |
|
} |
511 |
|
|
512 |
|
|
516 |
– |
int |
517 |
– |
done_rtrace() /* clean up and close rtrace calculation */ |
518 |
– |
{ |
519 |
– |
int status; |
520 |
– |
/* already closed? */ |
521 |
– |
if (!nprocs) |
522 |
– |
return; |
523 |
– |
/* report activity */ |
524 |
– |
wputs("closing rtrace process...\n"); |
525 |
– |
/* flush beam queue */ |
526 |
– |
done_packets(flush_queue()); |
527 |
– |
/* close rtrace */ |
528 |
– |
if ((status = end_rtrace())) |
529 |
– |
error(WARNING, "bad exit status from rtrace"); |
530 |
– |
if (vdef(REPORT)) /* report time */ |
531 |
– |
report(0); |
532 |
– |
return(status); /* return status */ |
533 |
– |
} |
534 |
– |
|
535 |
– |
|
536 |
– |
new_rtrace() /* restart rtrace calculation */ |
537 |
– |
{ |
538 |
– |
char combuf[128]; |
539 |
– |
|
540 |
– |
if (nprocs > 0) /* already running? */ |
541 |
– |
return; |
542 |
– |
wputs("restarting rtrace process...\n"); |
543 |
– |
if (vdef(RIF)) { /* rerun rad to update octree */ |
544 |
– |
sprintf(combuf, "rad -v 0 -s -w %s", vval(RIF)); |
545 |
– |
if (system(combuf)) |
546 |
– |
error(WARNING, "error running rad"); |
547 |
– |
} |
548 |
– |
if (start_rtrace() < 1) /* start rtrace */ |
549 |
– |
error(WARNING, "cannot restart rtrace"); |
550 |
– |
else if (vdef(REPORT)) |
551 |
– |
report(0); |
552 |
– |
} |
553 |
– |
|
554 |
– |
|
555 |
– |
getradfile(rfargs) /* run rad and get needed variables */ |
556 |
– |
char *rfargs; |
557 |
– |
{ |
558 |
– |
static short mvar[] = {OCTREE,-1}; |
559 |
– |
static char tf1[] = TEMPLATE; |
560 |
– |
char tf2[64]; |
561 |
– |
char combuf[256]; |
562 |
– |
char *pippt; |
563 |
– |
register int i; |
564 |
– |
register char *cp; |
565 |
– |
/* create rad command */ |
566 |
– |
mktemp(tf1); |
567 |
– |
sprintf(tf2, "%s.rif", tf1); |
568 |
– |
sprintf(combuf, |
569 |
– |
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
570 |
– |
rfargs, tf1); |
571 |
– |
cp = combuf; |
572 |
– |
while (*cp){ |
573 |
– |
if (*cp == '|') pippt = cp; |
574 |
– |
cp++; |
575 |
– |
} /* match unset variables */ |
576 |
– |
for (i = 0; mvar[i] >= 0; i++) |
577 |
– |
if (!vdef(mvar[i])) { |
578 |
– |
*cp++ = '|'; |
579 |
– |
strcpy(cp, vnam(mvar[i])); |
580 |
– |
while (*cp) cp++; |
581 |
– |
pippt = NULL; |
582 |
– |
} |
583 |
– |
if (pippt != NULL) |
584 |
– |
strcpy(pippt, "> /dev/null"); /* nothing to match */ |
585 |
– |
else |
586 |
– |
sprintf(cp, ")[ \t]*=' > %s", tf2); |
587 |
– |
if (system(combuf)) { |
588 |
– |
unlink(tf2); /* clean up */ |
589 |
– |
unlink(tf1); |
590 |
– |
error(SYSTEM, "cannot execute rad command"); |
591 |
– |
} |
592 |
– |
if (pippt == NULL) { |
593 |
– |
loadvars(tf2); /* load variables */ |
594 |
– |
unlink(tf2); |
595 |
– |
} |
596 |
– |
rtargc += wordfile(rtargv+rtargc, tf1); /* get rtrace options */ |
597 |
– |
unlink(tf1); /* clean up */ |
598 |
– |
} |
599 |
– |
|
600 |
– |
|
513 |
|
rootname(rn, fn) /* remove tail from end of fn */ |
514 |
|
register char *rn, *fn; |
515 |
|
{ |
516 |
|
char *tp, *dp; |
517 |
|
|
518 |
|
for (tp = NULL, dp = rn; *rn = *fn++; rn++) |
519 |
< |
if (ISDIRSEP(*rn)) |
519 |
> |
if (*rn == '/') |
520 |
|
dp = rn; |
521 |
|
else if (*rn == '.') |
522 |
|
tp = rn; |