--- ray/src/hd/rholo.c 1997/10/31 10:23:29 3.1 +++ ray/src/hd/rholo.c 1997/10/31 15:49:23 3.3 @@ -51,7 +51,8 @@ char *argv[]; HDGRID hdg; int i; int force = 0; - + /* mark start time */ + starttime = time(NULL); progname = argv[0]; /* get arguments */ for (i = 1; i < argc && argv[i][0] == '-'; i++) switch (argv[i][1]) { @@ -102,8 +103,11 @@ char *argv[]; "holodeck file exists -- use -f to overwrite"); /* create holodeck */ creatholo(&hdg); - } else /* else load holodeck */ + } else { /* else load holodeck */ loadholo(); + if (vdef(RIF)) /* load RIF if any */ + getradfile(vval(RIF)); + } /* initialize */ initrholo(); /* run */ @@ -128,8 +132,7 @@ initrholo() /* get our holodeck running */ open_display(outdev); else if (ncprocs > 0) /* else use global ray feed */ init_global(); - /* record the time */ - starttime = time(NULL); + /* record end time */ if (!vdef(TIME) || vflt(TIME) <= FTINY) endtime = 0; else @@ -191,15 +194,15 @@ rholo() /* holodeck main loop */ if (ncprocs <= 0) return(1); /* check file size */ - if (l = 1024.*1024.*vflt(DISKSPACE) > 0 && + if ((l = 1024.*1024.*vflt(DISKSPACE)) > 0 && hdfiluse(hdlist[0]->fd, 0) + hdmemuse(0) >= l) return(0); /* check time */ - if (endtime > 0 || vdef(REPORT)) + if (endtime > 0 || reporttime > 0) t = time(NULL); if (endtime > 0 && t >= endtime) return(0); - if (vdef(REPORT) && t >= reporttime) + if (reporttime > 0 && t >= reporttime) report(t); /* get packets to process */ while (freepacks != NULL) { @@ -227,8 +230,11 @@ time_t t; { if (t == 0) t = time(NULL); - fprintf(stderr, "%s: %ld packets done (%ld rays) after %.2f hours\n", + fprintf(stderr, "%s: %ld packets (%ld rays) done after %.2f hours\n", progname, npacksdone, nraysdone, (t-starttime)/3600.); + fflush(stderr); + if (vdef(REPORT)) + reporttime = t + (time_t)(vflt(REPORT)*60.+.5); } @@ -260,7 +266,7 @@ register HDGRID *gp; if ((len[i] = VLEN(gp->xv[i])) > maxlen) maxlen = len[i]; if (!vdef(GRID)) { - sprintf(buf, "%.4f", maxlen/16.); + sprintf(buf, "%.4f", maxlen/8.); vval(GRID) = savqstr(buf); vdef(GRID)++; } @@ -328,7 +334,7 @@ HDGRID *gp; putw(HOLOMAGIC, fp); /* put magic number & terminus */ fwrite(&endloc, sizeof(long), 1, fp); fflush(fp); /* flush buffer */ - initholo(fileno(fp), gp); /* allocate and initialize index */ + hdinit(fileno(fp), gp); /* allocate and initialize index */ /* we're dropping fp here.... */ } @@ -340,7 +346,7 @@ char *s; register char *cp; char fmt[32]; - if (headidval(fmt, s)) { + if (formatval(fmt, s)) { if (strcmp(fmt, HOLOFMT)) { sprintf(errmsg, "%s file \"%s\" has %s%s", HOLOFMT, hdkfile, FMTSTR, fmt); @@ -378,7 +384,7 @@ loadholo() /* start loading a holodeck from fname */ if (endloc != 0) error(WARNING, "ignoring multiple sections in holodeck file"); fseek(fp, 0L, 1); /* align system file pointer */ - initholo(fileno(fp), NULL); /* allocate and load index */ + hdinit(fileno(fp), NULL); /* allocate and load index */ /* we're dropping fp here.... */ } @@ -409,10 +415,11 @@ PACKET *pl; getradfile(rfargs) /* run rad and get needed variables */ char *rfargs; { - static short mvar[] = {VIEW,OCTREE,EXPOSURE,REPORT,-1}; + static short mvar[] = {VIEW,OCTREE,EXPOSURE,-1}; static char tf1[] = TEMPLATE; char tf2[64]; char combuf[256]; + char *pippt; register int i; register char *cp; /* create rad command */ @@ -422,24 +429,33 @@ char *rfargs; "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", rfargs, tf1); cp = combuf; - while (*cp) cp++; /* match unset variables */ + while (*cp){ + if (*cp == '|') pippt = cp; + cp++; + } /* match unset variables */ for (i = 0; mvar[i] >= 0; i++) if (!vdef(mvar[i])) { *cp++ = '|'; strcpy(cp, vnam(mvar[i])); while (*cp) cp++; + pippt = NULL; } - sprintf(cp, ")[ \t]*=' > %s", tf2); + if (pippt != NULL) + strcpy(pippt, "> /dev/null"); /* nothing to match */ + else + sprintf(cp, ")[ \t]*=' > %s", tf2); if (system(combuf)) { error(SYSTEM, "cannot execute rad command"); unlink(tf2); /* clean up */ unlink(tf1); quit(1); } - loadvars(tf2); /* load variables */ + if (pippt == NULL) { + loadvars(tf2); /* load variables */ + unlink(tf2); + } rtargc += wordfile(rtargv+rtargc, tf1); /* get rtrace options */ - unlink(tf2); /* clean up */ - unlink(tf1); + unlink(tf1); /* clean up */ } @@ -509,7 +525,7 @@ int ec; fsiz = lseek(hdlist[0]->fd, 0L, 2); fuse = hdfiluse(hdlist[0]->fd, 1); fprintf(stderr, - "%s: %.1f Mbyte holodeck file, %.2f%% fragmentation\n", + "%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n", hdkfile, fsiz/(1024.*1024.), 100.*(fsiz-fuse)/fsiz); }