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.81 by greg, Mon Oct 21 18:19:32 2019 UTC

# Line 55 | Line 55 | time_t reporttime;             /* time for next report */
55   off_t   maxdisk;                /* maximum file space (bytes) */
56  
57   int     rtargc = 1;             /* rtrace command */
58 < char    *rtargv[128] = {"rtrace", NULL};
58 > char    *rtargv[MAXRTARGC] = {"rtrace", NULL};
59  
60   int     orig_mode = -1;         /* original file mode (-1 if unchanged) */
61  
# Line 164 | Line 164 | main(
164          quit(0);
165   userr:
166          fprintf(stderr,
167 < "Usage: %s [-n nprocs][-o disp][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n",
167 > "Usage: %s [-n nprocs][-o disp][-i][-w][-r|-f] output.hdk [control.hif|+|- [VAR=val ..]]\n",
168                          progname);
169          quit(1);
170          return 1; /* pro forma return */
# Line 184 | Line 184 | onsig(                         /* fatal signal */
184                  hdsync(NULL, 0);        /* don't leave w/o saying goodbye */
185                  _exit(signo);
186          }
187 <        alarm(300);                     /* allow 5 minutes to clean up */
187 >        alarm(300);                     /* allow 10 minutes to clean up */
188          eputs("signal - ");
189          eputs(sigerr[signo]);
190          eputs("\n");
# Line 230 | Line 230 | static void
230   initrholo(void)                 /* get our holodeck running */
231   {
232          extern int      global_packet();
233 <        register int    i;
233 >        int     i;
234                                                  /* close holodeck on exec() */
235          fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC);
236  
# Line 250 | Line 250 | initrholo(void)                        /* get our holodeck running */
250                  hdcachesize = 1024.*1024.*vflt(CACHE);
251                                                  /* open report file */
252          if (vdef(REPORT)) {
253 <                register char   *s = sskip2(vval(REPORT), 1);
253 >                char    *s = sskip2(vval(REPORT), 1);
254                  if (*s && freopen(s, "a", stderr) == NULL)
255                          quit(2);
256          }
# Line 324 | Line 324 | rholo(void)                            /* holodeck main loop */
324          PACKET  *pl = NULL, *plend;
325          off_t   fsiz;
326          int     pksiz;
327 <        register PACKET *p;
327 >        PACKET  *p;
328          time_t  t;
329                                          /* check display */
330          if (nprocs <= 0)
# Line 391 | Line 391 | rholo(void)                            /* holodeck main loop */
391  
392   static void
393   setdefaults(                    /* set default values */
394 <        register HDGRID *gp
394 >        HDGRID  *gp
395   )
396   {
397          extern char     *atos();
398 <        register int    i;
398 >        int     i;
399          int     n;
400          double  len[3], d;
401  
# Line 415 | Line 415 | setdefaults(                   /* set default values */
415          }
416                                  /* append rendering options */
417          if (vdef(RENDER))
418 <                rtargc += wordstring(rtargv+rtargc, vval(RENDER));
418 >                rtargc += wordstring(rtargv+rtargc, MAXRTARGC-rtargc, vval(RENDER));
419          
420          if (gp == NULL)         /* already initialized? */
421                  return;
# Line 453 | Line 453 | creatholo(                     /* create a holodeck output file */
453   )
454   {
455          extern char     VersionID[];
456 <        int32   lastloc, nextloc;
456 >        off_t   lastloc, nextloc;
457          int     n;
458          int     fd;
459          FILE    *fp;
460                                          /* open & truncate file */
461 <        if ((fp = fopen(hdkfile, "w+")) == NULL) {
461 >        if ((fp = fopen(hdkfile, "wb+")) == NULL) {
462                  sprintf(errmsg, "cannot open \"%s\" for writing", hdkfile);
463                  error(SYSTEM, errmsg);
464          }
# Line 479 | Line 479 | creatholo(                     /* create a holodeck output file */
479                  if (!n)
480                          break;
481                  nextloc = hdfilen(fd);          /* write section pointer */
482 <                if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0)
482 >                if (lseek(fd, lastloc, SEEK_SET) < 0)
483                          error(SYSTEM,
484                                  "cannot seek on holodeck file in creatholo");
485                  write(fd, (char *)&nextloc, sizeof(nextloc));
486 <                lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET);
486 >                lseek(fd, (lastloc=nextloc), SEEK_SET);
487          }
488   }
489  
# Line 495 | Line 495 | headline(                      /* process information header line */
495   )
496   {
497          extern char     FMTSTR[];
498 <        register char   *cp;
499 <        char    fmt[32];
498 >        char    *cp;
499 >        char    fmt[MAXFMTLEN];
500  
501          if (formatval(fmt, s)) {
502                  if (strcmp(fmt, HOLOFMT)) {
# Line 522 | Line 522 | loadholo(void)                 /* start loading a holodeck from fnam
522          FILE    *fp;
523          int     fd;
524          int     n;
525 <        int32   nextloc;
525 >        off_t   nextloc;
526          
527          if ((ncprocs > 0) & (force >= 0))
528 <                fp = fopen(hdkfile, "r+");
528 >                fp = fopen(hdkfile, "rb+");
529          else
530                  fp = NULL;
531          if (fp == NULL) {
532 <                if ((fp = fopen(hdkfile, "r")) == NULL) {
532 >                if ((fp = fopen(hdkfile, "rb")) == NULL) {
533                          sprintf(errmsg, "cannot open \"%s\"", hdkfile);
534                          error(SYSTEM, errmsg);
535                  }
# Line 554 | Line 554 | loadholo(void)                 /* start loading a holodeck from fnam
554          fd = dup(fileno(fp));
555          fclose(fp);                             /* done with stdio */
556          for (n = 0; nextloc > 0L; n++) {        /* initialize each section */
557 <                lseek(fd, (off_t)nextloc, SEEK_SET);
557 >                lseek(fd, nextloc, SEEK_SET);
558                  read(fd, (char *)&nextloc, sizeof(nextloc));
559                  hdinit(fd, NULL);
560          }
# Line 566 | Line 566 | loadholo(void)                 /* start loading a holodeck from fnam
566   }
567  
568  
569 < extern void
569 > void
570   done_packets(           /* handle finished packets */
571          PACKET  *pl
572   )
573   {
574          static int      n2flush = 0;
575 <        register PACKET *p;
575 >        PACKET  *p;
576  
577          while (pl != NULL) {
578                  p = pl; pl = p->next; p->next = NULL;
# Line 603 | Line 603 | done_packets(          /* handle finished packets */
603  
604   static void
605   rootname(               /* remove tail from end of fn */
606 <        register char   *rn,
607 <        register char   *fn
606 >        char    *rn,
607 >        char    *fn
608   )
609   {
610          char    *tp, *dp;
# Line 632 | Line 632 | badvalue(                      /* report bad variable value and exit */
632  
633   void
634   eputs(s)                        /* put error message to stderr */
635 < register char  *s;
635 > char  *s;
636   {
637          static int  midline = 0;
638  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines