--- ray/src/hd/rholo.c 2004/01/01 11:21:55 3.64 +++ ray/src/hd/rholo.c 2008/12/05 00:22:33 3.74 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rholo.c,v 3.64 2004/01/01 11:21:55 schorsch Exp $"; +static const char RCSid[] = "$Id: rholo.c,v 3.74 2008/12/05 00:22:33 greg Exp $"; #endif /* * Radiance holodeck generation controller @@ -21,7 +21,7 @@ static const char RCSid[] = "$Id: rholo.c,v 3.64 2004/ #define FRAGWARN 20 /* fragmentation for warning (%) */ #endif #ifndef MAXQTIME -#define MAXQTIME 5 /* target maximum seconds in queue */ +#define MAXQTIME 3 /* target maximum seconds in queue */ #endif /* manual cache flushing frequency */ #ifndef RTFLUSH @@ -76,7 +76,7 @@ static void initrholo(void); static int rholo(void); static void setdefaults(HDGRID *gp); static void creatholo(HDGRID *gp); -static int headline(char *s); +static gethfunc headline; static void loadholo(void); static void rootname(char *rn, char *fn); static void badvalue(int vc); @@ -90,7 +90,6 @@ main( { int i; - initurand(16384); /* initialize urand */ progname = argv[0]; /* get arguments */ for (i = 1; i < argc && argv[i][0] == '-'; i++) switch (argv[i][1]) { @@ -165,7 +164,7 @@ main( quit(0); userr: fprintf(stderr, -"Usage: %s [-n nprocs][-o disp][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n", +"Usage: %s [-n nprocs][-o disp][-i][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n", progname); quit(1); return 1; /* pro forma return */ @@ -320,7 +319,7 @@ memerr: static int rholo(void) /* holodeck main loop */ { - static long nextfragwarn = 100*(1L<<20); + static off_t nextfragwarn = 100L<<20; static int idle = 0; PACKET *pl = NULL, *plend; off_t fsiz; @@ -339,22 +338,25 @@ rholo(void) /* holodeck main loop */ return(0); /* all done */ fsiz = hdfilen(hdlist[0]->fd); /* check file size */ if (maxdisk > 0 && fsiz >= maxdisk) { - error(WARNING, "file limit exceeded"); + error(USER, "file limit exceeded"); done_rtrace(); return(1); /* comes back */ } #if FRAGWARN - if (fsiz >= nextfragwarn && - (fsiz-hdfiluse(hdlist[0]->fd,0))/(fsiz/100) > FRAGWARN) { - sprintf(errmsg, "holodeck file fragmentation is %.0f%%", - 100.*(fsiz-hdfiluse(hdlist[0]->fd,1))/fsiz); - error(WARNING, errmsg); - nextfragwarn = fsiz + (fsiz>>2); /* decent interval */ + if (fsiz >= nextfragwarn) { + double pctfrag = 100.*(fsiz-hdfiluse(hdlist[0]->fd))/fsiz; + if (pctfrag >= (double)FRAGWARN) { + sprintf(errmsg, "holodeck file fragmentation is %.0f%%", + pctfrag); + error(WARNING, errmsg); + nextfragwarn = fsiz + (fsiz>>2); + } else + nextfragwarn = fsiz + (10L<<20); } #endif t = time(NULL); /* check time */ if (endtime > 0 && t >= endtime) { - error(WARNING, "time limit exceeded"); + error(USER, "time limit exceeded"); done_rtrace(); return(1); /* comes back */ } @@ -488,7 +490,8 @@ creatholo( /* create a holodeck output file */ static int headline( /* process information header line */ - char *s + char *s, + void *p ) { extern char FMTSTR[]; @@ -531,9 +534,10 @@ loadholo(void) /* start loading a holodeck from fnam error(SYSTEM, errmsg); } if (ncprocs > 0) { - sprintf(errmsg, - "\"%s\" opened read-only; new rays will be discarded", - hdkfile); + sprintf(errmsg, "\"%s\" is read-only", hdkfile); + if (outdev == NULL) + error(USER, errmsg); + strcat(errmsg, "; new rays will be discarded"); error(WARNING, errmsg); force = -1; } @@ -658,7 +662,7 @@ int ec; if ((ncprocs > 0) & (force >= 0) && vdef(REPORT)) { off_t fsiz, fuse; fsiz = hdfilen(hdlist[0]->fd); - fuse = hdfiluse(hdlist[0]->fd, 1); + fuse = hdfiluse(hdlist[0]->fd); fprintf(stderr, "%s: %.1f Mbyte holodeck file, %.1f%% fragmentation\n", hdkfile, fsiz/(1024.*1024.),