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.51 by gwlarson, Thu Aug 5 19:20:10 1999 UTC vs.
Revision 3.60 by schorsch, Sun Jul 27 22:12:02 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1999 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Radiance holodeck generation controller
6   */
7  
11 #include "rholo.h"
12 #include "random.h"
8   #include <signal.h>
9   #include <sys/stat.h>
10 + #include <string.h>
11  
12 + #include "rholo.h"
13 + #include "random.h"
14 +
15   #ifndef FRAGWARN
16   #define FRAGWARN        20              /* fragmentation for warning (%) */
17   #endif
# Line 48 | Line 47 | time_t starttime;              /* time we got started */
47   time_t  endtime;                /* time we should end by */
48   time_t  reporttime;             /* time for next report */
49  
50 < long    maxdisk;                /* maximum file space (bytes) */
50 > off_t   maxdisk;                /* maximum file space (bytes) */
51  
52   int     rtargc = 1;             /* rtrace command */
53   char    *rtargv[128] = {"rtrace", NULL};
# Line 155 | Line 154 | userr:
154   }
155  
156  
157 + void
158   onsig(signo)                            /* fatal signal */
159   int  signo;
160   {
# Line 217 | Line 217 | initrholo()                    /* get our holodeck running */
217                  init_global();
218                                                  /* record disk space limit */
219          if (!vdef(DISKSPACE))
220 <                maxdisk = 0;
220 >                maxdisk = ((off_t)1<<(sizeof(off_t)*8-2)) - 1024;
221          else
222                  maxdisk = 1024.*1024.*vflt(DISKSPACE);
223                                                  /* set up memory cache */
# Line 278 | Line 278 | initrholo()                    /* get our holodeck running */
278          sigdie(SIGXFSZ, "File size exceeded");
279   #endif
280                                          /* protect holodeck file */
281 <        orig_mode = resfmode(hdlist[0]->fd, ncprocs>0 ? 0 : 0444);
281 >        orig_mode = resfmode(hdlist[0]->fd, (ncprocs>0) & (force>=0) ? 0 : 0444);
282          return;
283   memerr:
284          error(SYSTEM, "out of memory in initrholo");
# Line 290 | Line 290 | rholo()                                /* holodeck main loop */
290          static long     nextfragwarn = 100*(1L<<20);
291          static int      idle = 0;
292          PACKET  *pl = NULL, *plend;
293 <        long    fsiz;
293 >        off_t   fsiz;
294          int     pksiz;
295          register PACKET *p;
296          time_t  t;
# Line 415 | Line 415 | creatholo(gp)                  /* create a holodeck output file */
415   HDGRID  *gp;
416   {
417          extern char     VersionID[];
418 <        int4    lastloc, nextloc;
418 >        int32   lastloc, nextloc;
419          int     n;
420          int     fd;
421          FILE    *fp;
# Line 433 | Line 433 | HDGRID *gp;
433          putw(HOLOMAGIC, fp);            /* put magic number */
434          fd = dup(fileno(fp));
435          fclose(fp);                     /* flush and close stdio stream */
436 <        lastloc = lseek(fd, 0L, 2);
436 >        lastloc = lseek(fd, (off_t)0, 2);
437          for (n = vdef(SECTION); n--; gp++) {    /* initialize each section */
438                  nextloc = 0L;
439                  write(fd, (char *)&nextloc, sizeof(nextloc));
# Line 441 | Line 441 | HDGRID *gp;
441                  if (!n)
442                          break;
443                  nextloc = hdfilen(fd);          /* write section pointer */
444 <                if (lseek(fd, (long)lastloc, 0) < 0)
444 >                if (lseek(fd, (off_t)lastloc, 0) < 0)
445                          error(SYSTEM,
446                                  "cannot seek on holodeck file in creatholo");
447                  write(fd, (char *)&nextloc, sizeof(nextloc));
448 <                lseek(fd, (long)(lastloc=nextloc), 0);
448 >                lseek(fd, (off_t)(lastloc=nextloc), 0);
449          }
450   }
451  
# Line 478 | Line 478 | char   *s;
478  
479   loadholo()                      /* start loading a holodeck from fname */
480   {
481        extern long     ftell();
481          FILE    *fp;
482          int     fd;
483          int     n;
484 <        int4    nextloc;
484 >        int32   nextloc;
485          
486 <        if (ncprocs > 0 & force >= 0)
486 >        if ((ncprocs > 0) & (force >= 0))
487                  fp = fopen(hdkfile, "r+");
488          else
489                  fp = NULL;
# Line 513 | Line 512 | loadholo()                     /* start loading a holodeck from fname */
512          fd = dup(fileno(fp));
513          fclose(fp);                             /* done with stdio */
514          for (n = 0; nextloc > 0L; n++) {        /* initialize each section */
515 <                lseek(fd, (long)nextloc, 0);
515 >                lseek(fd, (off_t)nextloc, 0);
516                  read(fd, (char *)&nextloc, sizeof(nextloc));
517                  hdinit(fd, NULL);
518          }
# Line 534 | Line 533 | PACKET *pl;
533          while (pl != NULL) {
534                  p = pl; pl = p->next; p->next = NULL;
535                  if (p->nr > 0) {                /* add to holodeck */
536 <                        bcopy((char *)p->ra,
537 <                                (char *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
536 >                        memcpy( (void *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
537 >                                (void *)p->ra,
538                                  p->nr*sizeof(RAYVAL));
539                          if (outdev != NULL)     /* display it */
540                                  disp_packet((PACKHEAD *)p);
# Line 563 | Line 562 | register char  *rn, *fn;
562   {
563          char    *tp, *dp;
564  
565 <        for (tp = NULL, dp = rn; *rn = *fn++; rn++)
565 >        for (tp = NULL, dp = rn; (*rn = *fn++); rn++) {
566                  if (*rn == '/')
567                          dp = rn;
568                  else if (*rn == '.')
569                          tp = rn;
570 +        }
571          if (tp != NULL && tp > dp)
572                  *tp = '\0';
573   }
# Line 581 | Line 581 | int    vc;
581   }
582  
583  
584 + void
585   eputs(s)                        /* put error message to stderr */
586   register char  *s;
587   {
# Line 600 | Line 601 | register char  *s;
601   }
602  
603  
604 + void
605   quit(ec)                        /* exit program gracefully */
606   int     ec;
607   {
# Line 608 | Line 610 | int    ec;
610          if (hdlist[0] != NULL) {        /* close holodeck */
611                  if (nprocs > 0)
612                          status = done_rtrace();         /* calls hdsync() */
613 <                if (ncprocs > 0 & force >= 0 && vdef(REPORT)) {
614 <                        long    fsiz, fuse;
613 >                if ((ncprocs > 0) & (force >= 0) && vdef(REPORT)) {
614 >                        off_t   fsiz, fuse;
615                          fsiz = hdfilen(hdlist[0]->fd);
616                          fuse = hdfiluse(hdlist[0]->fd, 1);
617                          fprintf(stderr,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines