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

Comparing ray/src/util/rad.c (file contents):
Revision 2.2 by greg, Thu Mar 11 11:39:48 1993 UTC vs.
Revision 2.45 by greg, Mon Aug 28 10:12:40 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1994 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 11 | Line 11 | static char SCCSid[] = "$SunId$ LBL";
11   #include "standard.h"
12   #include "paths.h"
13   #include <ctype.h>
14 + #include <sys/types.h>
15  
16  
17   typedef struct {
# Line 21 | Line 22 | typedef struct {
22          int     (*fixval)();    /* assignment checking function */
23   } VARIABLE;
24  
25 < int     onevalue(), catvalues();
25 > int     onevalue(), catvalues(), boolvalue(),
26 >        qualvalue(), fltvalue(), intvalue();
27  
28                                  /* variables */
29   #define OBJECT          0               /* object files */
30   #define SCENE           1               /* scene files */
31   #define MATERIAL        2               /* material files */
32 < #define RENDER          3               /* rendering options */
33 < #define OCONV           4               /* oconv options */
34 < #define PFILT           5               /* pfilt options */
35 < #define VIEW            6               /* view(s) for picture(s) */
36 < #define ZONE            7               /* simulation zone */
37 < #define QUALITY         8               /* desired rendering quality */
38 < #define OCTREE          9               /* octree file name */
39 < #define PICTURE         10              /* picture file name */
40 < #define AMBFILE         11              /* ambient file name */
41 < #define OPTFILE         12              /* rendering options file */
42 < #define EXPOSURE        13              /* picture exposure setting */
43 < #define RESOLUTION      14              /* maximum picture resolution */
44 < #define UP              15              /* view up (X, Y or Z) */
45 < #define INDIRECT        16              /* indirection in lighting */
46 < #define DETAIL          17              /* level of scene detail */
47 < #define PENUMBRAS       18              /* shadow penumbras are desired */
48 < #define VARIABILITY     19              /* level of light variability */
49 < #define REPORT          20              /* report frequency and errfile */
32 > #define ILLUM           3               /* mkillum input files */
33 > #define MKILLUM         4               /* mkillum options */
34 > #define RENDER          5               /* rendering options */
35 > #define OCONV           6               /* oconv options */
36 > #define PFILT           7               /* pfilt options */
37 > #define VIEW            8               /* view(s) for picture(s) */
38 > #define ZONE            9               /* simulation zone */
39 > #define QUALITY         10              /* desired rendering quality */
40 > #define OCTREE          11              /* octree file name */
41 > #define PICTURE         12              /* picture file root name */
42 > #define AMBFILE         13              /* ambient file name */
43 > #define OPTFILE         14              /* rendering options file */
44 > #define EXPOSURE        15              /* picture exposure setting */
45 > #define RESOLUTION      16              /* maximum picture resolution */
46 > #define UP              17              /* view up (X, Y or Z) */
47 > #define INDIRECT        18              /* indirection in lighting */
48 > #define DETAIL          19              /* level of scene detail */
49 > #define PENUMBRAS       20              /* shadow penumbras are desired */
50 > #define VARIABILITY     21              /* level of light variability */
51 > #define REPORT          22              /* report frequency and errfile */
52 > #define RAWFILE         23              /* raw picture file root name */
53 > #define ZFILE           24              /* distance file root name */
54                                  /* total number of variables */
55 < #define NVARS           21
55 > #define NVARS           25
56  
57   VARIABLE        vv[NVARS] = {           /* variable-value pairs */
58          {"objects",     3,      0,      NULL,   catvalues},
59          {"scene",       3,      0,      NULL,   catvalues},
60          {"materials",   3,      0,      NULL,   catvalues},
61 +        {"illum",       3,      0,      NULL,   catvalues},
62 +        {"mkillum",     3,      0,      NULL,   catvalues},
63          {"render",      3,      0,      NULL,   catvalues},
64          {"oconv",       3,      0,      NULL,   catvalues},
65          {"pfilt",       2,      0,      NULL,   catvalues},
66          {"view",        2,      0,      NULL,   NULL},
67          {"ZONE",        2,      0,      NULL,   onevalue},
68 <        {"QUALITY",     3,      0,      NULL,   onevalue},
68 >        {"QUALITY",     3,      0,      NULL,   qualvalue},
69          {"OCTREE",      3,      0,      NULL,   onevalue},
70          {"PICTURE",     3,      0,      NULL,   onevalue},
71          {"AMBFILE",     3,      0,      NULL,   onevalue},
72          {"OPTFILE",     3,      0,      NULL,   onevalue},
73 <        {"EXPOSURE",    3,      0,      NULL,   onevalue},
73 >        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
74          {"RESOLUTION",  3,      0,      NULL,   onevalue},
75          {"UP",          2,      0,      NULL,   onevalue},
76 <        {"INDIRECT",    3,      0,      NULL,   onevalue},
77 <        {"DETAIL",      3,      0,      NULL,   onevalue},
78 <        {"PENUMBRAS",   3,      0,      NULL,   onevalue},
79 <        {"VARIABILITY", 3,      0,      NULL,   onevalue},
76 >        {"INDIRECT",    3,      0,      NULL,   intvalue},
77 >        {"DETAIL",      3,      0,      NULL,   qualvalue},
78 >        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
79 >        {"VARIABILITY", 3,      0,      NULL,   qualvalue},
80          {"REPORT",      3,      0,      NULL,   onevalue},
81 +        {"RAWFILE",     3,      0,      NULL,   onevalue},
82 +        {"ZFILE",       2,      0,      NULL,   onevalue},
83   };
84  
85   VARIABLE        *matchvar();
86   char    *nvalue();
77 int     vscale();
87  
88 + #define UPPER(c)        ((c)&~0x20)     /* ASCII trick */
89 +
90   #define vnam(vc)        (vv[vc].name)
91   #define vdef(vc)        (vv[vc].nass)
92   #define vval(vc)        (vv[vc].value)
93   #define vint(vc)        atoi(vval(vc))
94 < #define vlet(vc)        (vval(vc)[0]&~0x20)
94 > #define vlet(vc)        UPPER(vval(vc)[0])
95 > #define vscale          vlet
96   #define vbool(vc)       (vlet(vc)=='T')
97  
98 < #define HIGH            2
99 < #define MEDIUM          1
100 < #define LOW             0
98 > #define HIGH            'H'
99 > #define MEDIUM          'M'
100 > #define LOW             'L'
101  
102 < int     lowqopts(), medqopts(), hiqopts();
103 < int     (*setqopts[3])() = {lowqopts, medqopts, hiqopts};
102 >                                /* overture calculation file */
103 > #ifdef NIX
104 > char    overfile[] = "overture.unf";
105 > #else
106 > char    overfile[] = "/dev/null";
107 > #endif
108  
109 < #define renderopts      (*setqopts[vscale(QUALITY)])
109 > extern time_t   fdate(), time();
110  
111 < extern long     fdate(), time();
111 > time_t  scenedate;              /* date of latest scene or object file */
112 > time_t  octreedate;             /* date of octree */
113 > time_t  matdate;                /* date of latest material file */
114 > time_t  illumdate;              /* date of last illum file */
115  
116 < long    scenedate;              /* date of latest scene or object file */
117 < long    octreedate;             /* date of octree */
116 > char    *oct0name;              /* name of pre-mkillum octree */
117 > time_t  oct0date;               /* date of pre-mkillum octree */
118 > char    *oct1name;              /* name of post-mkillum octree */
119 > time_t  oct1date;               /* date of post-mkillum octree (>= matdate) */
120  
121 + int     nowarn = 0;             /* no warnings */
122   int     explicate = 0;          /* explicate variables */
123   int     silent = 0;             /* do work silently */
124 + int     touchonly = 0;          /* touch files only */
125   int     noaction = 0;           /* don't do anything */
126 + int     sayview = 0;            /* print view out */
127   char    *rvdevice = NULL;       /* rview output device */
128   char    *viewselect = NULL;     /* specific view only */
129  
130   int     overture = 0;           /* overture calculation needed */
131  
132   char    *progname;              /* global argv[0] */
133 + char    *rifname;               /* global rad input file name */
134  
135   char    radname[MAXPATH];       /* root Radiance file name */
136  
# Line 115 | Line 140 | int    argc;
140   char    *argv[];
141   {
142          char    ropts[512];
143 +        char    popts[64];
144          int     i;
145  
146          progname = argv[0];
# Line 127 | Line 153 | char   *argv[];
153                  case 'n':
154                          noaction++;
155                          break;
156 +                case 't':
157 +                        touchonly++;
158 +                        break;
159                  case 'e':
160                          explicate++;
161                          break;
162                  case 'o':
163                          rvdevice = argv[++i];
164                          break;
165 +                case 'V':
166 +                        sayview++;
167 +                        break;
168                  case 'v':
169                          viewselect = argv[++i];
170                          break;
171 +                case 'w':
172 +                        nowarn++;
173 +                        break;
174                  default:
175                          goto userr;
176                  }
177          if (i >= argc)
178                  goto userr;
179 +        rifname = argv[i];
180                                  /* assign Radiance root file name */
181 <        rootname(radname, argv[i]);
181 >        rootname(radname, rifname);
182                                  /* load variable values */
183 <        load(argv[i]);
183 >        load(rifname);
184                                  /* get any additional assignments */
185          for (i++; i < argc; i++)
186                  setvariable(argv[i]);
# Line 157 | Line 193 | char   *argv[];
193                                  /* print all values if requested */
194          if (explicate)
195                  printvals();
196 <                                /* run simulation */
196 >                                /* build octree (and run mkillum) */
197          oconv();
198 <        renderopts(ropts);
198 >                                /* check date on ambient file */
199 >        checkambfile();
200 >                                /* run simulation */
201 >        renderopts(ropts, popts);
202          xferopts(ropts);
203          if (rvdevice != NULL)
204 <                rview(ropts);
204 >                rview(ropts, popts);
205          else
206 <                rpict(ropts);
206 >                rpict(ropts, popts);
207          exit(0);
208   userr:
209          fprintf(stderr,
210 <        "Usage: %s [-s][-n][-v view][-o dev] rfile [VAR=value ..]\n",
210 > "Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
211                          progname);
212          exit(1);
213   }
# Line 189 | Line 228 | register char  *rn, *fn;
228   }
229  
230  
231 + #define NOCHAR  127             /* constant for character to delete */
232 +
233 +
234   load(rfname)                    /* load Radiance simulation file */
235   char    *rfname;
236   {
237          FILE    *fp;
238 <        char    buf[256];
238 >        char    buf[512];
239          register char   *cp;
240  
241          if (rfname == NULL)
242                  fp = stdin;
243 <        else if ((fp = fopen(rfname, "r")) == NULL) {
244 <                perror(rfname);
203 <                exit(1);
204 <        }
243 >        else if ((fp = fopen(rfname, "r")) == NULL)
244 >                syserr(rfname);
245          while (fgetline(buf, sizeof(buf), fp) != NULL) {
246                  for (cp = buf; *cp; cp++) {
247                          switch (*cp) {
248                          case '\\':
249 <                        case '\n':
210 <                                *cp = ' ';
249 >                                *cp++ = NOCHAR;
250                                  continue;
251                          case '#':
252                                  *cp = '\0';
253                                  break;
254 +                        default:
255 +                                continue;
256                          }
257                          break;
258                  }
# Line 225 | Line 266 | setvariable(ass)               /* assign variable according to stri
266   register char   *ass;
267   {
268          char    varname[32];
269 +        int     n;
270          register char   *cp;
271          register VARIABLE       *vp;
272          register int    i;
231        int     n;
273  
274          while (isspace(*ass))           /* skip leading space */
275                  ass++;
# Line 242 | Line 283 | register char  *ass;
283                                          /* trim value */
284          while (isspace(*ass) || *ass == '=')
285                  ass++;
286 <        cp = ass + strlen(ass);
287 <        do
288 <                *cp-- = '\0';
289 <        while (cp >= ass && isspace(*cp));
249 <        n = cp - ass + 1;
250 <        if (!n) {
286 >        for (n = strlen(ass); n > 0; n--)
287 >                if (!isspace(ass[n-1]))
288 >                        break;
289 >        if (!n && !nowarn) {
290                  fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
291                                  progname, varname);
292                  return;
# Line 260 | Line 299 | register char  *ass;
299                  exit(1);
300          }
301                                          /* assign new value */
302 <        cp = vp->value; i = vp->nass;
303 <        while (i--)
304 <                while (*cp++)
305 <                        ;
306 <        i = cp - vp->value;
307 <        vp->value = realloc(vp->value, i+n+1);
308 <        if (vp->value == NULL) {
309 <                perror(progname);
310 <                exit(1);
302 >        if (i = vp->nass) {
303 >                cp = vp->value;
304 >                while (i--)
305 >                        while (*cp++)
306 >                                ;
307 >                i = cp - vp->value;
308 >                vp->value = realloc(vp->value, i+n+1);
309 >        } else
310 >                vp->value = malloc(n+1);
311 >        if (vp->value == NULL)
312 >                syserr(progname);
313 >        cp = vp->value+i;               /* copy value, squeezing spaces */
314 >        *cp = *ass;
315 >        for (i = 1; i <= n; i++) {
316 >                if (ass[i] == NOCHAR)
317 >                        continue;
318 >                if (isspace(*cp))
319 >                        while (isspace(ass[i]))
320 >                                i++;
321 >                *++cp = ass[i];
322          }
323 <        strcpy(vp->value+i, ass);
323 >        if (isspace(*cp))               /* remove trailing space */
324 >                *cp = '\0';
325          vp->nass++;
326   }
327  
# Line 296 | Line 347 | register int   n;
347   {
348          register char   *cp;
349  
350 <        if (vp == NULL || n < 0 || n >= vp->nass)
350 >        if (vp == NULL | n < 0 | n >= vp->nass)
351                  return(NULL);
352          cp = vp->value;
353          while (n--)
# Line 306 | Line 357 | register int   n;
357   }
358  
359  
309 int
310 vscale(vc)                      /* return scale for variable vc */
311 int     vc;
312 {
313        switch(vlet(vc)) {
314        case 'H':
315                return(HIGH);
316        case 'M':
317                return(MEDIUM);
318        case 'L':
319                return(LOW);
320        }
321        fprintf(stderr, "%s: illegal value for variable '%s' (%s)\n",
322                        progname, vnam(vc), vval(vc));
323        exit(1);
324 }
325
326
360   checkvalues()                   /* check assignments */
361   {
362          register int    i;
# Line 339 | Line 372 | register VARIABLE      *vp;
372   {
373          if (vp->nass < 2)
374                  return;
375 <        fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n",
375 >        if (!nowarn)
376 >                fprintf(stderr,
377 >                "%s: warning - multiple assignment of variable '%s'\n",
378                          progname, vp->name);
379          do
380                  vp->value += strlen(vp->value)+1;
# Line 362 | Line 397 | register VARIABLE      *vp;
397   }
398  
399  
400 < long
400 > int
401 > badmatch(tv, cv)                /* case insensitive truncated comparison */
402 > register char   *tv, *cv;
403 > {
404 >        if (!*tv) return(1);            /* null string cannot match */
405 >        do
406 >                if (UPPER(*tv) != *cv++)
407 >                        return(1);
408 >        while (*++tv);
409 >        return(0);              /* OK */
410 > }
411 >
412 >
413 > boolvalue(vp)                   /* check boolean for legal values */
414 > register VARIABLE       *vp;
415 > {
416 >        if (!vp->nass) return;
417 >        onevalue(vp);
418 >        switch (UPPER(vp->value[0])) {
419 >        case 'T':
420 >                if (badmatch(vp->value, "TRUE")) break;
421 >                return;
422 >        case 'F':
423 >                if (badmatch(vp->value, "FALSE")) break;
424 >                return;
425 >        }
426 >        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
427 >                        progname, vp->name);
428 >        exit(1);
429 > }
430 >
431 >
432 > qualvalue(vp)                   /* check qualitative var. for legal values */
433 > register VARIABLE       *vp;
434 > {
435 >        if (!vp->nass) return;
436 >        onevalue(vp);
437 >        switch (UPPER(vp->value[0])) {
438 >        case 'L':
439 >                if (badmatch(vp->value, "LOW")) break;
440 >                return;
441 >        case 'M':
442 >                if (badmatch(vp->value, "MEDIUM")) break;
443 >                return;
444 >        case 'H':
445 >                if (badmatch(vp->value, "HIGH")) break;
446 >                return;
447 >        }
448 >        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
449 >                        progname, vp->name);
450 >        exit(1);
451 > }
452 >
453 >
454 > intvalue(vp)                    /* check integer variable for legal values */
455 > register VARIABLE       *vp;
456 > {
457 >        if (!vp->nass) return;
458 >        onevalue(vp);
459 >        if (isint(vp->value)) return;
460 >        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
461 >                        progname, vp->name);
462 >        exit(1);
463 > }
464 >
465 >
466 > fltvalue(vp)                    /* check float variable for legal values */
467 > register VARIABLE       *vp;
468 > {
469 >        if (!vp->nass) return;
470 >        onevalue(vp);
471 >        if (isflt(vp->value)) return;
472 >        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
473 >                        progname, vp->name);
474 >        exit(1);
475 > }
476 >
477 >
478 > time_t
479   checklast(fnames)                       /* check files and find most recent */
480   register char   *fnames;
481   {
482          char    thisfile[MAXPATH];
483 <        long    thisdate, lastdate = -1;
483 >        time_t  thisdate, lastdate = 0;
484          register char   *cp;
485  
486 +        if (fnames == NULL)
487 +                return(0);
488          while (*fnames) {
489                  while (isspace(*fnames)) fnames++;
490                  cp = thisfile;
491 <                while (*fnames && !isspace(*fnames)) *cp++ = *fnames++;
491 >                while (*fnames && !isspace(*fnames))
492 >                        *cp++ = *fnames++;
493                  *cp = '\0';
494 <                if ((thisdate = fdate(thisfile)) < 0) {
495 <                        perror(thisfile);
380 <                        exit(1);
381 <                }
494 >                if (!(thisdate = fdate(thisfile)))
495 >                        syserr(thisfile);
496                  if (thisdate > lastdate)
497                          lastdate = thisdate;
498          }
# Line 386 | Line 500 | register char  *fnames;
500   }
501  
502  
503 + char *
504 + newfname(orig, pred)            /* create modified file name */
505 + char    *orig;
506 + int     pred;
507 + {
508 +        extern char     *rindex();
509 +        register char   *cp;
510 +        register int    n;
511 +        int     suffix;
512 +
513 +        n = 0; cp = orig; suffix = -1;          /* suffix position, length */
514 +        while (*cp) {
515 +                if (*cp == '.') suffix = n;
516 +                else if (ISDIRSEP(*cp)) suffix = -1;
517 +                cp++; n++;
518 +        }
519 +        if (suffix == -1) suffix = n;
520 +        if ((cp = bmalloc(n+2)) == NULL)
521 +                syserr(progname);
522 +        strncpy(cp, orig, suffix);
523 +        cp[suffix] = pred;                      /* root name + pred + suffix */
524 +        strcpy(cp+suffix+1, orig+suffix);
525 +        return(cp);
526 + }
527 +
528 +
529   checkfiles()                    /* check for existence and modified times */
530   {
531 <        char    *cp;
392 <        long    objdate;
531 >        time_t  objdate;
532  
533          if (!vdef(OCTREE)) {
534 <                if ((cp = bmalloc(strlen(radname)+5)) == NULL) {
535 <                        perror(progname);
536 <                        exit(1);
398 <                }
399 <                sprintf(cp, "%s.oct", radname);
400 <                vval(OCTREE) = cp;
534 >                if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL)
535 >                        syserr(progname);
536 >                sprintf(vval(OCTREE), "%s.oct", radname);
537                  vdef(OCTREE)++;
538          }
539          octreedate = fdate(vval(OCTREE));
540 <        scenedate = -1;
541 <        if (vdef(SCENE)) {
542 <                scenedate = checklast(vval(SCENE));
543 <                if (vdef(OBJECT)) {
544 <                        objdate = checklast(vval(OBJECT));
545 <                        if (objdate > scenedate)
546 <                                scenedate = objdate;
547 <                }
548 <        }
549 <        if (octreedate < 0 & scenedate < 0) {
550 <                fprintf(stderr, "%s: need '%s' or '%s'\n", progname,
551 <                                vnam(OCTREE), vnam(SCENE));
540 >        if (vdef(ILLUM)) {              /* illum requires secondary octrees */
541 >                oct0name = newfname(vval(OCTREE), '0');
542 >                oct1name = newfname(vval(OCTREE), '1');
543 >                oct0date = fdate(oct0name);
544 >                oct1date = fdate(oct1name);
545 >        } else
546 >                oct0name = oct1name = vval(OCTREE);
547 >        if ((scenedate = checklast(vval(SCENE))) &&
548 >                        (objdate = checklast(vval(OBJECT))) > scenedate)
549 >                scenedate = objdate;
550 >        illumdate = checklast(vval(ILLUM));
551 >        if (!octreedate & !scenedate & !illumdate) {
552 >                fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
553 >                                vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
554                  exit(1);
555          }
556 +        matdate = checklast(vval(MATERIAL));
557   }      
558  
559  
# Line 423 | Line 562 | double org[3], *sizp;
562   {
563          extern FILE     *popen();
564          static double   oorg[3], osiz = 0.;
565 <        char    buf[MAXPATH+16];
565 >        double  min[3], max[3];
566 >        char    buf[512];
567          FILE    *fp;
568 +        register int    i;
569  
570 <        if (osiz <= FTINY) {
571 <                oconv();                /* does nothing if done already */
572 <                sprintf(buf, "getinfo -d < %s", vval(OCTREE));
573 <                if ((fp = popen(buf, "r")) == NULL) {
574 <                        perror("getinfo");
575 <                        exit(1);
576 <                }
577 <                if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
578 <                                &oorg[2], &osiz) != 4) {
579 <                        fprintf(stderr,
570 >        if (osiz <= FTINY)
571 >                if (noaction && fdate(oct1name) <
572 >                                (scenedate>illumdate?scenedate:illumdate)) {
573 >                                                        /* run getbbox */
574 >                        sprintf(buf, "getbbox -w -h %s",
575 >                                vdef(SCENE) ? vval(SCENE) : vval(ILLUM));
576 >                        if ((fp = popen(buf, "r")) == NULL)
577 >                                syserr("getbbox");
578 >                        if (fscanf(fp, "%lf %lf %lf %lf %lf %lf",
579 >                                        &min[0], &max[0], &min[1], &max[1],
580 >                                        &min[2], &max[2]) != 6) {
581 >                                fprintf(stderr,
582 >                        "%s: error reading bounding box from getbbox\n",
583 >                                                progname);
584 >                                exit(1);
585 >                        }
586 >                        for (i = 0; i < 3; i++)
587 >                                if (max[i] - min[i] > osiz)
588 >                                        osiz = max[i] - min[i];
589 >                        for (i = 0; i < 3; i++)
590 >                                oorg[i] = (max[i]+min[i]-osiz)*.5;
591 >                        pclose(fp);
592 >                } else {                                /* from octree */
593 >                        oconv();        /* does nothing if done already */
594 >                        sprintf(buf, "getinfo -d < %s", oct1name);
595 >                        if ((fp = popen(buf, "r")) == NULL)
596 >                                syserr("getinfo");
597 >                        if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1],
598 >                                        &oorg[2], &osiz) != 4) {
599 >                                fprintf(stderr,
600                          "%s: error reading bounding cube from getinfo\n",
601 <                                        progname);
602 <                        exit(1);
601 >                                                progname);
602 >                                exit(1);
603 >                        }
604 >                        pclose(fp);
605                  }
443                pclose(fp);
444        }
606          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
607   }
608  
# Line 458 | Line 619 | setdefaults()                  /* set default values for unassigned v
619                  vval(ZONE) = savqstr(buf);
620                  vdef(ZONE)++;
621          }
461        if (!vdef(UP)) {
462                vval(UP) = "Z";
463                vdef(UP)++;
464        }
622          if (!vdef(INDIRECT)) {
623                  vval(INDIRECT) = "0";
624                  vdef(INDIRECT)++;
# Line 499 | Line 656 | setdefaults()                  /* set default values for unassigned v
656  
657   printvals()                     /* print variable values */
658   {
659 <        register int    i, j;
659 >        int     i, j, clipline;
660 >        register char   *cp;
661 >        register int    k;
662  
663 <        for (i = 0; i < NVARS; i++)
664 <                for (j = 0; j < vv[i].nass; j++)
665 <                        printf("%s= %s\n", vv[i].name, nvalue(vv+i, j));
663 >        for (i = 0; i < NVARS; i++)             /* print each variable */
664 >            for (j = 0; j < vdef(i); j++) {     /* print each assignment */
665 >                fputs(vnam(i), stdout);
666 >                fputs("= ", stdout);
667 >                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
668 >                                - strlen(vnam(i)) ;
669 >                cp = nvalue(vv+i, j);
670 >                while (*cp) {
671 >                    putchar(*cp++);
672 >                    if (--k <= 0) {             /* line too long */
673 >                        while (*cp && !isspace(*cp))
674 >                            putchar(*cp++);     /* finish this word */
675 >                        if (*cp) {              /* start new line */
676 >                            putchar('\n');
677 >                            fputs(vnam(i), stdout);
678 >                            putchar('=');
679 >                            k = clipline;
680 >                        }
681 >                    }
682 >                }
683 >                putchar('\n');
684 >            }
685          fflush(stdout);
686   }
687  
688  
689 < oconv()                         /* run oconv if necessary */
689 > oconv()                         /* run oconv and mkillum if necessary */
690   {
691 <        char    combuf[512], ocopts[64];
691 >        static char     illumtmp[] = "ilXXXXXX";
692 >        char    combuf[512], ocopts[64], mkopts[64];
693  
694 <        if (octreedate >= scenedate)    /* check dates */
695 <                return;
696 <                                        /* build command */
697 <        oconvopts(ocopts);
698 <        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
699 <                        vdef(MATERIAL) ? vval(MATERIAL) : "",
700 <                        vval(SCENE), vval(OCTREE));
701 <        if (!silent) {                  /* echo it */
702 <                printf("\t%s\n", combuf);
703 <                fflush(stdout);
694 >        oconvopts(ocopts);              /* get options */
695 >        if (octreedate < scenedate) {   /* check date on original octree */
696 >                if (touchonly && octreedate)
697 >                        touch(vval(OCTREE));
698 >                else {                          /* build command */
699 >                        if (vdef(MATERIAL))
700 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
701 >                                                vval(MATERIAL), vval(SCENE),
702 >                                                vval(OCTREE));
703 >                        else
704 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
705 >                                                vval(SCENE), vval(OCTREE));
706 >                        
707 >                        if (runcom(combuf)) {           /* run it */
708 >                                fprintf(stderr,
709 >                                "%s: error generating octree\n\t%s removed\n",
710 >                                                progname, vval(OCTREE));
711 >                                unlink(vval(OCTREE));
712 >                                exit(1);
713 >                        }
714 >                }
715 >                octreedate = time((time_t *)NULL);
716 >                if (octreedate < scenedate)     /* in case clock is off */
717 >                        octreedate = scenedate;
718          }
719 <        if (noaction)
719 >        if (oct1name == vval(OCTREE))           /* no mkillum? */
720 >                oct1date = octreedate > matdate ? octreedate : matdate;
721 >        if (oct1date >= octreedate & oct1date >= matdate
722 >                        & oct1date >= illumdate)        /* all done */
723                  return;
724 <        if (system(combuf)) {           /* run it */
725 <                fprintf(stderr, "%s: error generating octree\n\t%s removed\n",
726 <                                progname, vval(OCTREE));
727 <                unlink(vval(OCTREE));
728 <                exit(1);
724 >                                                /* make octree0 */
725 >        if (oct0date < scenedate | oct0date < illumdate) {
726 >                if (touchonly && oct0date)
727 >                        touch(oct0name);
728 >                else {                          /* build command */
729 >                        if (octreedate)
730 >                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
731 >                                        vval(OCTREE), vval(ILLUM), oct0name);
732 >                        else if (vdef(MATERIAL))
733 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
734 >                                        vval(MATERIAL), vval(ILLUM), oct0name);
735 >                        else
736 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
737 >                                        vval(ILLUM), oct0name);
738 >                        if (runcom(combuf)) {           /* run it */
739 >                                fprintf(stderr,
740 >                                "%s: error generating octree\n\t%s removed\n",
741 >                                                progname, oct0name);
742 >                                unlink(oct0name);
743 >                                exit(1);
744 >                        }
745 >                }
746 >                oct0date = time((time_t *)NULL);
747 >                if (oct0date < octreedate)      /* in case clock is off */
748 >                        oct0date = octreedate;
749 >                if (oct0date < illumdate)       /* ditto */
750 >                        oct0date = illumdate;
751 >                }
752 >        if (touchonly && oct1date)
753 >                touch(oct1name);
754 >        else {
755 >                mkillumopts(mkopts);            /* build mkillum command */
756 >                mktemp(illumtmp);
757 >                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
758 >                                oct0name, vval(ILLUM), illumtmp);
759 >                if (runcom(combuf)) {                   /* run it */
760 >                        fprintf(stderr, "%s: error running mkillum\n",
761 >                                        progname);
762 >                        unlink(illumtmp);
763 >                        exit(1);
764 >                }
765 >                                                /* make octree1 (frozen) */
766 >                if (octreedate)
767 >                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
768 >                                vval(OCTREE), illumtmp, oct1name);
769 >                else if (vdef(MATERIAL))
770 >                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
771 >                                vval(MATERIAL), illumtmp, oct1name);
772 >                else
773 >                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
774 >                                illumtmp, oct1name);
775 >                if (runcom(combuf)) {           /* run it */
776 >                        fprintf(stderr,
777 >                                "%s: error generating octree\n\t%s removed\n",
778 >                                        progname, oct1name);
779 >                        unlink(oct1name);
780 >                        exit(1);
781 >                }
782 >                rmfile(illumtmp);
783          }
784 <        octreedate = time(0);
784 >        oct1date = time((time_t *)NULL);
785 >        if (oct1date < oct0date)        /* in case clock is off */
786 >                oct1date = oct0date;
787   }
788  
789  
# Line 557 | Line 809 | register char  *oo;
809   }
810  
811  
812 + mkillumopts(mo)                         /* get mkillum options */
813 + register char   *mo;
814 + {
815 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
816 +
817 +        *mo = '\0';
818 +        if (vdef(MKILLUM))
819 +                addarg(mo, vval(MKILLUM));
820 + }
821 +
822 +
823 + checkambfile()                  /* check date on ambient file */
824 + {
825 +        time_t  afdate;
826 +
827 +        if (!vdef(AMBFILE))
828 +                return;
829 +        if (!(afdate = fdate(vval(AMBFILE))))
830 +                return;
831 +        if (oct1date > afdate)
832 +                if (touchonly)
833 +                        touch(vval(AMBFILE));
834 +                else
835 +                        rmfile(vval(AMBFILE));
836 + }
837 +
838 +
839   double
840   ambval()                                /* compute ambient value */
841   {
842 <        if (vdef(EXPOSURE))
842 >        if (vdef(EXPOSURE)) {
843                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
844                          return(.5/pow(2.,atof(vval(EXPOSURE))));
845 <                else
846 <                        return(.5/atof(vval(EXPOSURE)));
845 >                return(.5/atof(vval(EXPOSURE)));
846 >        }
847          if (vlet(ZONE) == 'E')
848                  return(10.);
849 <        else
849 >        if (vlet(ZONE) == 'I')
850                  return(.01);
851 +        badvalue(ZONE);
852   }
853  
854  
855 < lowqopts(op)                            /* low quality rendering options */
855 > renderopts(op, po)                      /* set rendering options */
856 > char    *op, *po;
857 > {
858 >        switch(vscale(QUALITY)) {
859 >        case LOW:
860 >                lowqopts(op, po);
861 >                break;
862 >        case MEDIUM:
863 >                medqopts(op, po);
864 >                break;
865 >        case HIGH:
866 >                hiqopts(op, po);
867 >                break;
868 >        }
869 > }
870 >
871 >
872 > lowqopts(op, po)                        /* low quality rendering options */
873   register char   *op;
874 + char    *po;
875   {
876          double  d, org[3], siz[3];
877  
878          *op = '\0';
879 +        *po = '\0';
880          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
881 <                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) {
882 <                fprintf(stderr, "%s: bad value for variable '%s'\n",
584 <                                progname, vnam(ZONE));
585 <                exit(1);
586 <        }
881 >                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
882 >                badvalue(ZONE);
883          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
884 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
885 +                badvalue(ZONE);
886          getoctcube(org, &d);
887          d *= 3./(siz[0]+siz[1]+siz[2]);
888          switch (vscale(DETAIL)) {
889          case LOW:
890 <                op = addarg(op, "-ps 16");
891 <                op = addarg(op, "-dp 16");
890 >                po = addarg(po, "-ps 16");
891 >                op = addarg(op, "-dp 64");
892                  sprintf(op, " -ar %d", (int)(4*d));
893                  op += strlen(op);
894                  break;
895          case MEDIUM:
896 <                op = addarg(op, "-ps 8");
897 <                op = addarg(op, "-dp 32");
896 >                po = addarg(po, "-ps 8");
897 >                op = addarg(op, "-dp 128");
898                  sprintf(op, " -ar %d", (int)(8*d));
899                  op += strlen(op);
900                  break;
901          case HIGH:
902 <                op = addarg(op, "-ps 4");
903 <                op = addarg(op, "-dp 64");
902 >                po = addarg(po, "-ps 4");
903 >                op = addarg(op, "-dp 256");
904                  sprintf(op, " -ar %d", (int)(16*d));
905                  op += strlen(op);
906                  break;
907          }
908 <        op = addarg(op, "-pt .16");
908 >        po = addarg(po, "-pt .16");
909          if (vbool(PENUMBRAS))
910                  op = addarg(op, "-ds .4");
911 <        op = addarg(op, "-dt .2");
912 <        op = addarg(op, "-dc .25");
913 <        op = addarg(op, "-dr 0");
616 <        op = addarg(op, "-sj 0");
617 <        op = addarg(op, "-st .7");
618 <        op = addarg(op, "-ab 0");
911 >        else
912 >                op = addarg(op, "-ds 0");
913 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
914          if (vdef(AMBFILE)) {
915                  sprintf(op, " -af %s", vval(AMBFILE));
916                  op += strlen(op);
# Line 623 | Line 918 | register char  *op;
918                  overture = 0;
919          switch (vscale(VARIABILITY)) {
920          case LOW:
921 <                op = addarg(op, "-aa .4");
627 <                op = addarg(op, "-ad 32");
921 >                op = addarg(op, "-aa .4 -ad 64");
922                  break;
923          case MEDIUM:
924 <                op = addarg(op, "-aa .3");
631 <                op = addarg(op, "-ad 64");
924 >                op = addarg(op, "-aa .3 -ad 128");
925                  break;
926          case HIGH:
927 <                op = addarg(op, "-aa .25");
635 <                op = addarg(op, "-ad 128");
927 >                op = addarg(op, "-aa .25 -ad 256");
928                  break;
929          }
930          op = addarg(op, "-as 0");
931          d = ambval();
932          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
933          op += strlen(op);
934 <        op = addarg(op, "-lr 3");
643 <        op = addarg(op, "-lw .02");
934 >        op = addarg(op, "-lr 3 -lw .02");
935          if (vdef(RENDER))
936                  op = addarg(op, vval(RENDER));
937   }
938  
939  
940 < medqopts(op)                            /* medium quality rendering options */
940 > medqopts(op, po)                        /* medium quality rendering options */
941   register char   *op;
942 + char    *po;
943   {
944          double  d, org[3], siz[3];
945  
946          *op = '\0';
947 +        *po = '\0';
948          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
949 <                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) {
950 <                fprintf(stderr, "%s: bad value for variable '%s'\n",
658 <                                progname, vnam(ZONE));
659 <                exit(1);
660 <        }
949 >                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
950 >                badvalue(ZONE);
951          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
952 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
953 +                badvalue(ZONE);
954          getoctcube(org, &d);
955          d *= 3./(siz[0]+siz[1]+siz[2]);
956          switch (vscale(DETAIL)) {
957          case LOW:
958 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
959 <                op = addarg(op, "-dp 64");
958 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
959 >                op = addarg(op, "-dp 256");
960                  sprintf(op, " -ar %d", (int)(8*d));
961                  op += strlen(op);
962                  break;
963          case MEDIUM:
964 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
965 <                op = addarg(op, "-dp 128");
964 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
965 >                op = addarg(op, "-dp 512");
966                  sprintf(op, " -ar %d", (int)(16*d));
967                  op += strlen(op);
968                  break;
969          case HIGH:
970 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
971 <                op = addarg(op, "-dp 256");
970 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
971 >                op = addarg(op, "-dp 1024");
972                  sprintf(op, " -ar %d", (int)(32*d));
973                  op += strlen(op);
974                  break;
975          }
976 <        op = addarg(op, "-pt .08");
977 <        if (vbool(PENUMBRAS)) {
978 <                op = addarg(op, "-ds .2");
979 <                op = addarg(op, "-dj .35");
688 <        } else
976 >        po = addarg(po, "-pt .08");
977 >        if (vbool(PENUMBRAS))
978 >                op = addarg(op, "-ds .2 -dj .5");
979 >        else
980                  op = addarg(op, "-ds .3");
981 <        op = addarg(op, "-dt .1");
982 <        op = addarg(op, "-dc .5");
983 <        op = addarg(op, "-dr 1");
984 <        op = addarg(op, "-sj .7");
985 <        op = addarg(op, "-st .15");
695 <        sprintf(op, " -ab %d", overture=vint(INDIRECT));
696 <        op += strlen(op);
981 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
982 >        if (overture = vint(INDIRECT)) {
983 >                sprintf(op, " -ab %d", overture);
984 >                op += strlen(op);
985 >        }
986          if (vdef(AMBFILE)) {
987                  sprintf(op, " -af %s", vval(AMBFILE));
988                  op += strlen(op);
# Line 701 | Line 990 | register char  *op;
990                  overture = 0;
991          switch (vscale(VARIABILITY)) {
992          case LOW:
993 <                op = addarg(op, "-aa .25");
705 <                op = addarg(op, "-ad 128");
706 <                op = addarg(op, "-as 0");
993 >                op = addarg(op, "-aa .25 -ad 196 -as 0");
994                  break;
995          case MEDIUM:
996 <                op = addarg(op, "-aa .2");
710 <                op = addarg(op, "-ad 300");
711 <                op = addarg(op, "-as 64");
996 >                op = addarg(op, "-aa .2 -ad 400 -as 64");
997                  break;
998          case HIGH:
999 <                op = addarg(op, "-aa .15");
715 <                op = addarg(op, "-ad 500");
716 <                op = addarg(op, "-as 128");
999 >                op = addarg(op, "-aa .15 -ad 768 -as 196");
1000                  break;
1001          }
1002          d = ambval();
1003          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
1004          op += strlen(op);
1005 <        op = addarg(op, "-lr 6");
723 <        op = addarg(op, "-lw .002");
1005 >        op = addarg(op, "-lr 6 -lw .002");
1006          if (vdef(RENDER))
1007                  op = addarg(op, vval(RENDER));
1008   }
1009  
1010  
1011 < hiqopts(op)                             /* high quality rendering options */
1011 > hiqopts(op, po)                         /* high quality rendering options */
1012   register char   *op;
1013 + char    *po;
1014   {
1015          double  d, org[3], siz[3];
1016  
1017          *op = '\0';
1018 +        *po = '\0';
1019          if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0],
1020 <                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) {
1021 <                fprintf(stderr, "%s: bad value for variable '%s'\n",
738 <                                progname, vnam(ZONE));
739 <                exit(1);
740 <        }
1020 >                        &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
1021 >                badvalue(ZONE);
1022          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
1023 +        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
1024 +                badvalue(ZONE);
1025          getoctcube(org, &d);
1026          d *= 3./(siz[0]+siz[1]+siz[2]);
1027          switch (vscale(DETAIL)) {
1028          case LOW:
1029 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
1030 <                op = addarg(op, "-dp 256");
1029 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
1030 >                op = addarg(op, "-dp 1024");
1031                  sprintf(op, " -ar %d", (int)(16*d));
1032                  op += strlen(op);
1033                  break;
1034          case MEDIUM:
1035 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
1036 <                op = addarg(op, "-dp 512");
1035 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
1036 >                op = addarg(op, "-dp 2048");
1037                  sprintf(op, " -ar %d", (int)(32*d));
1038                  op += strlen(op);
1039                  break;
1040          case HIGH:
1041 <                op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1042 <                op = addarg(op, "-dp 1024");
1041 >                po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1042 >                op = addarg(op, "-dp 4096");
1043                  sprintf(op, " -ar %d", (int)(64*d));
1044                  op += strlen(op);
1045                  break;
1046          }
1047 <        op = addarg(op, "-pt .04");
1048 <        if (vbool(PENUMBRAS)) {
1049 <                op = addarg(op, "-ds .1");
1050 <                op = addarg(op, "-dj .7");
768 <        } else
1047 >        po = addarg(po, "-pt .04");
1048 >        if (vbool(PENUMBRAS))
1049 >                op = addarg(op, "-ds .1 -dj .65");
1050 >        else
1051                  op = addarg(op, "-ds .2");
1052 <        op = addarg(op, "-dt .05");
771 <        op = addarg(op, "-dc .75");
772 <        op = addarg(op, "-dr 3");
773 <        op = addarg(op, "-sj 1");
774 <        op = addarg(op, "-st .03");
1052 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
1053          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
1054          op += strlen(op);
1055          if (vdef(AMBFILE)) {
# Line 781 | Line 1059 | register char  *op;
1059                  overture = 0;
1060          switch (vscale(VARIABILITY)) {
1061          case LOW:
1062 <                op = addarg(op, "-aa .15");
785 <                op = addarg(op, "-ad 200");
786 <                op = addarg(op, "-as 0");
1062 >                op = addarg(op, "-aa .15 -ad 256 -as 0");
1063                  break;
1064          case MEDIUM:
1065 <                op = addarg(op, "-aa .125");
790 <                op = addarg(op, "-ad 512");
791 <                op = addarg(op, "-as 128");
1065 >                op = addarg(op, "-aa .125 -ad 512 -as 256");
1066                  break;
1067          case HIGH:
1068 <                op = addarg(op, "-aa .08");
795 <                op = addarg(op, "-ad 850");
796 <                op = addarg(op, "-as 256");
1068 >                op = addarg(op, "-aa .08 -ad 1024 -as 512");
1069                  break;
1070          }
1071          d = ambval();
1072          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
1073          op += strlen(op);
1074 <        op = addarg(op, "-lr 12");
803 <        op = addarg(op, "-lw .0005");
1074 >        op = addarg(op, "-lr 12 -lw .0005");
1075          if (vdef(RENDER))
1076                  op = addarg(op, vval(RENDER));
1077   }
# Line 810 | Line 1081 | xferopts(ro)                           /* transfer options if indicated */
1081   char    *ro;
1082   {
1083          int     fd, n;
1084 +        register char   *cp;
1085          
1086          n = strlen(ro);
1087          if (n < 2)
1088                  return;
1089          if (vdef(OPTFILE)) {
1090 <                if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
1091 <                        perror(vval(OPTFILE));
1092 <                        exit(1);
1093 <                }
1094 <                if (write(fd, ro+1, n-1) != n-1) {
1095 <                        perror(vval(OPTFILE));
1096 <                        exit(1);
1097 <                }
1098 <                write(fd, "\n", 1);
1099 <                close(fd);
828 <                ro[0] = ' ';
829 <                ro[1] = '^';
830 <                strcpy(ro+2, vval(OPTFILE));
1090 >                for (cp = ro; cp[1]; cp++)
1091 >                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
1092 >                                *cp = '\n';
1093 >                        else
1094 >                                *cp = cp[1];
1095 >                *cp = '\n';
1096 >                fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666);
1097 >                if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0)
1098 >                        syserr(vval(OPTFILE));
1099 >                sprintf(ro, " @%s", vval(OPTFILE));
1100          }
1101   #ifdef MSDOS
1102          else if (n > 50) {
1103 <                register char   *evp = bmalloc(n+6);
835 <                if (evp == NULL) {
836 <                        perror(progname);
837 <                        exit(1);
838 <                }
839 <                strcpy(evp, "ROPT=");
840 <                strcat(evp, ro);
841 <                if (putenv(evp) != 0) {
842 <                        fprintf(stderr, "%s: out of environment space\n",
843 <                                        progname);
844 <                        exit(1);
845 <                }
1103 >                setenv("ROPT", ro+1);
1104                  strcpy(ro, " $ROPT");
1105          }
1106   #endif
# Line 857 | Line 1115 | register char  *po;
1115                  po = addarg(po, "-1 -e");
1116                  po = addarg(po, vval(EXPOSURE));
1117          }
1118 <        if (vscale(QUALITY) == HIGH)
1119 <                po = addarg(po, "-r .65");
1118 >        switch (vscale(QUALITY)) {
1119 >        case MEDIUM:
1120 >                po = addarg(po, "-r 1");
1121 >                break;
1122 >        case HIGH:
1123 >                po = addarg(po, "-m .25");
1124 >                break;
1125 >        }
1126          if (vdef(PFILT))
1127                  po = addarg(po, vval(PFILT));
1128   }
# Line 880 | Line 1144 | char *
1144   specview(vs)                            /* get proper view spec from vs */
1145   register char   *vs;
1146   {
1147 +        static char     vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0",
1148 +                        "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"};
1149          static char     viewopts[128];
1150          register char   *cp;
1151 <        int     xpos, ypos, zpos, viewtype;
1152 <        int     exterior;
1151 >        int     xpos, ypos, zpos, viewtype, upax;
1152 >        register int    i;
1153          double  cent[3], dim[3], mult, d;
1154  
1155          if (vs == NULL || *vs == '-')
1156                  return(vs);
1157 +        upax = 0;                       /* get the up vector */
1158 +        if (vdef(UP)) {
1159 +                if (vval(UP)[0] == '-' || vval(UP)[0] == '+')
1160 +                        upax = 1-'X'+UPPER(vval(UP)[1]);
1161 +                else
1162 +                        upax = 1-'X'+vlet(UP);
1163 +                if (upax < 1 | upax > 3)
1164 +                        badvalue(UP);
1165 +                if (vval(UP)[0] == '-')
1166 +                        upax = -upax;
1167 +        }
1168                                          /* check standard view names */
1169          xpos = ypos = zpos = 0;
893        viewtype = 0;
1170          if (*vs == 'X') {
1171                  xpos = 1; vs++;
1172          } else if (*vs == 'x') {
# Line 906 | Line 1182 | register char  *vs;
1182          } else if (*vs == 'z') {
1183                  zpos = -1; vs++;
1184          }
1185 <        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h')
1185 >        viewtype = 'v';
1186 >        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c')
1187                  viewtype = *vs++;
911        else if (!*vs || isspace(*vs))
912                viewtype = 'v';
1188          cp = viewopts;
1189 <        if (viewtype && (xpos|ypos|zpos)) {     /* got standard view */
1189 >        if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
1190                  *cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype;
1191                  if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf",
1192                                  &cent[0], &dim[0], &cent[1], &dim[1],
1193 <                                &cent[2], &dim[2]) != 6) {
1194 <                        fprintf(stderr, "%s: bad zone specification\n",
1195 <                                        progname);
1196 <                        exit(1);
1193 >                                &cent[2], &dim[2]) != 6)
1194 >                        badvalue(ZONE);
1195 >                for (i = 0; i < 3; i++) {
1196 >                        dim[i] -= cent[i];
1197 >                        if (dim[i] <= FTINY)
1198 >                                badvalue(ZONE);
1199 >                        cent[i] += .5*dim[i];
1200                  }
1201 <                dim[0] -= cent[0]; cent[0] += .5*dim[0];
924 <                dim[1] -= cent[1]; cent[1] += .5*dim[1];
925 <                dim[2] -= cent[2]; cent[2] += .5*dim[2];
926 <                exterior = vlet(ZONE) == 'E';
927 <                mult = exterior ? 2. : .45 ;
1201 >                mult = vlet(ZONE)=='E' ? 2. : .45 ;
1202                  sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g",
1203                                  cent[0]+xpos*mult*dim[0],
1204                                  cent[1]+ypos*mult*dim[1],
1205                                  cent[2]+zpos*mult*dim[2],
1206                                  -xpos*dim[0], -ypos*dim[1], -zpos*dim[2]);
1207                  cp += strlen(cp);
1208 <                switch (vlet(UP)) {
1209 <                case 'Z':
1210 <                        if (xpos|ypos) {
1211 <                                cp = addarg(cp, "-vu 0 0 1");
1212 <                                break;
1213 <                        }
1214 <                /* fall through */
941 <                case 'Y':
942 <                        if (xpos|zpos) {
943 <                                cp = addarg(cp, "-vu 0 1 0");
944 <                                break;
945 <                        }
946 <                /* fall through */
947 <                case 'X':
948 <                        if (ypos|zpos)
949 <                                cp = addarg(cp, "-vu 1 0 0");
950 <                        else
951 <                                cp = addarg(cp, "-vu 0 0 1");
1208 >                                        /* redirect up axis if necessary */
1209 >                switch (upax) {
1210 >                case 3:                 /* plus or minus Z axis */
1211 >                case -3:
1212 >                case 0:
1213 >                        if (!(xpos|ypos))
1214 >                                upax = 2;
1215                          break;
1216 <                default:
1217 <                        fprintf(stderr, "%s: illegal value for variable '%s'\n",
1218 <                                        progname, vnam(UP));
1219 <                        exit(1);
1216 >                case 2:                 /* plus or minus Y axis */
1217 >                case -2:
1218 >                        if (!(xpos|zpos))
1219 >                                upax = 1;
1220 >                        break;
1221 >                case 1:                 /* plus or minus X axis */
1222 >                case -1:
1223 >                        if (!(ypos|zpos))
1224 >                                upax = 3;
1225 >                        break;
1226                  }
1227 +                cp = addarg(cp, vup[upax+3]);
1228                  switch (viewtype) {
1229                  case 'v':
1230                          cp = addarg(cp, "-vh 45 -vv 45");
# Line 968 | Line 1238 | register char  *vs;
1238                  case 'h':
1239                          cp = addarg(cp, "-vh 180 -vv 180");
1240                          break;
1241 +                case 'c':
1242 +                        cp = addarg(cp, "-vh 180 -vv 90");
1243 +                        break;
1244                  }
1245 <        } else
1246 <                while (*vs && !isspace(*vs))    /* else skip id */
1247 <                        vs++;
1248 <                                        /* append any additional options */
1249 <        while (isspace(*vs)) vs++;
1245 >        } else {
1246 >                while (!isspace(*vs))           /* else skip id */
1247 >                        if (!*vs++)
1248 >                                return(NULL);
1249 >                if (upax) {                     /* specify up vector */
1250 >                        strcpy(cp, vup[upax+3]);
1251 >                        cp += strlen(cp);
1252 >                }
1253 >        }
1254 >        if (cp == viewopts)             /* append any additional options */
1255 >                vs++;           /* skip prefixed space if unneeded */
1256          strcpy(cp, vs);
1257 + #ifdef MSDOS
1258 +        if (strlen(viewopts) > 40) {
1259 +                setenv("VIEW", viewopts);
1260 +                return("$VIEW");
1261 +        }
1262 + #endif
1263          return(viewopts);
1264   }
1265  
# Line 982 | Line 1267 | register char  *vs;
1267   char *
1268   getview(n, vn)                          /* get view n, or NULL if none */
1269   int     n;
1270 < char    *vn;
1270 > char    *vn;            /* returned view name */
1271   {
1272          register char   *mv;
1273  
1274 <        if (viewselect != NULL) {
1274 >        if (viewselect != NULL) {               /* command-line selected */
1275                  if (n)                          /* only do one */
1276                          return(NULL);
1277                  if (viewselect[0] == '-') {     /* already specified */
# Line 999 | Line 1284 | char   *vn;
1284                                  ;
1285                          *vn = '\0';
1286                  }
1287 +                                                /* view number? */
1288 +                if (isint(viewselect))
1289 +                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
1290                                                  /* check list */
1291                  while ((mv = nvalue(vv+VIEW, n++)) != NULL)
1292                          if (matchword(viewselect, mv))
1293                                  return(specview(mv));
1294                  return(specview(viewselect));   /* standard view? */
1295          }
1296 <        if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) {
1297 <                if (*mv != '-')
1298 <                        while (*mv && !isspace(*mv))
1299 <                                *vn++ = *mv++;
1296 >        mv = nvalue(vv+VIEW, n);                /* use view n */
1297 >        if (vn != NULL & mv != NULL) {
1298 >                register char   *mv2 = mv;
1299 >                if (*mv2 != '-')
1300 >                        while (*mv2 && !isspace(*mv2))
1301 >                                *vn++ = *mv2++;
1302                  *vn = '\0';
1303          }
1304 <        return(specview(nvalue(vv+VIEW, n)));   /* use view n */
1304 >        return(specview(mv));
1305   }
1306  
1307  
1308 < rview(opts)                             /* run rview with first view */
1309 < char    *opts;
1308 > printview(vopts)                        /* print out selected view */
1309 > register char   *vopts;
1310   {
1311 +        extern char     *atos(), *getenv();
1312 +        char    buf[256];
1313 +        FILE    *fp;
1314 +        register char   *cp;
1315 +
1316 +        if (vopts == NULL)
1317 +                return(-1);
1318 +        fputs("VIEW=", stdout);
1319 +        do {
1320 +                if (matchword(vopts, "-vf")) {          /* expand view file */
1321 +                        vopts = sskip(vopts);
1322 +                        if (!*atos(buf, sizeof(buf), vopts))
1323 +                                return(-1);
1324 +                        if ((fp = fopen(buf, "r")) == NULL)
1325 +                                return(-1);
1326 +                        for (buf[sizeof(buf)-2] = '\n';
1327 +                                        fgets(buf, sizeof(buf), fp) != NULL &&
1328 +                                                buf[0] != '\n';
1329 +                                        buf[sizeof(buf)-2] = '\n') {
1330 +                                if (buf[sizeof(buf)-2] != '\n') {
1331 +                                        ungetc(buf[sizeof(buf)-2], fp);
1332 +                                        buf[sizeof(buf)-2] = '\0';
1333 +                                }
1334 +                                if (matchword(buf, "VIEW=") ||
1335 +                                                matchword(buf, "rview")) {
1336 +                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1337 +                                                putchar(*cp);
1338 +                                }
1339 +                        }
1340 +                        fclose(fp);
1341 +                        vopts = sskip(vopts);
1342 +                } else {
1343 +                        while (isspace(*vopts))
1344 +                                vopts++;
1345 +                        putchar(' ');
1346 + #ifdef MSDOS
1347 +                        if (*vopts == '$') {            /* expand env. var. */
1348 +                                if (!*atos(buf, sizeof(buf), vopts+1))
1349 +                                        return(-1);
1350 +                                if ((cp = getenv(buf)) == NULL)
1351 +                                        return(-1);
1352 +                                fputs(cp, stdout);
1353 +                                vopts = sskip(vopts);
1354 +                        } else
1355 + #endif
1356 +                                while (*vopts && !isspace(*vopts))
1357 +                                        putchar(*vopts++);
1358 +                }
1359 +        } while (*vopts++);
1360 +        putchar('\n');
1361 +        return(0);
1362 + }
1363 +
1364 +
1365 + rview(opts, po)                         /* run rview with first view */
1366 + char    *opts, *po;
1367 + {
1368 +        char    *vw;
1369          char    combuf[512];
1370                                          /* build command */
1371 <        sprintf(combuf, "rview %s%s ", getview(0, NULL), opts);
1371 >        if (touchonly || (vw = getview(0, NULL)) == NULL)
1372 >                return;
1373 >        if (sayview)
1374 >                printview(vw);
1375 >        sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname);
1376          if (rvdevice != NULL)
1377                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1378 <        strcat(combuf, vval(OCTREE));
1379 <        if (!silent) {                  /* echo it */
1380 <                printf("\t%s\n", combuf);
1381 <                fflush(stdout);
1030 <        }
1031 <        if (noaction)
1032 <                return;
1033 <        if (system(combuf)) {           /* run it */
1378 >        if (vdef(EXPOSURE))
1379 >                sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1380 >        strcat(combuf, oct1name);
1381 >        if (runcom(combuf)) {           /* run it */
1382                  fprintf(stderr, "%s: error running rview\n", progname);
1383                  exit(1);
1384          }
1385   }
1386  
1387  
1388 < rpict(opts)                             /* run rpict and pfilt for each view */
1389 < char    *opts;
1388 > rpict(opts, po)                         /* run rpict and pfilt for each view */
1389 > char    *opts, *po;
1390   {
1391          char    combuf[1024];
1392 <        char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH], res[32];
1393 <        char    pfopts[64];
1392 >        char    rawfile[MAXPATH], picfile[MAXPATH];
1393 >        char    zopt[MAXPATH+4], rep[MAXPATH+16], res[32];
1394 >        char    pfopts[128];
1395          char    vs[32], *vw;
1396          int     vn, mult;
1397 +        time_t  rfdt, pfdt;
1398                                          /* get pfilt options */
1399          pfiltopts(pfopts);
1400                                          /* get resolution, reporting */
1401 <        mult = vscale(QUALITY)+1;
1401 >        switch (vscale(QUALITY)) {
1402 >        case LOW:
1403 >                mult = 1;
1404 >                break;
1405 >        case MEDIUM:
1406 >                mult = 2;
1407 >                break;
1408 >        case HIGH:
1409 >                mult = 3;
1410 >                break;
1411 >        }
1412          {
1413                  int     xres, yres;
1414                  double  aspect;
# Line 1060 | Line 1420 | char   *opts;
1420                  else if (n) {
1421                          if (n == 1) yres = xres;
1422                          sprintf(res, "-x %d -y %d", mult*xres, mult*yres);
1423 <                } else {
1424 <                        fprintf(stderr, "%s: bad value for variable '%s'\n",
1065 <                                        progname, vnam(RESOLUTION));
1066 <                        exit(1);
1067 <                }
1423 >                } else
1424 >                        badvalue(RESOLUTION);
1425          }
1426          rep[0] = '\0';
1427          if (vdef(REPORT)) {
# Line 1075 | Line 1432 | char   *opts;
1432                          sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile);
1433                  else if (n == 1)
1434                          sprintf(rep, " -t %d", (int)(minutes*60));
1435 <                else {
1436 <                        fprintf(stderr, "%s: bad value for variable '%s'\n",
1080 <                                        progname, vnam(REPORT));
1081 <                        exit(1);
1082 <                }
1435 >                else
1436 >                        badvalue(REPORT);
1437          }
1438                                          /* do each view */
1439          vn = 0;
1440          while ((vw = getview(vn++, vs)) != NULL) {
1441 +                if (sayview)
1442 +                        printview(vw);
1443                  if (!vs[0])
1444                          sprintf(vs, "%d", vn);
1445                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1446 +                if (vdef(ZFILE))
1447 +                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1448 +                else
1449 +                        zopt[0] = '\0';
1450                                                  /* check date on picture */
1451 <                if (fdate(picfile) > octreedate)
1451 >                pfdt = fdate(picfile);
1452 >                if (pfdt >= oct1date)
1453                          continue;
1454 +                                                /* get raw file name */
1455 +                sprintf(rawfile, "%s_%s.unf",
1456 +                        vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs);
1457 +                rfdt = fdate(rawfile);
1458 +                if (touchonly) {                /* update times only */
1459 +                        if (rfdt) {
1460 +                                if (rfdt < oct1date)
1461 +                                        touch(rawfile);
1462 +                        } else if (pfdt && pfdt < oct1date)
1463 +                                touch(picfile);
1464 +                        continue;
1465 +                }
1466                                                  /* build rpict command */
1467 <                sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1468 <                if (fdate(rawfile) > octreedate)        /* recover */
1469 <                        sprintf(combuf, "rpict%s%s -ro %s %s",
1097 <                                        rep, opts, rawfile, vval(OCTREE));
1467 >                if (rfdt >= oct1date)           /* recover */
1468 >                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1469 >                                rep, po, opts, zopt, rawfile, oct1name);
1470                  else {
1471                          if (overture) {         /* run overture calculation */
1472                                  sprintf(combuf,
1473                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1474                                                  rep, vw, opts,
1475 <                                                vval(OCTREE), rawfile);
1476 <                                if (!silent) {
1105 <                                        printf("\t%s\n", combuf);
1106 <                                        fflush(stdout);
1107 <                                }
1108 <                                if (!noaction && system(combuf)) {
1475 >                                                oct1name, overfile);
1476 >                                if (runcom(combuf)) {
1477                                          fprintf(stderr,
1478 <                        "%s: error in overture for view %s\n\t%s removed\n",
1479 <                                                progname, vs, rawfile);
1112 <                                        unlink(rawfile);
1478 >                                        "%s: error in overture for view %s\n",
1479 >                                                progname, vs);
1480                                          exit(1);
1481                                  }
1482 + #ifdef NIX
1483 +                                rmfile(overfile);
1484 + #endif
1485                          }
1486 <                        sprintf(combuf, "rpict%s %s %s%s %s > %s",
1487 <                                        rep, vw, res, opts,
1488 <                                        vval(OCTREE), rawfile);
1486 >                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1487 >                                        rep, vw, res, po, opts, zopt,
1488 >                                        oct1name, rawfile);
1489                  }
1490 <                if (!silent) {                  /* echo rpict command */
1121 <                        printf("\t%s\n", combuf);
1122 <                        fflush(stdout);
1123 <                }
1124 <                if (!noaction && system(combuf)) {      /* run rpict */
1490 >                if (runcom(combuf)) {           /* run rpict */
1491                          fprintf(stderr, "%s: error rendering view %s\n",
1492                                          progname, vs);
1493                          exit(1);
1494                  }
1495 +                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1496                                                  /* build pfilt command */
1497 <                if (mult > 1)
1498 <                        sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1497 >                        if (mult > 1)
1498 >                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1499                                          pfopts, mult, mult, rawfile, picfile);
1500 <                else
1501 <                        sprintf(combuf, "pfilt%s %s > %s", pfopts,
1502 <                                        rawfile, picfile);
1503 <                if (!silent) {                  /* echo pfilt command */
1504 <                        printf("\t%s\n", combuf);
1505 <                        fflush(stdout);
1500 >                        else
1501 >                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1502 >                                                rawfile, picfile);
1503 >                        if (runcom(combuf)) {           /* run pfilt */
1504 >                                fprintf(stderr,
1505 >                                "%s: error filtering view %s\n\t%s removed\n",
1506 >                                                progname, vs, picfile);
1507 >                                unlink(picfile);
1508 >                                exit(1);
1509 >                        }
1510                  }
1511 <                if (!noaction && system(combuf)) {      /* run pfilt */
1512 <                        fprintf(stderr,
1513 <                        "%s: error filtering view %s\n\t%s removed\n",
1514 <                                        progname, vs, picfile);
1515 <                        unlink(picfile);
1516 <                        exit(1);
1517 <                }
1518 <                                                /* remove raw file */
1519 <                if (!silent)
1511 >                                                /* remove/rename raw file */
1512 >                if (vdef(RAWFILE)) {
1513 >                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1514 >                        mvfile(rawfile, combuf);
1515 >                } else
1516 >                        rmfile(rawfile);
1517 >        }
1518 > }
1519 >
1520 >
1521 > touch(fn)                       /* update a file */
1522 > char    *fn;
1523 > {
1524 >        if (!silent)
1525 >                printf("\ttouch %s\n", fn);
1526 >        if (noaction)
1527 >                return(0);
1528 > #ifdef notused
1529 >        if (access(fn, F_OK) == -1)             /* create it */
1530 >                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1531 >                        return(-1);
1532 > #endif
1533 >        return(setfdate(fn, time((time_t *)NULL)));
1534 > }
1535 >
1536 >
1537 > runcom(cs)                      /* run command */
1538 > char    *cs;
1539 > {
1540 >        if (!silent)            /* echo it */
1541 >                printf("\t%s\n", cs);
1542 >        if (noaction)
1543 >                return(0);
1544 >        fflush(stdout);         /* flush output and pass to shell */
1545 >        return(system(cs));
1546 > }
1547 >
1548 >
1549 > rmfile(fn)                      /* remove a file */
1550 > char    *fn;
1551 > {
1552 >        if (!silent)
1553   #ifdef MSDOS
1554 <                        printf("\tdel %s\n", rawfile);
1554 >                printf("\tdel %s\n", fn);
1555   #else
1556 <                        printf("\trm %s\n", rawfile);
1556 >                printf("\trm -f %s\n", fn);
1557   #endif
1558 <                if (!noaction)
1559 <                        unlink(rawfile);
1558 >        if (noaction)
1559 >                return(0);
1560 >        return(unlink(fn));
1561 > }
1562 >
1563 >
1564 > mvfile(fold, fnew)              /* move a file */
1565 > char    *fold, *fnew;
1566 > {
1567 >        if (!silent)
1568 > #ifdef MSDOS
1569 >                printf("\trename %s %s\n", fold, fnew);
1570 > #else
1571 >                printf("\tmv %s %s\n", fold, fnew);
1572 > #endif
1573 >        if (noaction)
1574 >                return(0);
1575 >        return(rename(fold, fnew));
1576 > }
1577 >
1578 >
1579 > #ifdef MSDOS
1580 > setenv(vname, value)            /* set an environment variable */
1581 > char    *vname, *value;
1582 > {
1583 >        register char   *evp;
1584 >
1585 >        evp = bmalloc(strlen(vname)+strlen(value)+2);
1586 >        if (evp == NULL)
1587 >                syserr(progname);
1588 >        sprintf(evp, "%s=%s", vname, value);
1589 >        if (putenv(evp) != 0) {
1590 >                fprintf(stderr, "%s: out of environment space\n", progname);
1591 >                exit(1);
1592          }
1593 +        if (!silent)
1594 +                printf("set %s\n", evp);
1595 + }
1596 + #endif
1597 +
1598 +
1599 + badvalue(vc)                    /* report bad variable value and exit */
1600 + int     vc;
1601 + {
1602 +        fprintf(stderr, "%s: bad value for variable '%s'\n",
1603 +                        progname, vnam(vc));
1604 +        exit(1);
1605 + }
1606 +
1607 +
1608 + syserr(s)                       /* report a system error and exit */
1609 + char    *s;
1610 + {
1611 +        perror(s);
1612 +        exit(1);
1613   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines