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.40 by greg, Thu Apr 21 12:22:44 1994 UTC vs.
Revision 2.79 by greg, Mon Oct 4 04:42:33 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1994 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Executive program for oconv, rpict and pfilt
6   */
7  
8   #include "standard.h"
9 < #include "paths.h"
9 >
10   #include <ctype.h>
11 < #include <sys/types.h>
11 > #include <time.h>
12  
13 + #include "platform.h"
14 + #include "rtprocess.h"
15 + #include "view.h"
16 + #include "paths.h"
17 + #include "vars.h"
18  
19 < typedef struct {
20 <        char    *name;          /* variable name */
21 <        short   nick;           /* # characters required for nickname */
22 <        short   nass;           /* # assignments made */
23 <        char    *value;         /* assigned value(s) */
24 <        int     (*fixval)();    /* assignment checking function */
25 < } VARIABLE;
19 > #ifdef _WIN32
20 >  #define DELCMD "del"
21 >  #define RENAMECMD "rename"
22 > #else
23 >  #define DELCMD "rm -f"
24 >  #define RENAMECMD "mv"
25 >  #include <sys/types.h>
26 >  #include <sys/wait.h>
27 > #endif
28  
29 < int     onevalue(), catvalues(), boolvalue(),
30 <        qualvalue(), fltvalue(), intvalue();
31 <
32 <                                /* variables */
33 < #define OBJECT          0               /* object files */
34 < #define SCENE           1               /* scene files */
35 < #define MATERIAL        2               /* material files */
36 < #define ILLUM           3               /* mkillum input files */
37 < #define MKILLUM         4               /* mkillum options */
38 < #define RENDER          5               /* rendering options */
39 < #define OCONV           6               /* oconv options */
40 < #define PFILT           7               /* pfilt options */
41 < #define VIEW            8               /* view(s) for picture(s) */
42 < #define ZONE            9               /* simulation zone */
43 < #define QUALITY         10              /* desired rendering quality */
44 < #define OCTREE          11              /* octree file name */
45 < #define PICTURE         12              /* picture file name */
46 < #define AMBFILE         13              /* ambient file name */
47 < #define OPTFILE         14              /* rendering options file */
48 < #define EXPOSURE        15              /* picture exposure setting */
49 < #define RESOLUTION      16              /* maximum picture resolution */
50 < #define UP              17              /* view up (X, Y or Z) */
51 < #define INDIRECT        18              /* indirection in lighting */
52 < #define DETAIL          19              /* level of scene detail */
53 < #define PENUMBRAS       20              /* shadow penumbras are desired */
54 < #define VARIABILITY     21              /* level of light variability */
55 < #define REPORT          22              /* report frequency and errfile */
29 >                                /* variables (alphabetical by name) */
30 > #define AMBFILE         0               /* ambient file name */
31 > #define DETAIL          1               /* level of scene detail */
32 > #define EXPOSURE        2               /* picture exposure setting */
33 > #define EYESEP          3               /* interocular distance */
34 > #define ILLUM           4               /* mkillum input files */
35 > #define INDIRECT        5               /* indirection in lighting */
36 > #define MATERIAL        6               /* material files */
37 > #define MKILLUM         7               /* mkillum options */
38 > #define OBJECT          8               /* object files */
39 > #define OCONV           9               /* oconv options */
40 > #define OCTREE          10              /* octree file name */
41 > #define OPTFILE         11              /* rendering options file */
42 > #define PENUMBRAS       12              /* shadow penumbras are desired */
43 > #define PFILT           13              /* pfilt options */
44 > #define PICTURE         14              /* picture file root name */
45 > #define QUALITY         15              /* desired rendering quality */
46 > #define RAWFILE         16              /* raw picture file root name */
47 > #define RENDER          17              /* rendering options */
48 > #define REPORT          18              /* report frequency and errfile */
49 > #define RESOLUTION      19              /* maximum picture resolution */
50 > #define SCENE           20              /* scene files */
51 > #define UP              21              /* view up (X, Y or Z) */
52 > #define VARIABILITY     22              /* level of light variability */
53 > #define VIEWS           23              /* view(s) for picture(s) */
54 > #define ZFILE           24              /* distance file root name */
55 > #define ZONE            25              /* simulation zone */
56                                  /* total number of variables */
57 < #define NVARS           23
57 > int NVARS = 26;
58  
59 < VARIABLE        vv[NVARS] = {           /* variable-value pairs */
60 <        {"objects",     3,      0,      NULL,   catvalues},
61 <        {"scene",       3,      0,      NULL,   catvalues},
62 <        {"materials",   3,      0,      NULL,   catvalues},
59 > VARIABLE        vv[] = {                /* variable-value pairs */
60 >        {"AMBFILE",     3,      0,      NULL,   onevalue},
61 >        {"DETAIL",      3,      0,      NULL,   qualvalue},
62 >        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
63 >        {"EYESEP",      3,      0,      NULL,   fltvalue},
64          {"illum",       3,      0,      NULL,   catvalues},
65 +        {"INDIRECT",    3,      0,      NULL,   intvalue},
66 +        {"materials",   3,      0,      NULL,   catvalues},
67          {"mkillum",     3,      0,      NULL,   catvalues},
68 <        {"render",      3,      0,      NULL,   catvalues},
68 >        {"objects",     3,      0,      NULL,   catvalues},
69          {"oconv",       3,      0,      NULL,   catvalues},
63        {"pfilt",       2,      0,      NULL,   catvalues},
64        {"view",        2,      0,      NULL,   NULL},
65        {"ZONE",        2,      0,      NULL,   onevalue},
66        {"QUALITY",     3,      0,      NULL,   qualvalue},
70          {"OCTREE",      3,      0,      NULL,   onevalue},
68        {"PICTURE",     3,      0,      NULL,   onevalue},
69        {"AMBFILE",     3,      0,      NULL,   onevalue},
71          {"OPTFILE",     3,      0,      NULL,   onevalue},
72 <        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
72 >        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
73 >        {"pfilt",       2,      0,      NULL,   catvalues},
74 >        {"PICTURE",     3,      0,      NULL,   onevalue},
75 >        {"QUALITY",     3,      0,      NULL,   qualvalue},
76 >        {"RAWFILE",     3,      0,      NULL,   onevalue},
77 >        {"render",      3,      0,      NULL,   catvalues},
78 >        {"REPORT",      3,      0,      NULL,   onevalue},
79          {"RESOLUTION",  3,      0,      NULL,   onevalue},
80 +        {"scene",       3,      0,      NULL,   catvalues},
81          {"UP",          2,      0,      NULL,   onevalue},
74        {"INDIRECT",    3,      0,      NULL,   intvalue},
75        {"DETAIL",      3,      0,      NULL,   qualvalue},
76        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
82          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
83 <        {"REPORT",      3,      0,      NULL,   onevalue},
83 >        {"view",        2,      0,      NULL,   NULL},
84 >        {"ZFILE",       2,      0,      NULL,   onevalue},
85 >        {"ZONE",        2,      0,      NULL,   onevalue},
86   };
87  
81 VARIABLE        *matchvar();
82 char    *nvalue();
83
84 #define UPPER(c)        ((c)&~0x20)     /* ASCII trick */
85
86 #define vnam(vc)        (vv[vc].name)
87 #define vdef(vc)        (vv[vc].nass)
88 #define vval(vc)        (vv[vc].value)
89 #define vint(vc)        atoi(vval(vc))
90 #define vlet(vc)        UPPER(vval(vc)[0])
91 #define vscale          vlet
92 #define vbool(vc)       (vlet(vc)=='T')
93
94 #define HIGH            'H'
95 #define MEDIUM          'M'
96 #define LOW             'L'
97
88                                  /* overture calculation file */
89 < #ifdef NIX
90 < char    overfile[] = "overture.raw";
89 > #ifdef NULL_DEVICE
90 > char    overfile[] = NULL_DEVICE;
91   #else
92 < char    overfile[] = "/dev/null";
92 > char    overfile[] = "overture.unf";
93   #endif
94  
105 extern time_t   fdate(), time();
95  
96   time_t  scenedate;              /* date of latest scene or object file */
97   time_t  octreedate;             /* date of octree */
# Line 117 | Line 106 | time_t oct1date;               /* date of post-mkillum octree (>= m
106   int     nowarn = 0;             /* no warnings */
107   int     explicate = 0;          /* explicate variables */
108   int     silent = 0;             /* do work silently */
109 < int     noaction = 0;           /* don't do anything */
109 > int     touchonly = 0;          /* touch files only */
110 > int     nprocs = 1;             /* maximum executing processes */
111   int     sayview = 0;            /* print view out */
112 < char    *rvdevice = NULL;       /* rview output device */
112 > char    *rvdevice = NULL;       /* rvu output device */
113   char    *viewselect = NULL;     /* specific view only */
114  
115   int     overture = 0;           /* overture calculation needed */
116  
117 + int     children_running = 0;   /* set negative in children */
118 +
119   char    *progname;              /* global argv[0] */
120   char    *rifname;               /* global rad input file name */
121  
122 < char    radname[MAXPATH];       /* root Radiance file name */
122 > char    radname[PATH_MAX];      /* root Radiance file name */
123  
124 + #define inchild()       (children_running < 0)
125  
126 < main(argc, argv)
127 < int     argc;
128 < char    *argv[];
126 > static void rootname(char       *rn, char       *fn);
127 > static time_t checklast(char    *fnames);
128 > static char * newfname(char     *orig, int      pred);
129 > static void checkfiles(void);
130 > static void getoctcube(double   org[3], double  *sizp);
131 > static void setdefaults(void);
132 > static void oconv(void);
133 > static char * addarg(char       *op, char       *arg);
134 > static void oconvopts(char      *oo);
135 > static void mkillumopts(char    *mo);
136 > static void checkambfile(void);
137 > static double ambval(void);
138 > static void renderopts(char     *op, char       *po);
139 > static void lowqopts(char       *op, char       *po);
140 > static void medqopts(char       *op, char       *po);
141 > static void hiqopts(char        *op, char       *po);
142 > static void xferopts(char       *ro);
143 > static void pfiltopts(char      *po);
144 > static int matchword(char       *s1, char       *s2);
145 > static char * specview(char     *vs);
146 > static char * getview(int       n, char *vn);
147 > static int myprintview(char     *vopts, FILE    *fp);
148 > static void rvu(char    *opts, char     *po);
149 > static void rpict(char  *opts, char     *po);
150 > static int touch(char   *fn);
151 > static int runcom(char  *cs);
152 > static int rmfile(char  *fn);
153 > static int mvfile(char  *fold, char     *fnew);
154 > static int next_process(void);
155 > static void wait_process(int    all);
156 > static void finish_process(void);
157 > static void badvalue(int        vc);
158 > static void syserr(char *s);
159 >
160 >
161 > int
162 > main(
163 >        int     argc,
164 >        char    *argv[]
165 > )
166   {
167          char    ropts[512];
168          char    popts[64];
# Line 146 | Line 176 | char   *argv[];
176                          silent++;
177                          break;
178                  case 'n':
179 <                        noaction++;
179 >                        nprocs = 0;
180                          break;
181 +                case 'N':
182 +                        nprocs = atoi(argv[++i]);
183 +                        if (nprocs < 0)
184 +                                nprocs = 0;
185 +                        break;
186 +                case 't':
187 +                        touchonly++;
188 +                        break;
189                  case 'e':
190                          explicate++;
191                          break;
# Line 169 | Line 207 | char   *argv[];
207          if (i >= argc)
208                  goto userr;
209          rifname = argv[i];
210 +                                /* check command-line options */
211 +        if ((nprocs > 1) & (viewselect != NULL))
212 +                nprocs = 1;
213                                  /* assign Radiance root file name */
214          rootname(radname, rifname);
215                                  /* load variable values */
216 <        load(rifname);
216 >        loadvars(rifname);
217                                  /* get any additional assignments */
218          for (i++; i < argc; i++)
219 <                setvariable(argv[i]);
219 >                if (setvariable(argv[i], matchvar) < 0) {
220 >                        fprintf(stderr, "%s: unknown variable: %s\n",
221 >                                        progname, argv[i]);
222 >                        quit(1);
223 >                }
224                                  /* check assignments */
225          checkvalues();
226                                  /* check files and dates */
# Line 184 | Line 229 | char   *argv[];
229          setdefaults();
230                                  /* print all values if requested */
231          if (explicate)
232 <                printvals();
232 >                printvars(stdout);
233                                  /* build octree (and run mkillum) */
234          oconv();
235                                  /* check date on ambient file */
# Line 193 | Line 238 | char   *argv[];
238          renderopts(ropts, popts);
239          xferopts(ropts);
240          if (rvdevice != NULL)
241 <                rview(ropts, popts);
241 >                rvu(ropts, popts);
242          else
243                  rpict(ropts, popts);
244 <        exit(0);
244 >        quit(0);
245   userr:
246          fprintf(stderr,
247 <        "Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
247 > "Usage: %s [-w][-s][-n|-N npr][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
248                          progname);
249 <        exit(1);
249 >        quit(1);
250 >        return 1; /* pro forma return */
251   }
252  
253  
254 < rootname(rn, fn)                /* remove tail from end of fn */
255 < register char   *rn, *fn;
254 > static void
255 > rootname(               /* remove tail from end of fn */
256 >        register char   *rn,
257 >        register char   *fn
258 > )
259   {
260          char    *tp, *dp;
261  
262 <        for (tp = NULL, dp = rn; *rn = *fn++; rn++)
262 >        for (tp = NULL, dp = rn; (*rn = *fn++); rn++)
263                  if (ISDIRSEP(*rn))
264                          dp = rn;
265                  else if (*rn == '.')
# Line 220 | Line 269 | register char  *rn, *fn;
269   }
270  
271  
272 < #define NOCHAR  127             /* constant for character to delete */
273 <
274 <
275 < load(rfname)                    /* load Radiance simulation file */
227 < char    *rfname;
272 > static time_t
273 > checklast(                      /* check files and find most recent */
274 >        register char   *fnames
275 > )
276   {
277 <        FILE    *fp;
230 <        char    buf[512];
231 <        register char   *cp;
232 <
233 <        if (rfname == NULL)
234 <                fp = stdin;
235 <        else if ((fp = fopen(rfname, "r")) == NULL)
236 <                syserr(rfname);
237 <        while (fgetline(buf, sizeof(buf), fp) != NULL) {
238 <                for (cp = buf; *cp; cp++) {
239 <                        switch (*cp) {
240 <                        case '\\':
241 <                                *cp++ = NOCHAR;
242 <                                continue;
243 <                        case '#':
244 <                                *cp = '\0';
245 <                                break;
246 <                        default:
247 <                                continue;
248 <                        }
249 <                        break;
250 <                }
251 <                setvariable(buf);
252 <        }
253 <        fclose(fp);
254 < }
255 <
256 <
257 < setvariable(ass)                /* assign variable according to string */
258 < register char   *ass;
259 < {
260 <        char    varname[32];
261 <        int     n;
262 <        register char   *cp;
263 <        register VARIABLE       *vp;
264 <        register int    i;
265 <
266 <        while (isspace(*ass))           /* skip leading space */
267 <                ass++;
268 <        cp = varname;                   /* extract name */
269 <        while (cp < varname+sizeof(varname)-1
270 <                        && *ass && !isspace(*ass) && *ass != '=')
271 <                *cp++ = *ass++;
272 <        *cp = '\0';
273 <        if (!varname[0])
274 <                return;         /* no variable name! */
275 <                                        /* trim value */
276 <        while (isspace(*ass) || *ass == '=')
277 <                ass++;
278 <        for (n = strlen(ass); n > 0; n--)
279 <                if (!isspace(ass[n-1]))
280 <                        break;
281 <        if (!n && !nowarn) {
282 <                fprintf(stderr, "%s: warning - missing value for variable '%s'\n",
283 <                                progname, varname);
284 <                return;
285 <        }
286 <                                        /* match variable from list */
287 <        vp = matchvar(varname);
288 <        if (vp == NULL) {
289 <                fprintf(stderr, "%s: unknown variable '%s'\n",
290 <                                progname, varname);
291 <                exit(1);
292 <        }
293 <                                        /* assign new value */
294 <        if (i = vp->nass) {
295 <                cp = vp->value;
296 <                while (i--)
297 <                        while (*cp++)
298 <                                ;
299 <                i = cp - vp->value;
300 <                vp->value = realloc(vp->value, i+n+1);
301 <        } else
302 <                vp->value = malloc(n+1);
303 <        if (vp->value == NULL)
304 <                syserr(progname);
305 <        cp = vp->value+i;               /* copy value, squeezing spaces */
306 <        *cp = *ass;
307 <        for (i = 1; i <= n; i++) {
308 <                if (ass[i] == NOCHAR)
309 <                        continue;
310 <                if (isspace(*cp))
311 <                        while (isspace(ass[i]))
312 <                                i++;
313 <                *++cp = ass[i];
314 <        }
315 <        if (isspace(*cp))               /* remove trailing space */
316 <                *cp = '\0';
317 <        vp->nass++;
318 < }
319 <
320 <
321 < VARIABLE *
322 < matchvar(nam)                   /* match a variable by its name */
323 < char    *nam;
324 < {
325 <        int     n = strlen(nam);
326 <        register int    i;
327 <
328 <        for (i = 0; i < NVARS; i++)
329 <                if (n >= vv[i].nick && !strncmp(nam, vv[i].name, n))
330 <                        return(vv+i);
331 <        return(NULL);
332 < }
333 <
334 <
335 < char *
336 < nvalue(vp, n)                   /* return nth variable value */
337 < VARIABLE        *vp;
338 < register int    n;
339 < {
340 <        register char   *cp;
341 <
342 <        if (vp == NULL | n < 0 | n >= vp->nass)
343 <                return(NULL);
344 <        cp = vp->value;
345 <        while (n--)
346 <                while (*cp++)
347 <                        ;
348 <        return(cp);
349 < }
350 <
351 <
352 < checkvalues()                   /* check assignments */
353 < {
354 <        register int    i;
355 <
356 <        for (i = 0; i < NVARS; i++)
357 <                if (vv[i].fixval != NULL)
358 <                        (*vv[i].fixval)(vv+i);
359 < }
360 <
361 <
362 < onevalue(vp)                    /* only one assignment for this variable */
363 < register VARIABLE       *vp;
364 < {
365 <        if (vp->nass < 2)
366 <                return;
367 <        if (!nowarn)
368 <                fprintf(stderr,
369 <                "%s: warning - multiple assignment of variable '%s'\n",
370 <                        progname, vp->name);
371 <        do
372 <                vp->value += strlen(vp->value)+1;
373 <        while (--vp->nass > 1);
374 < }
375 <
376 <
377 < catvalues(vp)                   /* concatenate variable values */
378 < register VARIABLE       *vp;
379 < {
380 <        register char   *cp;
381 <
382 <        if (vp->nass < 2)
383 <                return;
384 <        for (cp = vp->value; vp->nass > 1; vp->nass--) {
385 <                while (*cp)
386 <                        cp++;
387 <                *cp++ = ' ';
388 <        }
389 < }
390 <
391 <
392 < int
393 < badmatch(tv, cv)                /* case insensitive truncated comparison */
394 < register char   *tv, *cv;
395 < {
396 <        if (!*tv) return(1);            /* null string cannot match */
397 <        do
398 <                if (UPPER(*tv) != *cv++)
399 <                        return(1);
400 <        while (*++tv);
401 <        return(0);              /* OK */
402 < }
403 <
404 <
405 < boolvalue(vp)                   /* check boolean for legal values */
406 < register VARIABLE       *vp;
407 < {
408 <        if (!vp->nass) return;
409 <        onevalue(vp);
410 <        switch (UPPER(vp->value[0])) {
411 <        case 'T':
412 <                if (badmatch(vp->value, "TRUE")) break;
413 <                return;
414 <        case 'F':
415 <                if (badmatch(vp->value, "FALSE")) break;
416 <                return;
417 <        }
418 <        fprintf(stderr, "%s: illegal value for boolean variable '%s'\n",
419 <                        progname, vp->name);
420 <        exit(1);
421 < }
422 <
423 <
424 < qualvalue(vp)                   /* check qualitative var. for legal values */
425 < register VARIABLE       *vp;
426 < {
427 <        if (!vp->nass) return;
428 <        onevalue(vp);
429 <        switch (UPPER(vp->value[0])) {
430 <        case 'L':
431 <                if (badmatch(vp->value, "LOW")) break;
432 <                return;
433 <        case 'M':
434 <                if (badmatch(vp->value, "MEDIUM")) break;
435 <                return;
436 <        case 'H':
437 <                if (badmatch(vp->value, "HIGH")) break;
438 <                return;
439 <        }
440 <        fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n",
441 <                        progname, vp->name);
442 <        exit(1);
443 < }
444 <
445 <
446 < intvalue(vp)                    /* check integer variable for legal values */
447 < register VARIABLE       *vp;
448 < {
449 <        if (!vp->nass) return;
450 <        onevalue(vp);
451 <        if (isint(vp->value)) return;
452 <        fprintf(stderr, "%s: illegal value for integer variable '%s'\n",
453 <                        progname, vp->name);
454 <        exit(1);
455 < }
456 <
457 <
458 < fltvalue(vp)                    /* check float variable for legal values */
459 < register VARIABLE       *vp;
460 < {
461 <        if (!vp->nass) return;
462 <        onevalue(vp);
463 <        if (isflt(vp->value)) return;
464 <        fprintf(stderr, "%s: illegal value for real variable '%s'\n",
465 <                        progname, vp->name);
466 <        exit(1);
467 < }
468 <
469 <
470 < time_t
471 < checklast(fnames)                       /* check files and find most recent */
472 < register char   *fnames;
473 < {
474 <        char    thisfile[MAXPATH];
277 >        char    thisfile[PATH_MAX];
278          time_t  thisdate, lastdate = 0;
476        register char   *cp;
279  
280          if (fnames == NULL)
281                  return(0);
282 <        while (*fnames) {
283 <                while (isspace(*fnames)) fnames++;
284 <                cp = thisfile;
285 <                while (*fnames && !isspace(*fnames))
286 <                        *cp++ = *fnames++;
287 <                *cp = '\0';
282 >        while ((fnames = nextword(thisfile, PATH_MAX, fnames)) != NULL) {
283 >                if (thisfile[0] == '!' ||
284 >                                (thisfile[0] == '\\' && thisfile[1] == '!')) {
285 >                        if (!lastdate)
286 >                                lastdate = 1;
287 >                        continue;
288 >                }
289                  if (!(thisdate = fdate(thisfile)))
290                          syserr(thisfile);
291                  if (thisdate > lastdate)
# Line 492 | Line 295 | register char  *fnames;
295   }
296  
297  
298 < char *
299 < newfname(orig, pred)            /* create modified file name */
300 < char    *orig;
301 < int     pred;
298 > static char *
299 > newfname(               /* create modified file name */
300 >        char    *orig,
301 >        int     pred
302 > )
303   {
500        extern char     *rindex();
304          register char   *cp;
305          register int    n;
306          int     suffix;
# Line 518 | Line 321 | int    pred;
321   }
322  
323  
324 < checkfiles()                    /* check for existence and modified times */
324 > static void
325 > checkfiles(void)                        /* check for existence and modified times */
326   {
327          time_t  objdate;
328  
# Line 527 | Line 331 | checkfiles()                   /* check for existence and modified tim
331                          syserr(progname);
332                  sprintf(vval(OCTREE), "%s.oct", radname);
333                  vdef(OCTREE)++;
334 +        } else if (vval(OCTREE)[0] == '!') {
335 +                fprintf(stderr, "%s: illegal '%s' specification\n",
336 +                                progname, vnam(OCTREE));
337 +                quit(1);
338          }
339          octreedate = fdate(vval(OCTREE));
340          if (vdef(ILLUM)) {              /* illum requires secondary octrees */
# Line 543 | Line 351 | checkfiles()                   /* check for existence and modified tim
351          if (!octreedate & !scenedate & !illumdate) {
352                  fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname,
353                                  vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
354 <                exit(1);
354 >                quit(1);
355          }
356          matdate = checklast(vval(MATERIAL));
357   }      
358  
359  
360 < getoctcube(org, sizp)           /* get octree bounding cube */
361 < double  org[3], *sizp;
360 > static void
361 > getoctcube(             /* get octree bounding cube */
362 >        double  org[3],
363 >        double  *sizp
364 > )
365   {
555        extern FILE     *popen();
366          static double   oorg[3], osiz = 0.;
367          double  min[3], max[3];
368 <        char    buf[512];
368 >        char    buf[1024];
369          FILE    *fp;
370          register int    i;
371  
372 <        if (osiz <= FTINY)
373 <                if (noaction && fdate(oct1name) <
372 >        if (osiz <= FTINY) {
373 >                if (!nprocs && fdate(oct1name) <
374                                  (scenedate>illumdate?scenedate:illumdate)) {
375                                                          /* run getbbox */
376                          sprintf(buf, "getbbox -w -h %s",
# Line 573 | Line 383 | double org[3], *sizp;
383                                  fprintf(stderr,
384                          "%s: error reading bounding box from getbbox\n",
385                                                  progname);
386 <                                exit(1);
386 >                                quit(1);
387                          }
388                          for (i = 0; i < 3; i++)
389                                  if (max[i] - min[i] > osiz)
# Line 591 | Line 401 | double org[3], *sizp;
401                                  fprintf(stderr,
402                          "%s: error reading bounding cube from getinfo\n",
403                                                  progname);
404 <                                exit(1);
404 >                                quit(1);
405                          }
406                          pclose(fp);
407                  }
408 +        }
409          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
410   }
411  
412  
413 < setdefaults()                   /* set default values for unassigned var's */
413 > static void
414 > setdefaults(void)                       /* set default values for unassigned var's */
415   {
416 <        double  org[3], size;
416 >        double  org[3], lim[3], size;
417          char    buf[128];
418  
419          if (!vdef(ZONE)) {
# Line 611 | Line 423 | setdefaults()                  /* set default values for unassigned v
423                  vval(ZONE) = savqstr(buf);
424                  vdef(ZONE)++;
425          }
426 +        if (!vdef(EYESEP)) {
427 +                if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf",
428 +                                &org[0], &lim[0], &org[1], &lim[1],
429 +                                &org[2], &lim[2]) != 6)
430 +                        badvalue(ZONE);
431 +                sprintf(buf, "%f",
432 +                        0.01*(lim[0]-org[0]+lim[1]-org[1]+lim[2]-org[2]));
433 +                vval(EYESEP) = savqstr(buf);
434 +                vdef(EYESEP)++;
435 +        }
436          if (!vdef(INDIRECT)) {
437                  vval(INDIRECT) = "0";
438                  vdef(INDIRECT)++;
# Line 627 | Line 449 | setdefaults()                  /* set default values for unassigned v
449                  vval(PICTURE) = radname;
450                  vdef(PICTURE)++;
451          }
452 <        if (!vdef(VIEW)) {
453 <                vval(VIEW) = "X";
454 <                vdef(VIEW)++;
452 >        if (!vdef(VIEWS)) {
453 >                vval(VIEWS) = "X";
454 >                vdef(VIEWS)++;
455          }
456          if (!vdef(DETAIL)) {
457                  vval(DETAIL) = "M";
# Line 646 | Line 468 | setdefaults()                  /* set default values for unassigned v
468   }
469  
470  
471 < printvals()                     /* print variable values */
471 > static void
472 > oconv(void)                             /* run oconv and mkillum if necessary */
473   {
651        int     i, j, clipline;
652        register char   *cp;
653        register int    k;
654
655        for (i = 0; i < NVARS; i++)             /* print each variable */
656            for (j = 0; j < vdef(i); j++) {     /* print each assignment */
657                fputs(vnam(i), stdout);
658                fputs("= ", stdout);
659                k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 )
660                                - strlen(vnam(i)) ;
661                cp = nvalue(vv+i, j);
662                while (*cp) {
663                    putchar(*cp++);
664                    if (--k <= 0) {             /* line too long */
665                        while (*cp && !isspace(*cp))
666                            putchar(*cp++);     /* finish this word */
667                        if (*cp) {              /* start new line */
668                            putchar('\n');
669                            fputs(vnam(i), stdout);
670                            putchar('=');
671                            k = clipline;
672                        }
673                    }
674                }
675                putchar('\n');
676            }
677        fflush(stdout);
678 }
679
680
681 oconv()                         /* run oconv and mkillum if necessary */
682 {
474          static char     illumtmp[] = "ilXXXXXX";
475 <        char    combuf[512], ocopts[64], mkopts[64];
475 >        char    combuf[PATH_MAX], ocopts[64], mkopts[1024];
476  
477          oconvopts(ocopts);              /* get options */
478          if (octreedate < scenedate) {   /* check date on original octree */
479 <                                                /* build command */
480 <                if (vdef(MATERIAL))
481 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
482 <                                vval(MATERIAL), vval(SCENE), vval(OCTREE));
483 <                else
484 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
485 <                                        vval(SCENE), vval(OCTREE));
486 <                
487 <                if (runcom(combuf)) {           /* run it */
488 <                        fprintf(stderr,
479 >                if (touchonly && octreedate)
480 >                        touch(vval(OCTREE));
481 >                else {                          /* build command */
482 >                        if (vdef(MATERIAL))
483 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
484 >                                                vval(MATERIAL), vval(SCENE),
485 >                                                vval(OCTREE));
486 >                        else
487 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
488 >                                                vval(SCENE), vval(OCTREE));
489 >                        
490 >                        if (runcom(combuf)) {           /* run it */
491 >                                fprintf(stderr,
492                                  "%s: error generating octree\n\t%s removed\n",
493 <                                        progname, vval(OCTREE));
494 <                        unlink(vval(OCTREE));
495 <                        exit(1);
493 >                                                progname, vval(OCTREE));
494 >                                unlink(vval(OCTREE));
495 >                                quit(1);
496 >                        }
497                  }
498                  octreedate = time((time_t *)NULL);
499                  if (octreedate < scenedate)     /* in case clock is off */
# Line 706 | Line 501 | oconv()                                /* run oconv and mkillum if necessary */
501          }
502          if (oct1name == vval(OCTREE))           /* no mkillum? */
503                  oct1date = octreedate > matdate ? octreedate : matdate;
504 <        if (oct1date >= octreedate & oct1date >= matdate
505 <                        & oct1date >= illumdate)        /* all done */
504 >        if ((oct1date >= octreedate) & (oct1date >= matdate)
505 >                        & (oct1date >= illumdate))      /* all done */
506                  return;
507                                                  /* make octree0 */
508 <        if (oct0date < scenedate | oct0date < illumdate) {
509 <                                                /* build command */
510 <                if (octreedate)
511 <                        sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
512 <                                vval(OCTREE), vval(ILLUM), oct0name);
513 <                else if (vdef(MATERIAL))
514 <                        sprintf(combuf, "oconv%s %s %s > %s", ocopts,
515 <                                vval(MATERIAL), vval(ILLUM), oct0name);
516 <                else
517 <                        sprintf(combuf, "oconv%s %s > %s", ocopts,
518 <                                vval(ILLUM), oct0name);
519 <                if (runcom(combuf)) {           /* run it */
520 <                        fprintf(stderr,
508 >        if ((oct0date < scenedate) | (oct0date < illumdate)) {
509 >                if (touchonly && oct0date)
510 >                        touch(oct0name);
511 >                else {                          /* build command */
512 >                        if (octreedate)
513 >                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
514 >                                        vval(OCTREE), vval(ILLUM), oct0name);
515 >                        else if (vdef(MATERIAL))
516 >                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
517 >                                        vval(MATERIAL), vval(ILLUM), oct0name);
518 >                        else
519 >                                sprintf(combuf, "oconv%s %s > %s", ocopts,
520 >                                        vval(ILLUM), oct0name);
521 >                        if (runcom(combuf)) {           /* run it */
522 >                                fprintf(stderr,
523                                  "%s: error generating octree\n\t%s removed\n",
524 <                                        progname, oct0name);
525 <                        unlink(oct0name);
526 <                        exit(1);
524 >                                                progname, oct0name);
525 >                                unlink(oct0name);
526 >                                quit(1);
527 >                        }
528                  }
529                  oct0date = time((time_t *)NULL);
530                  if (oct0date < octreedate)      /* in case clock is off */
531                          oct0date = octreedate;
532                  if (oct0date < illumdate)       /* ditto */
533                          oct0date = illumdate;
534 <        }
535 <        mkillumopts(mkopts);                    /* build mkillum command */
536 <        mktemp(illumtmp);
537 <        sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
538 <                        oct0name, vval(ILLUM), illumtmp);
539 <        if (runcom(combuf)) {                   /* run it */
540 <                fprintf(stderr, "%s: error running mkillum\n", progname);
541 <                unlink(illumtmp);
542 <                exit(1);
543 <        }
534 >                }
535 >        if (touchonly && oct1date)
536 >                touch(oct1name);
537 >        else {
538 >                mkillumopts(mkopts);            /* build mkillum command */
539 >                mktemp(illumtmp);
540 >                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
541 >                                oct0name, vval(ILLUM), illumtmp);
542 >                if (runcom(combuf)) {                   /* run it */
543 >                        fprintf(stderr, "%s: error running mkillum\n",
544 >                                        progname);
545 >                        unlink(illumtmp);
546 >                        quit(1);
547 >                }
548                                                  /* make octree1 (frozen) */
549 <        if (octreedate)
550 <                sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
551 <                        vval(OCTREE), illumtmp, oct1name);
552 <        else if (vdef(MATERIAL))
553 <                sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
554 <                        vval(MATERIAL), illumtmp, oct1name);
555 <        else
556 <                sprintf(combuf, "oconv%s -f %s > %s", ocopts,
557 <                        illumtmp, oct1name);
558 <        if (runcom(combuf)) {           /* run it */
559 <                fprintf(stderr,
560 <                        "%s: error generating octree\n\t%s removed\n",
561 <                                progname, oct1name);
562 <                unlink(oct1name);
563 <                exit(1);
549 >                if (octreedate)
550 >                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
551 >                                vval(OCTREE), illumtmp, oct1name);
552 >                else if (vdef(MATERIAL))
553 >                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
554 >                                vval(MATERIAL), illumtmp, oct1name);
555 >                else
556 >                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
557 >                                illumtmp, oct1name);
558 >                if (runcom(combuf)) {           /* run it */
559 >                        fprintf(stderr,
560 >                                "%s: error generating octree\n\t%s removed\n",
561 >                                        progname, oct1name);
562 >                        unlink(oct1name);
563 >                        unlink(illumtmp);
564 >                        quit(1);
565 >                }
566 >                rmfile(illumtmp);
567          }
568          oct1date = time((time_t *)NULL);
569          if (oct1date < oct0date)        /* in case clock is off */
570                  oct1date = oct0date;
766        rmfile(illumtmp);
571   }
572  
573  
574 < char *
575 < addarg(op, arg)                         /* add argument and advance pointer */
576 < register char   *op, *arg;
574 > static char *
575 > addarg(                         /* add argument and advance pointer */
576 > register char   *op,
577 > register char   *arg
578 > )
579   {
580          *op = ' ';
581 <        while (*++op = *arg++)
581 >        while ( (*++op = *arg++) )
582                  ;
583          return(op);
584   }
585  
586  
587 < oconvopts(oo)                           /* get oconv options */
588 < register char   *oo;
587 > static void
588 > oconvopts(                              /* get oconv options */
589 >        register char   *oo
590 > )
591   {
592          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
593  
# Line 789 | Line 597 | register char  *oo;
597   }
598  
599  
600 < mkillumopts(mo)                         /* get mkillum options */
601 < register char   *mo;
600 > static void
601 > mkillumopts(                            /* get mkillum options */
602 >        char    *mo
603 > )
604   {
605          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
606  
607 <        *mo = '\0';
607 >        if (nprocs > 1) {
608 >                sprintf(mo, " -n %d", nprocs);
609 >                while (*mo)
610 >                        mo++;
611 >        } else
612 >                *mo = '\0';
613          if (vdef(MKILLUM))
614                  addarg(mo, vval(MKILLUM));
615   }
616  
617  
618 < checkambfile()                  /* check date on ambient file */
618 > static void
619 > checkambfile(void)                      /* check date on ambient file */
620   {
621          time_t  afdate;
622  
# Line 808 | Line 624 | checkambfile()                 /* check date on ambient file */
624                  return;
625          if (!(afdate = fdate(vval(AMBFILE))))
626                  return;
627 <        if (oct1date > afdate)
628 <                rmfile(vval(AMBFILE));
627 >        if (oct1date > afdate) {
628 >                if (touchonly)
629 >                        touch(vval(AMBFILE));
630 >                else
631 >                        rmfile(vval(AMBFILE));
632 >        }
633   }
634  
635  
636 < double
637 < ambval()                                /* compute ambient value */
636 > static double
637 > ambval(void)                            /* compute ambient value */
638   {
639          if (vdef(EXPOSURE)) {
640                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
641 <                        return(.5/pow(2.,atof(vval(EXPOSURE))));
642 <                return(.5/atof(vval(EXPOSURE)));
641 >                        return(.5/pow(2.,vflt(EXPOSURE)));
642 >                return(.5/vflt(EXPOSURE));
643          }
644          if (vlet(ZONE) == 'E')
645                  return(10.);
646          if (vlet(ZONE) == 'I')
647                  return(.01);
648          badvalue(ZONE);
649 +        return 0; /* pro forma return */
650   }
651  
652  
653 < renderopts(op, po)                      /* set rendering options */
654 < char    *op, *po;
653 > static void
654 > renderopts(                     /* set rendering options */
655 >        char    *op,
656 >        char    *po
657 > )
658   {
659          switch(vscale(QUALITY)) {
660          case LOW:
# Line 846 | Line 670 | char   *op, *po;
670   }
671  
672  
673 < lowqopts(op, po)                        /* low quality rendering options */
674 < register char   *op;
675 < char    *po;
673 > static void
674 > lowqopts(                       /* low quality rendering options */
675 >        register char   *op,
676 >        char    *po
677 > )
678   {
679          double  d, org[3], siz[3];
680  
# Line 858 | Line 684 | char   *po;
684                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
685                  badvalue(ZONE);
686          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
687 <        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
687 >        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY))
688                  badvalue(ZONE);
689          getoctcube(org, &d);
690          d *= 3./(siz[0]+siz[1]+siz[2]);
# Line 866 | Line 692 | char   *po;
692          case LOW:
693                  po = addarg(po, "-ps 16");
694                  op = addarg(op, "-dp 64");
695 <                sprintf(op, " -ar %d", (int)(4*d));
695 >                sprintf(op, " -ar %d", (int)(8*d));
696                  op += strlen(op);
697                  break;
698          case MEDIUM:
699                  po = addarg(po, "-ps 8");
700                  op = addarg(op, "-dp 128");
701 <                sprintf(op, " -ar %d", (int)(8*d));
701 >                sprintf(op, " -ar %d", (int)(16*d));
702                  op += strlen(op);
703                  break;
704          case HIGH:
705                  po = addarg(po, "-ps 4");
706                  op = addarg(op, "-dp 256");
707 <                sprintf(op, " -ar %d", (int)(16*d));
707 >                sprintf(op, " -ar %d", (int)(32*d));
708                  op += strlen(op);
709                  break;
710          }
# Line 895 | Line 721 | char   *po;
721                  overture = 0;
722          switch (vscale(VARIABILITY)) {
723          case LOW:
724 <                op = addarg(op, "-aa .4 -ad 64");
724 >                op = addarg(op, "-aa .3 -ad 256");
725                  break;
726          case MEDIUM:
727 <                op = addarg(op, "-aa .3 -ad 128");
727 >                op = addarg(op, "-aa .25 -ad 512");
728                  break;
729          case HIGH:
730 <                op = addarg(op, "-aa .25 -ad 256");
730 >                op = addarg(op, "-aa .2 -ad 1024");
731                  break;
732          }
733          op = addarg(op, "-as 0");
734          d = ambval();
735          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
736          op += strlen(op);
737 <        op = addarg(op, "-lr 3 -lw .02");
737 >        op = addarg(op, "-lr 6 -lw .01");
738          if (vdef(RENDER))
739                  op = addarg(op, vval(RENDER));
740   }
741  
742  
743 < medqopts(op, po)                        /* medium quality rendering options */
744 < register char   *op;
745 < char    *po;
743 > static void
744 > medqopts(                       /* medium quality rendering options */
745 >        register char   *op,
746 >        char    *po
747 > )
748   {
749 <        double  d, org[3], siz[3];
749 >        double  d, org[3], siz[3], asz;
750  
751          *op = '\0';
752          *po = '\0';
# Line 926 | Line 754 | char   *po;
754                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
755                  badvalue(ZONE);
756          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
757 <        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
757 >        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY))
758                  badvalue(ZONE);
759          getoctcube(org, &d);
760 <        d *= 3./(siz[0]+siz[1]+siz[2]);
760 >        asz = (siz[0]+siz[1]+siz[2])/3.;
761 >        d /= asz;
762          switch (vscale(DETAIL)) {
763          case LOW:
764                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
765                  op = addarg(op, "-dp 256");
766 <                sprintf(op, " -ar %d", (int)(8*d));
766 >                sprintf(op, " -ar %d", (int)(16*d));
767                  op += strlen(op);
768 +                sprintf(op, " -ms %.2g", asz/20.);
769 +                op += strlen(op);
770                  break;
771          case MEDIUM:
772                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
773                  op = addarg(op, "-dp 512");
774 <                sprintf(op, " -ar %d", (int)(16*d));
774 >                sprintf(op, " -ar %d", (int)(32*d));
775                  op += strlen(op);
776 +                sprintf(op, " -ms %.2g", asz/40.);
777 +                op += strlen(op);
778                  break;
779          case HIGH:
780                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
781                  op = addarg(op, "-dp 1024");
782 <                sprintf(op, " -ar %d", (int)(32*d));
782 >                sprintf(op, " -ar %d", (int)(64*d));
783                  op += strlen(op);
784 +                sprintf(op, " -ms %.2g", asz/80.);
785 +                op += strlen(op);
786                  break;
787          }
788          po = addarg(po, "-pt .08");
# Line 956 | Line 791 | char   *po;
791          else
792                  op = addarg(op, "-ds .3");
793          op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
794 <        if (overture = vint(INDIRECT)) {
794 >        if ( (overture = vint(INDIRECT)) ) {
795                  sprintf(op, " -ab %d", overture);
796                  op += strlen(op);
797          }
# Line 967 | Line 802 | char   *po;
802                  overture = 0;
803          switch (vscale(VARIABILITY)) {
804          case LOW:
805 <                op = addarg(op, "-aa .25 -ad 196 -as 0");
805 >                op = addarg(op, "-aa .2 -ad 329 -as 42");
806                  break;
807          case MEDIUM:
808 <                op = addarg(op, "-aa .2 -ad 400 -as 64");
808 >                op = addarg(op, "-aa .15 -ad 800 -as 128");
809                  break;
810          case HIGH:
811 <                op = addarg(op, "-aa .15 -ad 768 -as 196");
811 >                op = addarg(op, "-aa .1 -ad 1536 -as 392");
812                  break;
813          }
814          d = ambval();
815          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
816          op += strlen(op);
817 <        op = addarg(op, "-lr 6 -lw .002");
817 >        op = addarg(op, "-lr 8 -lw .002");
818          if (vdef(RENDER))
819                  op = addarg(op, vval(RENDER));
820   }
821  
822  
823 < hiqopts(op, po)                         /* high quality rendering options */
824 < register char   *op;
825 < char    *po;
823 > static void
824 > hiqopts(                                /* high quality rendering options */
825 >        register char   *op,
826 >        char    *po
827 > )
828   {
829 <        double  d, org[3], siz[3];
829 >        double  d, org[3], siz[3], asz;
830  
831          *op = '\0';
832          *po = '\0';
# Line 997 | Line 834 | char   *po;
834                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
835                  badvalue(ZONE);
836          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
837 <        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
837 >        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY))
838                  badvalue(ZONE);
839          getoctcube(org, &d);
840 <        d *= 3./(siz[0]+siz[1]+siz[2]);
840 >        asz = (siz[0]+siz[1]+siz[2])/3.;
841 >        d /= asz;
842          switch (vscale(DETAIL)) {
843          case LOW:
844                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
845                  op = addarg(op, "-dp 1024");
846 <                sprintf(op, " -ar %d", (int)(16*d));
846 >                sprintf(op, " -ar %d", (int)(32*d));
847                  op += strlen(op);
848 +                sprintf(op, " -ms %.2g", asz/40.);
849 +                op += strlen(op);
850                  break;
851          case MEDIUM:
852                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
853                  op = addarg(op, "-dp 2048");
854 <                sprintf(op, " -ar %d", (int)(32*d));
854 >                sprintf(op, " -ar %d", (int)(64*d));
855                  op += strlen(op);
856 +                sprintf(op, " -ms %.2g", asz/80.);
857 +                op += strlen(op);
858                  break;
859          case HIGH:
860                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
861                  op = addarg(op, "-dp 4096");
862 <                sprintf(op, " -ar %d", (int)(64*d));
862 >                sprintf(op, " -ar %d", (int)(128*d));
863                  op += strlen(op);
864 +                sprintf(op, " -ms %.2g", asz/160.);
865 +                op += strlen(op);
866                  break;
867          }
868          po = addarg(po, "-pt .04");
869          if (vbool(PENUMBRAS))
870 <                op = addarg(op, "-ds .1 -dj .7");
870 >                op = addarg(op, "-ds .1 -dj .65");
871          else
872                  op = addarg(op, "-ds .2");
873          op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
# Line 1036 | Line 880 | char   *po;
880                  overture = 0;
881          switch (vscale(VARIABILITY)) {
882          case LOW:
883 <                op = addarg(op, "-aa .15 -ad 256 -as 0");
883 >                op = addarg(op, "-aa .125 -ad 512 -as 64");
884                  break;
885          case MEDIUM:
886 <                op = addarg(op, "-aa .125 -ad 512 -as 256");
886 >                op = addarg(op, "-aa .1 -ad 1536 -as 768");
887                  break;
888          case HIGH:
889 <                op = addarg(op, "-aa .08 -ad 1024 -as 512");
889 >                op = addarg(op, "-aa .075 -ad 4096 -as 2048");
890                  break;
891          }
892          d = ambval();
# Line 1054 | Line 898 | char   *po;
898   }
899  
900  
901 < xferopts(ro)                            /* transfer options if indicated */
902 < char    *ro;
901 > static void
902 > xferopts(                               /* transfer options if indicated */
903 >        char    *ro
904 > )
905   {
906          int     fd, n;
907          register char   *cp;
# Line 1065 | Line 911 | char   *ro;
911                  return;
912          if (vdef(OPTFILE)) {
913                  for (cp = ro; cp[1]; cp++)
914 <                        if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3]))
914 >                        if (isspace(cp[1]) && (cp[2] == '@' ||
915 >                                        (cp[2] == '-' && isalpha(cp[3]))))
916                                  *cp = '\n';
917                          else
918                                  *cp = cp[1];
# Line 1075 | Line 922 | char   *ro;
922                          syserr(vval(OPTFILE));
923                  sprintf(ro, " @%s", vval(OPTFILE));
924          }
925 < #ifdef MSDOS
925 > #ifdef _WIN32
926          else if (n > 50) {
927                  setenv("ROPT", ro+1);
928                  strcpy(ro, " $ROPT");
# Line 1084 | Line 931 | char   *ro;
931   }
932  
933  
934 < pfiltopts(po)                           /* get pfilt options */
935 < register char   *po;
934 > static void
935 > pfiltopts(                              /* get pfilt options */
936 >        register char   *po
937 > )
938   {
939          *po = '\0';
940          if (vdef(EXPOSURE)) {
# Line 1094 | Line 943 | register char  *po;
943          }
944          switch (vscale(QUALITY)) {
945          case MEDIUM:
946 <                po = addarg(po, "-r 1");
946 >                po = addarg(po, "-r .6");
947                  break;
948          case HIGH:
949                  po = addarg(po, "-m .25");
# Line 1105 | Line 954 | register char  *po;
954   }
955  
956  
957 < matchword(s1, s2)                       /* match white-delimited words */
958 < register char   *s1, *s2;
957 > static int
958 > matchword(                      /* match white-delimited words */
959 >        register char   *s1,
960 >        register char   *s2
961 > )
962   {
963          while (isspace(*s1)) s1++;
964          while (isspace(*s2)) s2++;
# Line 1117 | Line 969 | register char  *s1, *s2;
969   }
970  
971  
972 < char *
973 < specview(vs)                            /* get proper view spec from vs */
974 < register char   *vs;
972 > static char *
973 > specview(                               /* get proper view spec from vs */
974 >        register char   *vs
975 > )
976   {
977          static char     vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0",
978                          "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"};
# Line 1137 | Line 990 | register char  *vs;
990                          upax = 1-'X'+UPPER(vval(UP)[1]);
991                  else
992                          upax = 1-'X'+vlet(UP);
993 <                if (upax < 1 | upax > 3)
993 >                if ((upax < 1) | (upax > 3))
994                          badvalue(UP);
995                  if (vval(UP)[0] == '-')
996                          upax = -upax;
# Line 1160 | Line 1013 | register char  *vs;
1013                  zpos = -1; vs++;
1014          }
1015          viewtype = 'v';
1016 <        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h')
1016 >        if((*vs == 'v') | (*vs == 'l') | (*vs == 'a') | (*vs == 'h') | (*vs == 'c'))
1017                  viewtype = *vs++;
1018          cp = viewopts;
1019          if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
# Line 1215 | Line 1068 | register char  *vs;
1068                  case 'h':
1069                          cp = addarg(cp, "-vh 180 -vv 180");
1070                          break;
1071 +                case 'c':
1072 +                        cp = addarg(cp, "-vh 180 -vv 90");
1073 +                        break;
1074                  }
1075          } else {
1076                  while (!isspace(*vs))           /* else skip id */
# Line 1228 | Line 1084 | register char  *vs;
1084          if (cp == viewopts)             /* append any additional options */
1085                  vs++;           /* skip prefixed space if unneeded */
1086          strcpy(cp, vs);
1087 < #ifdef MSDOS
1087 > #ifdef _WIN32
1088          if (strlen(viewopts) > 40) {
1089                  setenv("VIEW", viewopts);
1090                  return("$VIEW");
# Line 1238 | Line 1094 | register char  *vs;
1094   }
1095  
1096  
1097 < char *
1098 < getview(n, vn)                          /* get view n, or NULL if none */
1099 < int     n;
1100 < char    *vn;            /* returned view name */
1097 > static char *
1098 > getview(                                /* get view n, or NULL if none */
1099 >        int     n,
1100 >        char    *vn             /* returned view name */
1101 > )
1102   {
1103          register char   *mv;
1104  
# Line 1260 | Line 1117 | char   *vn;            /* returned view name */
1117                  }
1118                                                  /* view number? */
1119                  if (isint(viewselect))
1120 <                        return(specview(nvalue(vv+VIEW, atoi(viewselect)-1)));
1120 >                        return(specview(nvalue(VIEWS, atoi(viewselect)-1)));
1121                                                  /* check list */
1122 <                while ((mv = nvalue(vv+VIEW, n++)) != NULL)
1122 >                while ((mv = nvalue(VIEWS, n++)) != NULL)
1123                          if (matchword(viewselect, mv))
1124                                  return(specview(mv));
1125                  return(specview(viewselect));   /* standard view? */
1126          }
1127 <        mv = nvalue(vv+VIEW, n);                /* use view n */
1128 <        if (vn != NULL & mv != NULL) {
1127 >        mv = nvalue(VIEWS, n);          /* use view n */
1128 >        if ((vn != NULL) & (mv != NULL)) {
1129                  register char   *mv2 = mv;
1130                  if (*mv2 != '-')
1131                          while (*mv2 && !isspace(*mv2))
# Line 1279 | Line 1136 | char   *vn;            /* returned view name */
1136   }
1137  
1138  
1139 < printview(vopts)                        /* print out selected view */
1140 < register char   *vopts;
1139 > static int
1140 > myprintview(                    /* print out selected view */
1141 >        register char   *vopts,
1142 >        FILE    *fp
1143 > )
1144   {
1145 <        extern char     *atos(), *getenv();
1146 <        char    buf[256];
1287 <        FILE    *fp;
1145 >        VIEW    vwr;
1146 >        char    buf[128];
1147          register char   *cp;
1289
1148          if (vopts == NULL)
1149                  return(-1);
1150 <        fputs("VIEW=", stdout);
1151 <        do {
1152 <                if (matchword(vopts, "-vf")) {          /* expand view file */
1153 <                        vopts = sskip(vopts);
1154 <                        if (!*atos(buf, sizeof(buf), vopts))
1297 <                                return(-1);
1298 <                        if ((fp = fopen(buf, "r")) == NULL)
1299 <                                return(-1);
1300 <                        for (buf[sizeof(buf)-2] = '\n';
1301 <                                        fgets(buf, sizeof(buf), fp) != NULL &&
1302 <                                                buf[0] != '\n';
1303 <                                        buf[sizeof(buf)-2] = '\n') {
1304 <                                if (buf[sizeof(buf)-2] != '\n') {
1305 <                                        ungetc(buf[sizeof(buf)-2], fp);
1306 <                                        buf[sizeof(buf)-2] = '\0';
1307 <                                }
1308 <                                if (matchword(buf, "VIEW=") ||
1309 <                                                matchword(buf, "rview")) {
1310 <                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1311 <                                                putchar(*cp);
1312 <                                }
1313 <                        }
1314 <                        fclose(fp);
1315 <                        vopts = sskip(vopts);
1316 <                } else {
1317 <                        while (isspace(*vopts))
1318 <                                vopts++;
1319 <                        putchar(' ');
1320 < #ifdef MSDOS
1321 <                        if (*vopts == '$') {            /* expand env. var. */
1322 <                                if (!*atos(buf, sizeof(buf), vopts+1))
1323 <                                        return(-1);
1324 <                                if ((cp = getenv(buf)) == NULL)
1325 <                                        return(-1);
1326 <                                fputs(cp, stdout);
1327 <                                vopts = sskip(vopts);
1328 <                        } else
1150 > #ifdef _WIN32
1151 >        if (vopts[0] == '$') {
1152 >                vopts = getenv(vopts+1);
1153 >                goto again;
1154 >        }
1155   #endif
1156 <                                while (*vopts && !isspace(*vopts))
1157 <                                        putchar(*vopts++);
1158 <                }
1159 <        } while (*vopts++);
1160 <        putchar('\n');
1156 >        vwr = stdview;
1157 >        sscanview(&vwr, cp=vopts);              /* set initial options */
1158 >        while ((cp = strstr(cp, "-vf ")) != NULL &&
1159 >                        *atos(buf, sizeof(buf), cp += 4)) {
1160 >                viewfile(buf, &vwr, NULL);      /* load -vf file */
1161 >                sscanview(&vwr, cp);            /* reset tail */
1162 >        }
1163 >        fputs(VIEWSTR, fp);
1164 >        fprintview(&vwr, fp);                   /* print full spec. */
1165 >        fputc('\n', fp);
1166          return(0);
1167   }
1168  
1169  
1170 < rview(opts, po)                         /* run rview with first view */
1171 < char    *opts, *po;
1170 > static void
1171 > rvu(                            /* run rvu with first view */
1172 >        char    *opts,
1173 >        char    *po
1174 > )
1175   {
1176          char    *vw;
1177 <        char    combuf[512];
1177 >        char    combuf[PATH_MAX];
1178                                          /* build command */
1179 <        if ((vw = getview(0, NULL)) == NULL)
1179 >        if (touchonly || (vw = getview(0, NULL)) == NULL)
1180                  return;
1181          if (sayview)
1182 <                printview(vw);
1183 <        sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname);
1182 >                myprintview(vw, stdout);
1183 >        sprintf(combuf, "rvu %s%s%s -R %s ", vw, po, opts, rifname);
1184          if (rvdevice != NULL)
1185                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1186          if (vdef(EXPOSURE))
1187                  sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1188          strcat(combuf, oct1name);
1189          if (runcom(combuf)) {           /* run it */
1190 <                fprintf(stderr, "%s: error running rview\n", progname);
1191 <                exit(1);
1190 >                fprintf(stderr, "%s: error running rvu\n", progname);
1191 >                quit(1);
1192          }
1193   }
1194  
1195  
1196 < rpict(opts, po)                         /* run rpict and pfilt for each view */
1197 < char    *opts, *po;
1196 > static void
1197 > rpict(                          /* run rpict and pfilt for each view */
1198 >        char    *opts,
1199 >        char    *po
1200 > )
1201   {
1202 <        char    combuf[1024];
1203 <        char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
1202 >        char    combuf[PATH_MAX];
1203 >        char    rawfile[PATH_MAX], picfile[PATH_MAX];
1204 >        char    zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32];
1205 >        char    rppopt[128], *pfile = NULL;
1206          char    pfopts[128];
1207          char    vs[32], *vw;
1208          int     vn, mult;
1209 +        FILE    *fp;
1210 +        time_t  rfdt, pfdt;
1211                                          /* get pfilt options */
1212          pfiltopts(pfopts);
1213                                          /* get resolution, reporting */
# Line 1407 | Line 1248 | char   *opts, *po;
1248                  else
1249                          badvalue(REPORT);
1250          }
1251 <                                        /* do each view */
1252 <        vn = 0;
1251 >                                        /* set up parallel rendering */
1252 >        if ((nprocs > 1) & (!vdef(ZFILE))) {
1253 >                strcpy(rppopt, "-S 1 -PP pfXXXXXX");
1254 >                pfile = rppopt+9;
1255 >                if (mktemp(pfile) == NULL)
1256 >                        pfile = NULL;
1257 >        }
1258 >        vn = 0;                                 /* do each view */
1259          while ((vw = getview(vn++, vs)) != NULL) {
1260                  if (sayview)
1261 <                        printview(vw);
1261 >                        myprintview(vw, stdout);
1262                  if (!vs[0])
1263                          sprintf(vs, "%d", vn);
1264                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1265 +                if (vdef(ZFILE))
1266 +                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1267 +                else
1268 +                        zopt[0] = '\0';
1269                                                  /* check date on picture */
1270 <                if (fdate(picfile) >= oct1date)
1270 >                pfdt = fdate(picfile);
1271 >                if (pfdt >= oct1date)
1272                          continue;
1273 +                                                /* get raw file name */
1274 +                sprintf(rawfile, "%s_%s.unf",
1275 +                        vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs);
1276 +                rfdt = fdate(rawfile);
1277 +                if (touchonly) {                /* update times only */
1278 +                        if (rfdt) {
1279 +                                if (rfdt < oct1date)
1280 +                                        touch(rawfile);
1281 +                        } else if (pfdt && pfdt < oct1date)
1282 +                                touch(picfile);
1283 +                        continue;
1284 +                }
1285 +                if (next_process()) {           /* parallel running? */
1286 +                        if (pfile != NULL)
1287 +                                sleep(20);
1288 +                        continue;
1289 +                }
1290 +                /* XXX Remember to call finish_process() */
1291                                                  /* build rpict command */
1292 <                sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1293 <                if (fdate(rawfile) >= oct1date)         /* recover */
1294 <                        sprintf(combuf, "rpict%s%s%s -ro %s %s",
1295 <                                        rep, po, opts, rawfile, oct1name);
1296 <                else {
1292 >                if (rfdt >= oct1date) {         /* recover */
1293 >                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1294 >                                rep, po, opts, zopt, rawfile, oct1name);
1295 >                        if (runcom(combuf))     /* run rpict */
1296 >                                goto rperror;
1297 >                } else {
1298                          if (overture) {         /* run overture calculation */
1299                                  sprintf(combuf,
1300                                  "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
# Line 1433 | Line 1304 | char   *opts, *po;
1304                                          fprintf(stderr,
1305                                          "%s: error in overture for view %s\n",
1306                                                  progname, vs);
1307 <                                        exit(1);
1307 >                                        quit(1);
1308                                  }
1309 < #ifdef NIX
1309 > #ifndef NULL_DEVICE
1310                                  rmfile(overfile);
1311   #endif
1312                          }
1313 <                        sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1313 >                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1314                                          rep, vw, res, po, opts,
1315 <                                oct1name, rawfile);
1315 >                                        zopt, oct1name, rawfile);
1316 >                        if (pfile != NULL && inchild()) {
1317 >                                                /* rpict persistent mode */
1318 >                                if (!silent) {
1319 >                                        printf("\t%s\n", combuf);
1320 >                                        fflush(stdout);
1321 >                                }
1322 >                                sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1323 >                                                rep, rppopt, res, po, opts,
1324 >                                                oct1name, rawfile);
1325 >                                fflush(stdout);
1326 >                                fp = popen(combuf, "w");
1327 >                                if (fp == NULL)
1328 >                                        goto rperror;
1329 >                                myprintview(vw, fp);
1330 >                                if (pclose(fp))
1331 >                                        goto rperror;
1332 >                        } else {                /* rpict normal mode */
1333 >                                if (runcom(combuf))
1334 >                                        goto rperror;
1335 >                        }
1336                  }
1337 <                if (runcom(combuf)) {           /* run rpict */
1447 <                        fprintf(stderr, "%s: error rendering view %s\n",
1448 <                                        progname, vs);
1449 <                        exit(1);
1450 <                }
1337 >                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1338                                                  /* build pfilt command */
1339 <                if (mult > 1)
1340 <                        sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1339 >                        if (mult > 1)
1340 >                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1341                                          pfopts, mult, mult, rawfile, picfile);
1342 <                else
1343 <                        sprintf(combuf, "pfilt%s %s > %s", pfopts,
1344 <                                        rawfile, picfile);
1345 <                if (runcom(combuf)) {           /* run pfilt */
1346 <                        fprintf(stderr,
1347 <                        "%s: error filtering view %s\n\t%s removed\n",
1348 <                                        progname, vs, picfile);
1349 <                        unlink(picfile);
1350 <                        exit(1);
1342 >                        else
1343 >                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1344 >                                                rawfile, picfile);
1345 >                        if (runcom(combuf)) {   /* run pfilt */
1346 >                                fprintf(stderr,
1347 >                                "%s: error filtering view %s\n\t%s removed\n",
1348 >                                                progname, vs, picfile);
1349 >                                unlink(picfile);
1350 >                                quit(1);
1351 >                        }
1352                  }
1353 <                                                /* remove raw file */
1354 <                rmfile(rawfile);
1353 >                                                /* remove/rename raw file */
1354 >                if (vdef(RAWFILE)) {
1355 >                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1356 >                        mvfile(rawfile, combuf);
1357 >                } else
1358 >                        rmfile(rawfile);
1359 >                finish_process();               /* exit if child */
1360          }
1361 +        wait_process(1);                /* wait for children to finish */
1362 +        if (pfile != NULL) {            /* clean up rpict persistent mode */
1363 +                int     pid;
1364 +                fp = fopen(pfile, "r");
1365 +                if (fp != NULL) {
1366 +                        if (fscanf(fp, "%*s %d", &pid) != 1 ||
1367 +                                        kill(pid, 1) < 0)
1368 +                                unlink(pfile);
1369 +                        fclose(fp);
1370 +                }
1371 +        }
1372 +        return;
1373 + rperror:
1374 +        fprintf(stderr, "%s: error rendering view %s\n", progname, vs);
1375 +        quit(1);
1376   }
1377  
1378  
1379 < runcom(cs)                      /* run command */
1380 < char    *cs;
1379 > static int
1380 > touch(                  /* update a file */
1381 >        char    *fn
1382 > )
1383   {
1384 +        if (!silent)
1385 +                printf("\ttouch %s\n", fn);
1386 +        if (!nprocs)
1387 +                return(0);
1388 + #ifdef notused
1389 +        if (access(fn, F_OK) == -1)             /* create it */
1390 +                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1391 +                        return(-1);
1392 + #endif
1393 +        return(setfdate(fn, time((time_t *)NULL)));
1394 + }
1395 +
1396 +
1397 + static int
1398 + runcom(                 /* run command */
1399 +        char    *cs
1400 + )
1401 + {
1402          if (!silent)            /* echo it */
1403                  printf("\t%s\n", cs);
1404 <        if (noaction)
1404 >        if (!nprocs)
1405                  return(0);
1406          fflush(stdout);         /* flush output and pass to shell */
1407          return(system(cs));
1408   }
1409  
1410  
1411 < rmfile(fn)                      /* remove a file */
1412 < char    *fn;
1411 > static int
1412 > rmfile(                 /* remove a file */
1413 >        char    *fn
1414 > )
1415   {
1416          if (!silent)
1417 < #ifdef MSDOS
1418 <                printf("\tdel %s\n", fn);
1489 < #else
1490 <                printf("\trm -f %s\n", fn);
1491 < #endif
1492 <        if (noaction)
1417 >                printf("\t%s %s\n", DELCMD, fn);
1418 >        if (!nprocs)
1419                  return(0);
1420          return(unlink(fn));
1421   }
1422  
1423  
1424 < #ifdef MSDOS
1424 > static int
1425 > mvfile(         /* move a file */
1426 >        char    *fold,
1427 >        char    *fnew
1428 > )
1429 > {
1430 >        if (!silent)
1431 >                printf("\t%s %s %s\n", RENAMECMD, fold, fnew);
1432 >        if (!nprocs)
1433 >                return(0);
1434 >        return(rename(fold, fnew));
1435 > }
1436 >
1437 >
1438 > #ifdef RHAS_FORK_EXEC
1439 > static int
1440 > next_process(void)                      /* fork the next process (max. nprocs) */
1441 > {
1442 >        int     child_pid;
1443 >
1444 >        if (nprocs <= 1)
1445 >                return(0);              /* it's us or no one */
1446 >        if (inchild()) {
1447 >                fprintf(stderr, "%s: internal error 1 in next_process()\n",
1448 >                                progname);
1449 >                quit(1);
1450 >        }
1451 >        if (children_running >= nprocs)
1452 >                wait_process(0);        /* wait for someone to finish */
1453 >        fflush(stdout);
1454 >        child_pid = fork();             /* split process */
1455 >        if (child_pid == 0) {           /* we're the child */
1456 >                children_running = -1;
1457 >                return(0);
1458 >        }
1459 >        if (child_pid > 0) {            /* we're the parent */
1460 >                ++children_running;
1461 >                return(1);
1462 >        }
1463 >        fprintf(stderr, "%s: warning -- fork() failed\n", progname);
1464 >        return(0);
1465 > }
1466 >
1467 > static void
1468 > wait_process(                   /* wait for process(es) to finish */
1469 >        int     all
1470 > )
1471 > {
1472 >        int     ourstatus = 0;
1473 >        int     pid, status;
1474 >
1475 >        if (all)
1476 >                all = children_running;
1477 >        else if (children_running > 0)
1478 >                all = 1;
1479 >        while (all-- > 0) {
1480 >                pid = wait(&status);
1481 >                if (pid < 0)
1482 >                        syserr(progname);
1483 >                status = status>>8 & 0xff;
1484 >                --children_running;
1485 >                if (status != 0) {      /* child's problem is our problem */
1486 >                        if ((ourstatus == 0) & (children_running > 0))
1487 >                                fprintf(stderr, "%s: waiting for remaining processes\n",
1488 >                                                progname);
1489 >                        ourstatus = status;
1490 >                        all = children_running;
1491 >                }
1492 >        }
1493 >        if (ourstatus != 0)
1494 >                quit(ourstatus);        /* bad status from child */
1495 > }
1496 > #else   /* ! RHAS_FORK_EXEC */
1497 > static int
1498 > next_process(void)
1499 > {
1500 >        return(0);                      /* cannot start new process */
1501 > }
1502 > static void
1503 > wait_process(all)
1504 > int     all;
1505 > {
1506 >        (void)all;                      /* no one to wait for */
1507 > }
1508 > int
1509 > kill(pid, sig) /* win|unix_process.c should also wait and kill */
1510 > int pid, sig;
1511 > {
1512 >        return 0;
1513 > }
1514 > #endif  /* ! RHAS_FORK_EXEC */
1515 >
1516 > static void
1517 > finish_process(void)                    /* exit a child process */
1518 > {
1519 >        if (!inchild())
1520 >                return;                 /* in parent -- noop */
1521 >        exit(0);
1522 > }
1523 >
1524 > #ifdef _WIN32
1525   setenv(vname, value)            /* set an environment variable */
1526   char    *vname, *value;
1527   {
# Line 1507 | Line 1533 | char   *vname, *value;
1533          sprintf(evp, "%s=%s", vname, value);
1534          if (putenv(evp) != 0) {
1535                  fprintf(stderr, "%s: out of environment space\n", progname);
1536 <                exit(1);
1536 >                quit(1);
1537          }
1538          if (!silent)
1539                  printf("set %s\n", evp);
# Line 1515 | Line 1541 | char   *vname, *value;
1541   #endif
1542  
1543  
1544 < badvalue(vc)                    /* report bad variable value and exit */
1545 < int     vc;
1544 > static void
1545 > badvalue(                       /* report bad variable value and exit */
1546 >        int     vc
1547 > )
1548   {
1549          fprintf(stderr, "%s: bad value for variable '%s'\n",
1550                          progname, vnam(vc));
1551 <        exit(1);
1551 >        quit(1);
1552   }
1553  
1554  
1555 < syserr(s)                       /* report a system error and exit */
1556 < char    *s;
1555 > static void
1556 > syserr(                 /* report a system error and exit */
1557 >        char    *s
1558 > )
1559   {
1560          perror(s);
1561 <        exit(1);
1561 >        quit(1);
1562 > }
1563 >
1564 >
1565 > void
1566 > quit(ec)                        /* exit program */
1567 > int     ec;
1568 > {
1569 >        exit(ec);
1570   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines