ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rholo.c
(Generate patch)

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.73 by greg, Thu Dec 4 23:34:00 2008 UTC vs.
Revision 3.86 by greg, Thu Jun 5 19:10:31 2025 UTC

# Line 36 | Line 36 | int    NVARS = NRHVARS;                /* total number of variables */
36  
37   VARIABLE        vv[] = RHVINIT;         /* variable-value pairs */
38  
39 char    *progname;              /* our program name */
39   char    *hdkfile;               /* holodeck file name */
40   char    froot[256];             /* root file name */
41  
# Line 55 | Line 54 | time_t reporttime;             /* time for next report */
54   off_t   maxdisk;                /* maximum file space (bytes) */
55  
56   int     rtargc = 1;             /* rtrace command */
57 < char    *rtargv[128] = {"rtrace", NULL};
57 > char    *rtargv[MAXRTARGC] = {"rtrace", NULL};
58  
59   int     orig_mode = -1;         /* original file mode (-1 if unchanged) */
60  
# Line 90 | Line 89 | main(
89   {
90          int     i;
91  
92 <        progname = argv[0];                     /* get arguments */
92 >        fixargv0(argv[0]);                      /* get arguments */
93          for (i = 1; i < argc && argv[i][0] == '-'; i++)
94                  switch (argv[i][1]) {
95                  case 'w':                       /* turn off warnings */
# Line 164 | Line 163 | main(
163          quit(0);
164   userr:
165          fprintf(stderr,
166 < "Usage: %s [-n nprocs][-o disp][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n",
166 > "Usage: %s [-n nprocs][-o disp][-i][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n",
167                          progname);
168          quit(1);
169          return 1; /* pro forma return */
# Line 184 | Line 183 | onsig(                         /* fatal signal */
183                  hdsync(NULL, 0);        /* don't leave w/o saying goodbye */
184                  _exit(signo);
185          }
186 <        alarm(300);                     /* allow 5 minutes to clean up */
186 >        alarm(300);                     /* allow 10 minutes to clean up */
187          eputs("signal - ");
188          eputs(sigerr[signo]);
189          eputs("\n");
# Line 229 | Line 228 | resfmode(              /* restrict open file access mode */
228   static void
229   initrholo(void)                 /* get our holodeck running */
230   {
231 <        extern int      global_packet();
233 <        register int    i;
231 >        int     i;
232                                                  /* close holodeck on exec() */
233          fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC);
234  
# Line 250 | Line 248 | initrholo(void)                        /* get our holodeck running */
248                  hdcachesize = 1024.*1024.*vflt(CACHE);
249                                                  /* open report file */
250          if (vdef(REPORT)) {
251 <                register char   *s = sskip2(vval(REPORT), 1);
251 >                char    *s = sskip2(vval(REPORT), 1);
252                  if (*s && freopen(s, "a", stderr) == NULL)
253                          quit(2);
254          }
# Line 324 | Line 322 | rholo(void)                            /* holodeck main loop */
322          PACKET  *pl = NULL, *plend;
323          off_t   fsiz;
324          int     pksiz;
325 <        register PACKET *p;
325 >        PACKET  *p;
326          time_t  t;
327                                          /* check display */
328          if (nprocs <= 0)
# Line 391 | Line 389 | rholo(void)                            /* holodeck main loop */
389  
390   static void
391   setdefaults(                    /* set default values */
392 <        register HDGRID *gp
392 >        HDGRID  *gp
393   )
394   {
395 <        extern char     *atos();
398 <        register int    i;
395 >        int     i;
396          int     n;
397          double  len[3], d;
398  
# Line 415 | Line 412 | setdefaults(                   /* set default values */
412          }
413                                  /* append rendering options */
414          if (vdef(RENDER))
415 <                rtargc += wordstring(rtargv+rtargc, vval(RENDER));
415 >                rtargc += wordstring(rtargv+rtargc, MAXRTARGC-rtargc, vval(RENDER));
416          
417          if (gp == NULL)         /* already initialized? */
418                  return;
# Line 453 | Line 450 | creatholo(                     /* create a holodeck output file */
450   )
451   {
452          extern char     VersionID[];
453 <        int32   lastloc, nextloc;
453 >        off_t   lastloc, nextloc;
454          int     n;
455          int     fd;
456          FILE    *fp;
457                                          /* open & truncate file */
458 <        if ((fp = fopen(hdkfile, "w+")) == NULL) {
458 >        if ((fp = fopen(hdkfile, "wb+")) == NULL) {
459                  sprintf(errmsg, "cannot open \"%s\" for writing", hdkfile);
460                  error(SYSTEM, errmsg);
461          }
462                                          /* write information header */
463          newheader("RADIANCE", fp);
464          fprintf(fp, "SOFTWARE= %s\n", VersionID);
465 +        fputnow(fp);
466          printvars(fp);
467 +        fputendian(fp);
468          fputformat(HOLOFMT, fp);
469          fputc('\n', fp);
470          putw(HOLOMAGIC, fp);            /* put magic number */
# Line 479 | Line 478 | creatholo(                     /* create a holodeck output file */
478                  if (!n)
479                          break;
480                  nextloc = hdfilen(fd);          /* write section pointer */
481 <                if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0)
481 >                if (lseek(fd, lastloc, SEEK_SET) < 0)
482                          error(SYSTEM,
483                                  "cannot seek on holodeck file in creatholo");
484                  write(fd, (char *)&nextloc, sizeof(nextloc));
485 <                lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET);
485 >                lseek(fd, (lastloc=nextloc), SEEK_SET);
486          }
487   }
488  
# Line 495 | Line 494 | headline(                      /* process information header line */
494   )
495   {
496          extern char     FMTSTR[];
497 <        register char   *cp;
498 <        char    fmt[32];
497 >        char    *cp;
498 >        char    fmt[MAXFMTLEN];
499  
500          if (formatval(fmt, s)) {
501                  if (strcmp(fmt, HOLOFMT)) {
# Line 522 | Line 521 | loadholo(void)                 /* start loading a holodeck from fnam
521          FILE    *fp;
522          int     fd;
523          int     n;
524 <        int32   nextloc;
524 >        off_t   nextloc;
525          
526          if ((ncprocs > 0) & (force >= 0))
527 <                fp = fopen(hdkfile, "r+");
527 >                fp = fopen(hdkfile, "rb+");
528          else
529                  fp = NULL;
530          if (fp == NULL) {
531 <                if ((fp = fopen(hdkfile, "r")) == NULL) {
531 >                if ((fp = fopen(hdkfile, "rb")) == NULL) {
532                          sprintf(errmsg, "cannot open \"%s\"", hdkfile);
533                          error(SYSTEM, errmsg);
534                  }
# Line 554 | Line 553 | loadholo(void)                 /* start loading a holodeck from fnam
553          fd = dup(fileno(fp));
554          fclose(fp);                             /* done with stdio */
555          for (n = 0; nextloc > 0L; n++) {        /* initialize each section */
556 <                lseek(fd, (off_t)nextloc, SEEK_SET);
556 >                lseek(fd, nextloc, SEEK_SET);
557                  read(fd, (char *)&nextloc, sizeof(nextloc));
558                  hdinit(fd, NULL);
559          }
# Line 566 | Line 565 | loadholo(void)                 /* start loading a holodeck from fnam
565   }
566  
567  
568 < extern void
568 > void
569   done_packets(           /* handle finished packets */
570          PACKET  *pl
571   )
572   {
573          static int      n2flush = 0;
574 <        register PACKET *p;
574 >        PACKET  *p;
575  
576          while (pl != NULL) {
577                  p = pl; pl = p->next; p->next = NULL;
# Line 603 | Line 602 | done_packets(          /* handle finished packets */
602  
603   static void
604   rootname(               /* remove tail from end of fn */
605 <        register char   *rn,
606 <        register char   *fn
605 >        char    *rn,
606 >        char    *fn
607   )
608   {
609          char    *tp, *dp;
# Line 631 | Line 630 | badvalue(                      /* report bad variable value and exit */
630  
631  
632   void
633 < eputs(s)                        /* put error message to stderr */
635 < register char  *s;
633 > eputs(const char *s)            /* put error message to stderr */
634   {
635          static int  midline = 0;
636  
# Line 651 | Line 649 | register char  *s;
649  
650  
651   void
652 < quit(ec)                        /* exit program gracefully */
655 < int     ec;
652 > quit(int ec)                    /* exit program gracefully */
653   {
654          int     status = 0;
655  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines