--- ray/src/hd/rholo.c 2003/05/29 16:26:22 3.54 +++ ray/src/hd/rholo.c 2003/10/21 19:19:28 3.62 @@ -1,15 +1,18 @@ #ifndef lint -static const char RCSid[] = "$Id: rholo.c,v 3.54 2003/05/29 16:26:22 greg Exp $"; +static const char RCSid[] = "$Id: rholo.c,v 3.62 2003/10/21 19:19:28 schorsch Exp $"; #endif /* * Radiance holodeck generation controller */ -#include "rholo.h" -#include "random.h" #include #include +#include +#include "rholo.h" +#include "platform.h" +#include "random.h" + #ifndef FRAGWARN #define FRAGWARN 20 /* fragmentation for warning (%) */ #endif @@ -152,6 +155,7 @@ userr: } +void onsig(signo) /* fatal signal */ int signo; { @@ -214,7 +218,7 @@ initrholo() /* get our holodeck running */ init_global(); /* record disk space limit */ if (!vdef(DISKSPACE)) - maxdisk = (1L<<(sizeof(off_t)*8-2)) - 1024; + maxdisk = ((off_t)1<<(sizeof(off_t)*8-2)) - 1024; else maxdisk = 1024.*1024.*vflt(DISKSPACE); /* set up memory cache */ @@ -266,16 +270,24 @@ initrholo() /* get our holodeck running */ } /* set up signal handling */ sigdie(SIGINT, "Interrupt"); - sigdie(SIGHUP, "Hangup"); sigdie(SIGTERM, "Terminate"); +#ifdef SIGHUP + sigdie(SIGHUP, "Hangup"); +#endif +#ifdef SIGPIPE sigdie(SIGPIPE, "Broken pipe"); +#endif +#ifdef SIGALRM sigdie(SIGALRM, "Alarm clock"); +#endif #ifdef SIGXCPU sigdie(SIGXCPU, "CPU limit exceeded"); +#endif +#ifdef SIGXFSZ sigdie(SIGXFSZ, "File size exceeded"); #endif /* protect holodeck file */ - orig_mode = resfmode(hdlist[0]->fd, ncprocs>0&force>=0 ? 0 : 0444); + orig_mode = resfmode(hdlist[0]->fd, (ncprocs>0) & (force>=0) ? 0 : 0444); return; memerr: error(SYSTEM, "out of memory in initrholo"); @@ -412,7 +424,7 @@ creatholo(gp) /* create a holodeck output file */ HDGRID *gp; { extern char VersionID[]; - int4 lastloc, nextloc; + int32 lastloc, nextloc; int n; int fd; FILE *fp; @@ -430,7 +442,7 @@ HDGRID *gp; putw(HOLOMAGIC, fp); /* put magic number */ fd = dup(fileno(fp)); fclose(fp); /* flush and close stdio stream */ - lastloc = lseek(fd, (off_t)0L, 2); + lastloc = lseek(fd, (off_t)0, SEEK_END); for (n = vdef(SECTION); n--; gp++) { /* initialize each section */ nextloc = 0L; write(fd, (char *)&nextloc, sizeof(nextloc)); @@ -438,11 +450,11 @@ HDGRID *gp; if (!n) break; nextloc = hdfilen(fd); /* write section pointer */ - if (lseek(fd, (off_t)lastloc, 0) < 0) + if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0) error(SYSTEM, "cannot seek on holodeck file in creatholo"); write(fd, (char *)&nextloc, sizeof(nextloc)); - lseek(fd, (off_t)(lastloc=nextloc), 0); + lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET); } } @@ -478,9 +490,9 @@ loadholo() /* start loading a holodeck from fname */ FILE *fp; int fd; int n; - int4 nextloc; + int32 nextloc; - if (ncprocs > 0 & force >= 0) + if ((ncprocs > 0) & (force >= 0)) fp = fopen(hdkfile, "r+"); else fp = NULL; @@ -509,7 +521,7 @@ loadholo() /* start loading a holodeck from fname */ fd = dup(fileno(fp)); fclose(fp); /* done with stdio */ for (n = 0; nextloc > 0L; n++) { /* initialize each section */ - lseek(fd, (off_t)nextloc, 0); + lseek(fd, (off_t)nextloc, SEEK_SET); read(fd, (char *)&nextloc, sizeof(nextloc)); hdinit(fd, NULL); } @@ -530,8 +542,8 @@ PACKET *pl; while (pl != NULL) { p = pl; pl = p->next; p->next = NULL; if (p->nr > 0) { /* add to holodeck */ - bcopy((void *)p->ra, - (void *)hdnewrays(hdlist[p->hd],p->bi,p->nr), + memcpy( (void *)hdnewrays(hdlist[p->hd],p->bi,p->nr), + (void *)p->ra, p->nr*sizeof(RAYVAL)); if (outdev != NULL) /* display it */ disp_packet((PACKHEAD *)p); @@ -559,11 +571,12 @@ register char *rn, *fn; { char *tp, *dp; - for (tp = NULL, dp = rn; *rn = *fn++; rn++) + for (tp = NULL, dp = rn; (*rn = *fn++); rn++) { if (*rn == '/') dp = rn; else if (*rn == '.') tp = rn; + } if (tp != NULL && tp > dp) *tp = '\0'; } @@ -606,7 +619,7 @@ int ec; if (hdlist[0] != NULL) { /* close holodeck */ if (nprocs > 0) status = done_rtrace(); /* calls hdsync() */ - if (ncprocs > 0 & force >= 0 && vdef(REPORT)) { + if ((ncprocs > 0) & (force >= 0) && vdef(REPORT)) { off_t fsiz, fuse; fsiz = hdfilen(hdlist[0]->fd); fuse = hdfiluse(hdlist[0]->fd, 1);