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

Comparing ray/src/rt/rtmain.c (file contents):
Revision 2.1 by greg, Sat Feb 22 02:07:29 2003 UTC vs.
Revision 2.10 by greg, Wed May 25 04:44:26 2005 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   *  rtmain.c - main for rtrace per-ray calculation program
6   */
7  
8 < /* ====================================================================
9 < * The Radiance Software License, Version 1.0
10 < *
11 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
12 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
13 < *
14 < * Redistribution and use in source and binary forms, with or without
15 < * modification, are permitted provided that the following conditions
16 < * are met:
17 < *
18 < * 1. Redistributions of source code must retain the above copyright
19 < *         notice, this list of conditions and the following disclaimer.
20 < *
21 < * 2. Redistributions in binary form must reproduce the above copyright
22 < *       notice, this list of conditions and the following disclaimer in
23 < *       the documentation and/or other materials provided with the
24 < *       distribution.
25 < *
26 < * 3. The end-user documentation included with the redistribution,
27 < *           if any, must include the following acknowledgment:
28 < *             "This product includes Radiance software
29 < *                 (http://radsite.lbl.gov/)
30 < *                 developed by the Lawrence Berkeley National Laboratory
31 < *               (http://www.lbl.gov/)."
32 < *       Alternately, this acknowledgment may appear in the software itself,
33 < *       if and wherever such third-party acknowledgments normally appear.
34 < *
35 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
36 < *       and "The Regents of the University of California" must
37 < *       not be used to endorse or promote products derived from this
38 < *       software without prior written permission. For written
39 < *       permission, please contact [email protected].
40 < *
41 < * 5. Products derived from this software may not be called "Radiance",
42 < *       nor may "Radiance" appear in their name, without prior written
43 < *       permission of Lawrence Berkeley National Laboratory.
44 < *
45 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
46 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
49 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
52 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 < * SUCH DAMAGE.
57 < * ====================================================================
58 < *
59 < * This software consists of voluntary contributions made by many
60 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
61 < * information on Lawrence Berkeley National Laboratory, please see
62 < * <http://www.lbl.gov/>.
63 < */
8 > #include "copyright.h"
9  
10 < #include  "ray.h"
10 > #include  <sys/types.h>
11 > #include  <signal.h>
12  
13 + #include  "platform.h"
14 + #include  "rtprocess.h" /* getpid() */
15 + #include  "resolu.h"
16 + #include  "ray.h"
17   #include  "source.h"
68
18   #include  "ambient.h"
70
19   #include  "random.h"
72
20   #include  "paths.h"
21  
75 #include  <sys/types.h>
76
77 #include  <signal.h>
22                                          /* persistent processes define */
23   #ifdef  F_SETLKW
24   #define  PERSIST        1               /* normal persist */
# Line 83 | Line 27 | static const char      RCSid[] = "$Id$";
27   #endif
28  
29   char  *progname;                        /* argv[0] */
86
30   char  *octname;                         /* octree name */
88
31   char  *sigerr[NSIG];                    /* signal error messages */
90
32   char  *shm_boundary = NULL;             /* boundary of shared memory */
92
33   char  *errfile = NULL;                  /* error output file */
34  
35   extern char  *formstr();                /* string from format */
# Line 106 | Line 46 | extern int  lim_dist;                  /* limit distance? */
46   extern char  *tralist[];                /* list of modifers to trace (or no) */
47   extern int  traincl;                    /* include == 1, exclude == 0 */
48  
49 < void    onsig();
110 < void    sigdie();
111 < void    printdefaults();
49 > static int  loadflags = ~IO_FILES;      /* what to load from octree */
50  
51 + static void onsig(int  signo);
52 + static void sigdie(int  signo, char  *msg);
53 + static void printdefaults(void);
54  
55 +
56   int
57 < main(argc, argv)
116 < int  argc;
117 < char  *argv[];
57 > main(int  argc, char  *argv[])
58   {
59   #define  check(ol,al)           if (argv[i][ol] || \
60                                  badarg(argc-i-1,argv+i+1,al)) \
# Line 126 | Line 66 | char  *argv[];
66                                  case 'n': case 'N': case 'f': case 'F': \
67                                  case '-': case '0': var = 0; break; \
68                                  default: goto badopt; }
129        int  loadflags = ~IO_FILES;
69          int  persist = 0;
70          char  **tralp;
71          int  duped1;
# Line 231 | Line 170 | char  *argv[];
170                                  }
171                                  if (argv[i][2] == 'I') {        /* file */
172                                          rval = wordfile(tralp,
173 <                                        getpath(argv[++i],getlibpath(),R_OK));
173 >                                        getpath(argv[++i],getrlibpath(),R_OK));
174                                          if (rval < 0) {
175                                                  sprintf(errmsg,
176                                  "cannot open trace include file \"%s\"",
# Line 253 | Line 192 | char  *argv[];
192                                  }
193                                  if (argv[i][2] == 'E') {        /* file */
194                                          rval = wordfile(tralp,
195 <                                        getpath(argv[++i],getlibpath(),R_OK));
195 >                                        getpath(argv[++i],getrlibpath(),R_OK));
196                                          if (rval < 0) {
197                                                  sprintf(errmsg,
198                                  "cannot open trace exclude file \"%s\"",
# Line 292 | Line 231 | char  *argv[];
231          initurand(2048);
232                                          /* set up signal handling */
233          sigdie(SIGINT, "Interrupt");
234 + #ifdef SIGHUP
235          sigdie(SIGHUP, "Hangup");
236 + #endif
237          sigdie(SIGTERM, "Terminate");
238 + #ifdef SIGPIPE
239          sigdie(SIGPIPE, "Broken pipe");
240 + #endif
241 + #ifdef SIGALRM
242          sigdie(SIGALRM, "Alarm clock");
243 + #endif
244   #ifdef  SIGXCPU
245          sigdie(SIGXCPU, "CPU limit exceeded");
246          sigdie(SIGXFSZ, "File size exceeded");
# Line 329 | Line 274 | char  *argv[];
274                  openheader();
275          }
276   #endif
277 < #ifdef  MSDOS
277 > #ifdef  _WIN32
278          if (outform != 'a')
279 <                setmode(fileno(stdout), O_BINARY);
279 >                SET_FILE_BINARY(stdout);
280          if (octname == NULL)
281 <                setmode(fileno(stdin), O_BINARY);
281 >                SET_FILE_BINARY(stdin);
282   #endif
283          readoct(octname, loadflags, &thescene, NULL);
284          nsceneobjs = nobjects;
# Line 400 | Line 345 | runagain:
345   badopt:
346          sprintf(errmsg, "command line error at '%s'", argv[i]);
347          error(USER, errmsg);
348 +        return 1; /* pro forma return */
349  
350   #undef  check
351   #undef  bool
# Line 407 | Line 353 | badopt:
353  
354  
355   void
356 < wputs(s)                                /* warning output function */
357 < char    *s;
356 > wputs(                          /* warning output function */
357 >        char    *s
358 > )
359   {
360          int  lasterrno = errno;
361          eputs(s);
# Line 417 | Line 364 | char   *s;
364  
365  
366   void
367 < eputs(s)                                /* put string to stderr */
368 < register char  *s;
367 > eputs(                          /* put string to stderr */
368 >        register char  *s
369 > )
370   {
371          static int  midline = 0;
372  
# Line 436 | Line 384 | register char  *s;
384   }
385  
386  
387 < void
388 < onsig(signo)                            /* fatal signal */
389 < int  signo;
387 > static void
388 > onsig(                          /* fatal signal */
389 >        int  signo
390 > )
391   {
392          static int  gotsig = 0;
393  
394          if (gotsig++)                   /* two signals and we're gone! */
395                  _exit(signo);
396  
397 + #ifdef SIGALRM
398          alarm(15);                      /* allow 15 seconds to clean up */
399          signal(SIGALRM, SIG_DFL);       /* make certain we do die */
400 + #endif
401          eputs("signal - ");
402          eputs(sigerr[signo]);
403          eputs("\n");
# Line 454 | Line 405 | int  signo;
405   }
406  
407  
408 < void
409 < sigdie(signo, msg)                      /* set fatal signal */
410 < int  signo;
411 < char  *msg;
408 > static void
409 > sigdie(                 /* set fatal signal */
410 >        int  signo,
411 >        char  *msg
412 > )
413   {
414          if (signal(signo, onsig) == SIG_IGN)
415                  signal(signo, SIG_IGN);
# Line 465 | Line 417 | char  *msg;
417   }
418  
419  
420 < void
421 < printdefaults()                 /* print default values to stdout */
420 > static void
421 > printdefaults(void)                     /* print default values to stdout */
422   {
423          register char  *cp;
424  
425          if (imm_irrad)
426                  printf("-I+\t\t\t\t# immediate irradiance on\n");
427 <        printf("-x  %-9d\t\t\t# x resolution\n", hresolu);
427 >        printf("-x  %-9d\t\t\t# x resolution (flush interval)\n", hresolu);
428          printf("-y  %-9d\t\t\t# y resolution\n", vresolu);
429          printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" :
430                          "-ld-\t\t\t\t# limit distance off\n");
431 +        printf("-h%c\t\t\t\t# %s header\n", loadflags & IO_INFO ? '+' : '-',
432 +                        loadflags & IO_INFO ? "output" : "no");
433          printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n",
434                          inform, outform, formstr(inform), formstr(outform));
435 <        printf("-o%s\t\t\t\t# output", outvals);
435 >        printf("-o%-9s\t\t\t# output", outvals);
436          for (cp = outvals; *cp; cp++)
437                  switch (*cp) {
438 <                case 't': printf(" trace"); break;
438 >                case 't': case 'T': printf(" trace"); break;
439                  case 'o': printf(" origin"); break;
440                  case 'd': printf(" direction"); break;
441                  case 'v': printf(" value"); break;
# Line 493 | Line 447 | printdefaults()                        /* print default values to stdout */
447                  case 's': printf(" surface"); break;
448                  case 'w': printf(" weight"); break;
449                  case 'm': printf(" modifier"); break;
450 +                case 'M': printf(" material"); break;
451 +                case 'W': printf(" contribution"); break;
452 +                case '-': printf(" stroke"); break;
453                  }
454          putchar('\n');
455          printf(erract[WARNING].pf != NULL ?

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines