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.58 by greg, Sat Jun 21 14:48:54 2003 UTC vs.
Revision 3.62 by schorsch, Tue Oct 21 19:19:28 2003 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * Radiance holodeck generation controller
6   */
7  
8 #include "rholo.h"
9 #include "random.h"
8   #include <signal.h>
9   #include <sys/stat.h>
10 + #include <string.h>
11  
12 + #include "rholo.h"
13 + #include "platform.h"
14 + #include "random.h"
15 +
16   #ifndef FRAGWARN
17   #define FRAGWARN        20              /* fragmentation for warning (%) */
18   #endif
# Line 267 | Line 270 | initrholo()                    /* get our holodeck running */
270          }
271                                          /* set up signal handling */
272          sigdie(SIGINT, "Interrupt");
270        sigdie(SIGHUP, "Hangup");
273          sigdie(SIGTERM, "Terminate");
274 + #ifdef SIGHUP
275 +        sigdie(SIGHUP, "Hangup");
276 + #endif
277 + #ifdef SIGPIPE
278          sigdie(SIGPIPE, "Broken pipe");
279 + #endif
280 + #ifdef SIGALRM
281          sigdie(SIGALRM, "Alarm clock");
282 + #endif
283   #ifdef  SIGXCPU
284          sigdie(SIGXCPU, "CPU limit exceeded");
285 + #endif
286 + #ifdef  SIGXFSZ
287          sigdie(SIGXFSZ, "File size exceeded");
288   #endif
289                                          /* protect holodeck file */
290 <        orig_mode = resfmode(hdlist[0]->fd, ncprocs>0&force>=0 ? 0 : 0444);
290 >        orig_mode = resfmode(hdlist[0]->fd, (ncprocs>0) & (force>=0) ? 0 : 0444);
291          return;
292   memerr:
293          error(SYSTEM, "out of memory in initrholo");
# Line 431 | Line 442 | HDGRID *gp;
442          putw(HOLOMAGIC, fp);            /* put magic number */
443          fd = dup(fileno(fp));
444          fclose(fp);                     /* flush and close stdio stream */
445 <        lastloc = lseek(fd, (off_t)0, 2);
445 >        lastloc = lseek(fd, (off_t)0, SEEK_END);
446          for (n = vdef(SECTION); n--; gp++) {    /* initialize each section */
447                  nextloc = 0L;
448                  write(fd, (char *)&nextloc, sizeof(nextloc));
# Line 439 | Line 450 | HDGRID *gp;
450                  if (!n)
451                          break;
452                  nextloc = hdfilen(fd);          /* write section pointer */
453 <                if (lseek(fd, (off_t)lastloc, 0) < 0)
453 >                if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0)
454                          error(SYSTEM,
455                                  "cannot seek on holodeck file in creatholo");
456                  write(fd, (char *)&nextloc, sizeof(nextloc));
457 <                lseek(fd, (off_t)(lastloc=nextloc), 0);
457 >                lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET);
458          }
459   }
460  
# Line 481 | Line 492 | loadholo()                     /* start loading a holodeck from fname */
492          int     n;
493          int32   nextloc;
494          
495 <        if (ncprocs > 0 & force >= 0)
495 >        if ((ncprocs > 0) & (force >= 0))
496                  fp = fopen(hdkfile, "r+");
497          else
498                  fp = NULL;
# Line 510 | Line 521 | loadholo()                     /* start loading a holodeck from fname */
521          fd = dup(fileno(fp));
522          fclose(fp);                             /* done with stdio */
523          for (n = 0; nextloc > 0L; n++) {        /* initialize each section */
524 <                lseek(fd, (off_t)nextloc, 0);
524 >                lseek(fd, (off_t)nextloc, SEEK_SET);
525                  read(fd, (char *)&nextloc, sizeof(nextloc));
526                  hdinit(fd, NULL);
527          }
# Line 531 | Line 542 | PACKET *pl;
542          while (pl != NULL) {
543                  p = pl; pl = p->next; p->next = NULL;
544                  if (p->nr > 0) {                /* add to holodeck */
545 <                        bcopy((void *)p->ra,
546 <                                (void *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
545 >                        memcpy( (void *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
546 >                                (void *)p->ra,
547                                  p->nr*sizeof(RAYVAL));
548                          if (outdev != NULL)     /* display it */
549                                  disp_packet((PACKHEAD *)p);
# Line 560 | Line 571 | register char  *rn, *fn;
571   {
572          char    *tp, *dp;
573  
574 <        for (tp = NULL, dp = rn; *rn = *fn++; rn++)
574 >        for (tp = NULL, dp = rn; (*rn = *fn++); rn++) {
575                  if (*rn == '/')
576                          dp = rn;
577                  else if (*rn == '.')
578                          tp = rn;
579 +        }
580          if (tp != NULL && tp > dp)
581                  *tp = '\0';
582   }
# Line 607 | Line 619 | int    ec;
619          if (hdlist[0] != NULL) {        /* close holodeck */
620                  if (nprocs > 0)
621                          status = done_rtrace();         /* calls hdsync() */
622 <                if (ncprocs > 0 & force >= 0 && vdef(REPORT)) {
622 >                if ((ncprocs > 0) & (force >= 0) && vdef(REPORT)) {
623                          off_t   fsiz, fuse;
624                          fsiz = hdfilen(hdlist[0]->fd);
625                          fuse = hdfiluse(hdlist[0]->fd, 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines