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.53 by greg, Thu Mar 20 12:50:07 1997 UTC vs.
Revision 2.110 by greg, Wed Dec 4 20:07:07 2013 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1995 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 +
10 + #include <ctype.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"
14 #include <ctype.h>
15 #include <sys/types.h>
18  
19 <                                /* variables */
20 < #define OBJECT          0               /* object files */
21 < #define SCENE           1               /* scene files */
22 < #define MATERIAL        2               /* material files */
23 < #define ILLUM           3               /* mkillum input files */
24 < #define MKILLUM         4               /* mkillum options */
25 < #define RENDER          5               /* rendering options */
26 < #define OCONV           6               /* oconv options */
27 < #define PFILT           7               /* pfilt options */
28 < #define VIEW            8               /* view(s) for picture(s) */
29 < #define ZONE            9               /* simulation zone */
30 < #define QUALITY         10              /* desired rendering quality */
31 < #define OCTREE          11              /* octree file name */
32 < #define PICTURE         12              /* picture file root name */
33 < #define AMBFILE         13              /* ambient file name */
34 < #define OPTFILE         14              /* rendering options file */
35 < #define EXPOSURE        15              /* picture exposure setting */
36 < #define RESOLUTION      16              /* maximum picture resolution */
37 < #define UP              17              /* view up (X, Y or Z) */
38 < #define INDIRECT        18              /* indirection in lighting */
39 < #define DETAIL          19              /* level of scene detail */
40 < #define PENUMBRAS       20              /* shadow penumbras are desired */
41 < #define VARIABILITY     21              /* level of light variability */
42 < #define REPORT          22              /* report frequency and errfile */
43 < #define RAWFILE         23              /* raw picture file root name */
44 < #define ZFILE           24              /* distance file root name */
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 >                                /* 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 RPICT           20              /* rpict parameters */
51 > #define RVU             21              /* rvu parameters */
52 > #define SCENE           22              /* scene files */
53 > #define UP              23              /* view up (X, Y or Z) */
54 > #define VARIABILITY     24              /* level of light variability */
55 > #define VIEWS           25              /* view(s) for picture(s) */
56 > #define ZFILE           26              /* distance file root name */
57 > #define ZONE            27              /* simulation zone */
58                                  /* total number of variables */
59 < int NVARS = 25;
59 > int NVARS = 28;
60  
61   VARIABLE        vv[] = {                /* variable-value pairs */
62 <        {"objects",     3,      0,      NULL,   catvalues},
63 <        {"scene",       3,      0,      NULL,   catvalues},
64 <        {"materials",   3,      0,      NULL,   catvalues},
62 >        {"AMBFILE",     3,      0,      NULL,   onevalue},
63 >        {"DETAIL",      3,      0,      NULL,   qualvalue},
64 >        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
65 >        {"EYESEP",      3,      0,      NULL,   fltvalue},
66          {"illum",       3,      0,      NULL,   catvalues},
67 +        {"INDIRECT",    3,      0,      NULL,   intvalue},
68 +        {"materials",   3,      0,      NULL,   catvalues},
69          {"mkillum",     3,      0,      NULL,   catvalues},
70 <        {"render",      3,      0,      NULL,   catvalues},
70 >        {"objects",     3,      0,      NULL,   catvalues},
71          {"oconv",       3,      0,      NULL,   catvalues},
54        {"pfilt",       2,      0,      NULL,   catvalues},
55        {"view",        2,      0,      NULL,   NULL},
56        {"ZONE",        2,      0,      NULL,   onevalue},
57        {"QUALITY",     3,      0,      NULL,   qualvalue},
72          {"OCTREE",      3,      0,      NULL,   onevalue},
59        {"PICTURE",     3,      0,      NULL,   onevalue},
60        {"AMBFILE",     3,      0,      NULL,   onevalue},
73          {"OPTFILE",     3,      0,      NULL,   onevalue},
74 <        {"EXPOSURE",    3,      0,      NULL,   fltvalue},
74 >        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
75 >        {"pfilt",       2,      0,      NULL,   catvalues},
76 >        {"PICTURE",     3,      0,      NULL,   onevalue},
77 >        {"QUALITY",     3,      0,      NULL,   qualvalue},
78 >        {"RAWFILE",     3,      0,      NULL,   onevalue},
79 >        {"render",      3,      0,      NULL,   catvalues},
80 >        {"REPORT",      3,      0,      NULL,   onevalue},
81          {"RESOLUTION",  3,      0,      NULL,   onevalue},
82 +        {"rpict",       3,      0,      NULL,   catvalues},
83 +        {"rvu",         3,      0,      NULL,   catvalues},
84 +        {"scene",       3,      0,      NULL,   catvalues},
85          {"UP",          2,      0,      NULL,   onevalue},
65        {"INDIRECT",    3,      0,      NULL,   intvalue},
66        {"DETAIL",      3,      0,      NULL,   qualvalue},
67        {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
86          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
87 <        {"REPORT",      3,      0,      NULL,   onevalue},
70 <        {"RAWFILE",     3,      0,      NULL,   onevalue},
87 >        {"view",        2,      0,      NULL,   NULL},
88          {"ZFILE",       2,      0,      NULL,   onevalue},
89 +        {"ZONE",        2,      0,      NULL,   onevalue},
90   };
91  
92                                  /* overture calculation file */
93 < #ifdef NIX
94 < char    overfile[] = "overture.unf";
93 > #ifdef NULL_DEVICE
94 > char    overfile[] = NULL_DEVICE;
95   #else
96 < char    overfile[] = "/dev/null";
96 > char    overfile[] = "overture.unf";
97   #endif
98  
81 extern time_t   fdate(), time();
99  
100   time_t  scenedate;              /* date of latest scene or object file */
101   time_t  octreedate;             /* date of octree */
# Line 94 | Line 111 | int    nowarn = 0;             /* no warnings */
111   int     explicate = 0;          /* explicate variables */
112   int     silent = 0;             /* do work silently */
113   int     touchonly = 0;          /* touch files only */
114 < int     noaction = 0;           /* don't do anything */
114 > int     nprocs = 1;             /* maximum executing processes */
115   int     sayview = 0;            /* print view out */
116 < char    *rvdevice = NULL;       /* rview output device */
116 > char    *rvdevice = NULL;       /* rvu output device */
117   char    *viewselect = NULL;     /* specific view only */
118  
119 + #define DEF_RPICT_PATH  "rpict"         /* default rpict path */
120 +
121 +                                /* command paths */
122 + char    c_oconv[256] = "oconv";
123 + char    c_mkillum[256] = "mkillum";
124 + char    c_rvu[256] = "rvu";
125 + char    c_rpict[256] = DEF_RPICT_PATH;
126 + char    c_rpiece[] = "rpiece";
127 + char    c_pfilt[256] = "pfilt";
128 +
129   int     overture = 0;           /* overture calculation needed */
130  
131 + int     children_running = 0;   /* set negative in children */
132 +
133   char    *progname;              /* global argv[0] */
134   char    *rifname;               /* global rad input file name */
135  
136 < char    radname[MAXPATH];       /* root Radiance file name */
136 > char    radname[PATH_MAX];      /* root Radiance file name */
137  
138 + #define inchild()       (children_running < 0)
139  
140 < main(argc, argv)
141 < int     argc;
142 < char    *argv[];
140 > static void rootname(char       *rn, char       *fn);
141 > static time_t checklast(char    *fnames);
142 > static char * newfname(char     *orig, int      pred);
143 > static void checkfiles(void);
144 > static void getoctcube(double   org[3], double  *sizp);
145 > static void setdefaults(void);
146 > static void oconv(void);
147 > static char * addarg(char       *op, char       *arg);
148 > static void oconvopts(char      *oo);
149 > static void mkillumopts(char    *mo);
150 > static void checkambfile(void);
151 > static double ambval(void);
152 > static void renderopts(char     *op, char       *po);
153 > static void lowqopts(char       *op, char       *po);
154 > static void medqopts(char       *op, char       *po);
155 > static void hiqopts(char        *op, char       *po);
156 > static void xferopts(char       *ro);
157 > static void pfiltopts(char      *po);
158 > static int matchword(char       *s1, char       *s2);
159 > static char * specview(char     *vs);
160 > static char * getview(int       n, char *vn);
161 > static int myprintview(char     *vopts, FILE    *fp);
162 > static void rvu(char    *opts, char     *po);
163 > static void rpict(char  *opts, char     *po);
164 > static int touch(char   *fn);
165 > static int runcom(char  *cs);
166 > static int rmfile(char  *fn);
167 > static int mvfile(char  *fold, char     *fnew);
168 > static int next_process(int     reserve);
169 > static void wait_process(int    all);
170 > static void finish_process(void);
171 > static void badvalue(int        vc);
172 > static void syserr(char *s);
173 >
174 >
175 > int
176 > main(
177 >        int     argc,
178 >        char    *argv[]
179 > )
180   {
181          char    ropts[512];
182          char    popts[64];
# Line 123 | Line 190 | char   *argv[];
190                          silent++;
191                          break;
192                  case 'n':
193 <                        noaction++;
193 >                        nprocs = 0;
194                          break;
195 +                case 'N':
196 +                        nprocs = atoi(argv[++i]);
197 +                        if (nprocs < 0)
198 +                                nprocs = 0;
199 +                        break;
200                  case 't':
201                          touchonly++;
202                          break;
# Line 177 | Line 249 | char   *argv[];
249          renderopts(ropts, popts);
250          xferopts(ropts);
251          if (rvdevice != NULL)
252 <                rview(ropts, popts);
252 >                rvu(ropts, popts);
253          else
254                  rpict(ropts, popts);
255          quit(0);
256   userr:
257          fprintf(stderr,
258 < "Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
258 > "Usage: %s [-w][-s][-n|-N npr][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n",
259                          progname);
260          quit(1);
261 +        return 1; /* pro forma return */
262   }
263  
264  
265 < rootname(rn, fn)                /* remove tail from end of fn */
266 < register char   *rn, *fn;
265 > static void
266 > rootname(               /* remove tail from end of fn */
267 >        char    *rn,
268 >        char    *fn
269 > )
270   {
271          char    *tp, *dp;
272  
273 <        for (tp = NULL, dp = rn; *rn = *fn++; rn++)
273 >        for (tp = NULL, dp = rn; (*rn = *fn++); rn++)
274                  if (ISDIRSEP(*rn))
275                          dp = rn;
276                  else if (*rn == '.')
# Line 204 | Line 280 | register char  *rn, *fn;
280   }
281  
282  
283 < time_t
284 < checklast(fnames)                       /* check files and find most recent */
285 < register char   *fnames;
283 > static time_t
284 > checklast(                      /* check files and find most recent */
285 >        char    *fnames
286 > )
287   {
288 <        char    thisfile[MAXPATH];
288 >        char    thisfile[PATH_MAX];
289          time_t  thisdate, lastdate = 0;
213        register char   *cp;
290  
291          if (fnames == NULL)
292                  return(0);
293 <        while (*fnames) {
294 <                while (isspace(*fnames)) fnames++;
295 <                cp = thisfile;
296 <                while (*fnames && !isspace(*fnames))
297 <                        *cp++ = *fnames++;
298 <                *cp = '\0';
293 >        while ((fnames = nextword(thisfile, PATH_MAX, fnames)) != NULL) {
294 >                if (thisfile[0] == '!' ||
295 >                                (thisfile[0] == '\\' && thisfile[1] == '!')) {
296 >                        if (!lastdate)
297 >                                lastdate = 1;
298 >                        continue;
299 >                }
300                  if (!(thisdate = fdate(thisfile)))
301                          syserr(thisfile);
302                  if (thisdate > lastdate)
# Line 229 | Line 306 | register char  *fnames;
306   }
307  
308  
309 < char *
310 < newfname(orig, pred)            /* create modified file name */
311 < char    *orig;
312 < int     pred;
309 > static char *
310 > newfname(               /* create modified file name */
311 >        char    *orig,
312 >        int     pred
313 > )
314   {
315 <        extern char     *rindex();
316 <        register char   *cp;
239 <        register int    n;
315 >        char    *cp;
316 >        int     n;
317          int     suffix;
318  
319          n = 0; cp = orig; suffix = -1;          /* suffix position, length */
# Line 255 | Line 332 | int    pred;
332   }
333  
334  
335 < checkfiles()                    /* check for existence and modified times */
335 > static void
336 > checkfiles(void)                        /* check for existence and modified times */
337   {
338          time_t  objdate;
339  
# Line 264 | Line 342 | checkfiles()                   /* check for existence and modified tim
342                          syserr(progname);
343                  sprintf(vval(OCTREE), "%s.oct", radname);
344                  vdef(OCTREE)++;
345 +        } else if (vval(OCTREE)[0] == '!') {
346 +                fprintf(stderr, "%s: illegal '%s' specification\n",
347 +                                progname, vnam(OCTREE));
348 +                quit(1);
349          }
350          octreedate = fdate(vval(OCTREE));
351          if (vdef(ILLUM)) {              /* illum requires secondary octrees */
# Line 286 | Line 368 | checkfiles()                   /* check for existence and modified tim
368   }      
369  
370  
371 < getoctcube(org, sizp)           /* get octree bounding cube */
372 < double  org[3], *sizp;
371 > static void
372 > getoctcube(             /* get octree bounding cube */
373 >        double  org[3],
374 >        double  *sizp
375 > )
376   {
292        extern FILE     *popen();
377          static double   oorg[3], osiz = 0.;
378          double  min[3], max[3];
379          char    buf[1024];
380          FILE    *fp;
381 <        register int    i;
381 >        int     i;
382  
383 <        if (osiz <= FTINY)
384 <                if (noaction && fdate(oct1name) <
383 >        if (osiz <= FTINY) {
384 >                if (!nprocs && fdate(oct1name) <
385                                  (scenedate>illumdate?scenedate:illumdate)) {
386                                                          /* run getbbox */
387                          sprintf(buf, "getbbox -w -h %s",
# Line 332 | Line 416 | double org[3], *sizp;
416                          }
417                          pclose(fp);
418                  }
419 +        }
420          org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz;
421   }
422  
423  
424 < setdefaults()                   /* set default values for unassigned var's */
424 > static void
425 > setdefaults(void)                       /* set default values for unassigned var's */
426   {
427 <        double  org[3], size;
427 >        double  org[3], lim[3], size;
428          char    buf[128];
429  
430          if (!vdef(ZONE)) {
# Line 348 | Line 434 | setdefaults()                  /* set default values for unassigned v
434                  vval(ZONE) = savqstr(buf);
435                  vdef(ZONE)++;
436          }
437 +        if (!vdef(EYESEP)) {
438 +                if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf",
439 +                                &org[0], &lim[0], &org[1], &lim[1],
440 +                                &org[2], &lim[2]) != 6)
441 +                        badvalue(ZONE);
442 +                sprintf(buf, "%f",
443 +                        0.01*(lim[0]-org[0]+lim[1]-org[1]+lim[2]-org[2]));
444 +                vval(EYESEP) = savqstr(buf);
445 +                vdef(EYESEP)++;
446 +        }
447          if (!vdef(INDIRECT)) {
448                  vval(INDIRECT) = "0";
449                  vdef(INDIRECT)++;
# Line 364 | Line 460 | setdefaults()                  /* set default values for unassigned v
460                  vval(PICTURE) = radname;
461                  vdef(PICTURE)++;
462          }
463 <        if (!vdef(VIEW)) {
464 <                vval(VIEW) = "X";
465 <                vdef(VIEW)++;
463 >        if (!vdef(VIEWS)) {
464 >                vval(VIEWS) = "X";
465 >                vdef(VIEWS)++;
466          }
467          if (!vdef(DETAIL)) {
468                  vval(DETAIL) = "M";
# Line 383 | Line 479 | setdefaults()                  /* set default values for unassigned v
479   }
480  
481  
482 < oconv()                         /* run oconv and mkillum if necessary */
482 > static void
483 > oconv(void)                             /* run oconv and mkillum if necessary */
484   {
485          static char     illumtmp[] = "ilXXXXXX";
486 <        char    combuf[1024], ocopts[64], mkopts[64];
486 >        char    combuf[PATH_MAX], ocopts[64], mkopts[1024];
487  
488          oconvopts(ocopts);              /* get options */
489          if (octreedate < scenedate) {   /* check date on original octree */
# Line 394 | Line 491 | oconv()                                /* run oconv and mkillum if necessary */
491                          touch(vval(OCTREE));
492                  else {                          /* build command */
493                          if (vdef(MATERIAL))
494 <                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
495 <                                                vval(MATERIAL), vval(SCENE),
496 <                                                vval(OCTREE));
494 >                                sprintf(combuf, "%s%s %s %s > %s", c_oconv,
495 >                                                ocopts, vval(MATERIAL),
496 >                                                vval(SCENE), vval(OCTREE));
497                          else
498 <                                sprintf(combuf, "oconv%s %s > %s", ocopts,
498 >                                sprintf(combuf, "%s%s %s > %s", c_oconv, ocopts,
499                                                  vval(SCENE), vval(OCTREE));
500                          
501                          if (runcom(combuf)) {           /* run it */
# Line 415 | Line 512 | oconv()                                /* run oconv and mkillum if necessary */
512          }
513          if (oct1name == vval(OCTREE))           /* no mkillum? */
514                  oct1date = octreedate > matdate ? octreedate : matdate;
515 <        if (oct1date >= octreedate & oct1date >= matdate
516 <                        & oct1date >= illumdate)        /* all done */
515 >        if ((oct1date >= octreedate) & (oct1date >= matdate)
516 >                        & (oct1date >= illumdate))      /* all done */
517                  return;
518                                                  /* make octree0 */
519 <        if (oct0date < scenedate | oct0date < illumdate) {
519 >        if ((oct0date < scenedate) | (oct0date < illumdate)) {
520                  if (touchonly && oct0date)
521                          touch(oct0name);
522                  else {                          /* build command */
523                          if (octreedate)
524 <                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
525 <                                        vval(OCTREE), vval(ILLUM), oct0name);
524 >                                sprintf(combuf, "%s%s -i %s %s > %s", c_oconv,
525 >                                        ocopts, vval(OCTREE),
526 >                                        vval(ILLUM), oct0name);
527                          else if (vdef(MATERIAL))
528 <                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
529 <                                        vval(MATERIAL), vval(ILLUM), oct0name);
432 <                        else
433 <                                sprintf(combuf, "oconv%s %s > %s", ocopts,
528 >                                sprintf(combuf, "%s%s %s %s > %s", c_oconv,
529 >                                        ocopts, vval(MATERIAL),
530                                          vval(ILLUM), oct0name);
531 +                        else
532 +                                sprintf(combuf, "%s%s %s > %s", c_oconv,
533 +                                        ocopts, vval(ILLUM), oct0name);
534                          if (runcom(combuf)) {           /* run it */
535                                  fprintf(stderr,
536                                  "%s: error generating octree\n\t%s removed\n",
# Line 451 | Line 550 | oconv()                                /* run oconv and mkillum if necessary */
550          else {
551                  mkillumopts(mkopts);            /* build mkillum command */
552                  mktemp(illumtmp);
553 <                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
553 >                sprintf(combuf, "%s%s %s \"<\" %s > %s", c_mkillum, mkopts,
554                                  oct0name, vval(ILLUM), illumtmp);
555                  if (runcom(combuf)) {                   /* run it */
556 <                        fprintf(stderr, "%s: error running mkillum\n",
557 <                                        progname);
556 >                        fprintf(stderr, "%s: error running %s\n",
557 >                                        progname, c_mkillum);
558                          unlink(illumtmp);
559                          quit(1);
560                  }
561 +                rmfile(oct0name);
562                                                  /* make octree1 (frozen) */
563                  if (octreedate)
564 <                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
565 <                                vval(OCTREE), illumtmp, oct1name);
564 >                        sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv,
565 >                                ocopts, vval(OCTREE), illumtmp, oct1name);
566                  else if (vdef(MATERIAL))
567 <                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
568 <                                vval(MATERIAL), illumtmp, oct1name);
567 >                        sprintf(combuf, "%s%s -f %s %s > %s", c_oconv,
568 >                                ocopts, vval(MATERIAL), illumtmp, oct1name);
569                  else
570 <                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
570 >                        sprintf(combuf, "%s%s -f %s > %s", c_oconv, ocopts,
571                                  illumtmp, oct1name);
572                  if (runcom(combuf)) {           /* run it */
573                          fprintf(stderr,
# Line 485 | Line 585 | oconv()                                /* run oconv and mkillum if necessary */
585   }
586  
587  
588 < char *
589 < addarg(op, arg)                         /* add argument and advance pointer */
590 < register char   *op, *arg;
588 > static char *
589 > addarg(                         /* append argument and advance pointer */
590 > char    *op,
591 > char    *arg
592 > )
593   {
594 +        while (*op)
595 +                op++;
596          *op = ' ';
597 <        while (*++op = *arg++)
597 >        while ( (*++op = *arg++) )
598                  ;
599          return(op);
600   }
601  
602  
603 < oconvopts(oo)                           /* get oconv options */
604 < register char   *oo;
603 > static void
604 > oconvopts(                              /* get oconv options */
605 >        char    *oo
606 > )
607   {
608          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
609  
610          *oo = '\0';
611          if (vdef(OCONV))
612 <                addarg(oo, vval(OCONV));
612 >                if (vval(OCONV)[0] != '-') {
613 >                        atos(c_oconv, sizeof(c_oconv), vval(OCONV));
614 >                        oo = addarg(oo, sskip2(vval(OCONV), 1));
615 >                } else
616 >                        oo = addarg(oo, vval(OCONV));
617   }
618  
619  
620 < mkillumopts(mo)                         /* get mkillum options */
621 < register char   *mo;
620 > static void
621 > mkillumopts(                            /* get mkillum options */
622 >        char    *mo
623 > )
624   {
625          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
626  
627 <        *mo = '\0';
627 >        if (nprocs > 1)
628 >                sprintf(mo, " -n %d", nprocs);
629 >        else
630 >                *mo = '\0';
631          if (vdef(MKILLUM))
632 <                addarg(mo, vval(MKILLUM));
632 >                if (vval(MKILLUM)[0] != '-') {
633 >                        atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM));
634 >                        mo = addarg(mo, sskip2(vval(MKILLUM), 1));
635 >                } else
636 >                        mo = addarg(mo, vval(MKILLUM));
637   }
638  
639  
640 < checkambfile()                  /* check date on ambient file */
640 > static void
641 > checkambfile(void)                      /* check date on ambient file */
642   {
643          time_t  afdate;
644  
# Line 526 | Line 646 | checkambfile()                 /* check date on ambient file */
646                  return;
647          if (!(afdate = fdate(vval(AMBFILE))))
648                  return;
649 <        if (oct1date > afdate)
649 >        if (oct1date > afdate) {
650                  if (touchonly)
651                          touch(vval(AMBFILE));
652                  else
653                          rmfile(vval(AMBFILE));
654 +        }
655   }
656  
657  
658 < double
659 < ambval()                                /* compute ambient value */
658 > static double
659 > ambval(void)                            /* compute ambient value */
660   {
661          if (vdef(EXPOSURE)) {
662                  if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-')
# Line 547 | Line 668 | ambval()                               /* compute ambient value */
668          if (vlet(ZONE) == 'I')
669                  return(.01);
670          badvalue(ZONE);
671 +        return 0; /* pro forma return */
672   }
673  
674  
675 < renderopts(op, po)                      /* set rendering options */
676 < char    *op, *po;
675 > static void
676 > renderopts(                     /* set rendering options */
677 >        char    *op,
678 >        char    *po
679 > )
680   {
681          switch(vscale(QUALITY)) {
682          case LOW:
# Line 564 | Line 689 | char   *op, *po;
689                  hiqopts(op, po);
690                  break;
691          }
692 +        if (vdef(RENDER))
693 +                op = addarg(op, vval(RENDER));
694 +        if (rvdevice != NULL) {
695 +                if (vdef(RVU))
696 +                        if (vval(RVU)[0] != '-') {
697 +                                atos(c_rvu, sizeof(c_rvu), vval(RVU));
698 +                                po = addarg(po, sskip2(vval(RVU), 1));
699 +                        } else
700 +                                po = addarg(po, vval(RVU));
701 +        } else {
702 +                if (vdef(RPICT))
703 +                        if (vval(RPICT)[0] != '-') {
704 +                                atos(c_rpict, sizeof(c_rpict), vval(RPICT));
705 +                                po = addarg(po, sskip2(vval(RPICT), 1));
706 +                        } else
707 +                                po = addarg(po, vval(RPICT));
708 +        }
709   }
710  
711  
712 < lowqopts(op, po)                        /* low quality rendering options */
713 < register char   *op;
714 < char    *po;
712 > static void
713 > lowqopts(                       /* low quality rendering options */
714 >        char    *op,
715 >        char    *po
716 > )
717   {
718          double  d, org[3], siz[3];
719  
# Line 579 | Line 723 | char   *po;
723                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
724                  badvalue(ZONE);
725          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
726 <        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
726 >        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY))
727                  badvalue(ZONE);
728          getoctcube(org, &d);
729          d *= 3./(siz[0]+siz[1]+siz[2]);
# Line 587 | Line 731 | char   *po;
731          case LOW:
732                  po = addarg(po, "-ps 16");
733                  op = addarg(op, "-dp 64");
734 <                sprintf(op, " -ar %d", (int)(4*d));
734 >                sprintf(op, " -ar %d", (int)(8*d));
735                  op += strlen(op);
736                  break;
737          case MEDIUM:
738                  po = addarg(po, "-ps 8");
739                  op = addarg(op, "-dp 128");
740 <                sprintf(op, " -ar %d", (int)(8*d));
740 >                sprintf(op, " -ar %d", (int)(16*d));
741                  op += strlen(op);
742                  break;
743          case HIGH:
744                  po = addarg(po, "-ps 4");
745                  op = addarg(op, "-dp 256");
746 <                sprintf(op, " -ar %d", (int)(16*d));
746 >                sprintf(op, " -ar %d", (int)(32*d));
747                  op += strlen(op);
748                  break;
749          }
# Line 608 | Line 752 | char   *po;
752                  op = addarg(op, "-ds .4");
753          else
754                  op = addarg(op, "-ds 0");
755 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
755 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -ss 0 -st .5");
756          if (vdef(AMBFILE)) {
757                  sprintf(op, " -af %s", vval(AMBFILE));
758                  op += strlen(op);
# Line 616 | Line 760 | char   *po;
760                  overture = 0;
761          switch (vscale(VARIABILITY)) {
762          case LOW:
763 <                op = addarg(op, "-aw 128 -aa .4 -ad 64");
763 >                op = addarg(op, "-aa .3 -ad 256");
764                  break;
765          case MEDIUM:
766 <                op = addarg(op, "-aw 1024 -aa .3 -ad 128");
766 >                op = addarg(op, "-aa .25 -ad 512");
767                  break;
768          case HIGH:
769 <                op = addarg(op, "-aa .25 -ad 256");
769 >                op = addarg(op, "-aa .2 -ad 1024");
770                  break;
771          }
772          op = addarg(op, "-as 0");
773          d = ambval();
774          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
775          op += strlen(op);
776 <        op = addarg(op, "-lr 3 -lw .02");
633 <        if (vdef(RENDER))
634 <                op = addarg(op, vval(RENDER));
776 >        op = addarg(op, "-lr 6 -lw .003");
777   }
778  
779  
780 < medqopts(op, po)                        /* medium quality rendering options */
781 < register char   *op;
782 < char    *po;
780 > static void
781 > medqopts(                       /* medium quality rendering options */
782 >        char    *op,
783 >        char    *po
784 > )
785   {
786          double  d, org[3], siz[3], asz;
787  
# Line 647 | Line 791 | char   *po;
791                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
792                  badvalue(ZONE);
793          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
794 <        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
794 >        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY))
795                  badvalue(ZONE);
796          getoctcube(org, &d);
797          asz = (siz[0]+siz[1]+siz[2])/3.;
# Line 656 | Line 800 | char   *po;
800          case LOW:
801                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
802                  op = addarg(op, "-dp 256");
803 <                sprintf(op, " -ar %d", (int)(8*d));
803 >                sprintf(op, " -ar %d", (int)(16*d));
804                  op += strlen(op);
805                  sprintf(op, " -ms %.2g", asz/20.);
806                  op += strlen(op);
# Line 664 | Line 808 | char   *po;
808          case MEDIUM:
809                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
810                  op = addarg(op, "-dp 512");
811 <                sprintf(op, " -ar %d", (int)(16*d));
811 >                sprintf(op, " -ar %d", (int)(32*d));
812                  op += strlen(op);
813                  sprintf(op, " -ms %.2g", asz/40.);
814                  op += strlen(op);
# Line 672 | Line 816 | char   *po;
816          case HIGH:
817                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
818                  op = addarg(op, "-dp 1024");
819 <                sprintf(op, " -ar %d", (int)(32*d));
819 >                sprintf(op, " -ar %d", (int)(64*d));
820                  op += strlen(op);
821                  sprintf(op, " -ms %.2g", asz/80.);
822                  op += strlen(op);
# Line 680 | Line 824 | char   *po;
824          }
825          po = addarg(po, "-pt .08");
826          if (vbool(PENUMBRAS))
827 <                op = addarg(op, "-ds .2 -dj .5");
827 >                op = addarg(op, "-ds .2 -dj .9");
828          else
829                  op = addarg(op, "-ds .3");
830 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
831 <        if (overture = vint(INDIRECT)) {
830 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss 1 -st .1");
831 >        if ( (overture = vint(INDIRECT)) ) {
832                  sprintf(op, " -ab %d", overture);
833                  op += strlen(op);
834          }
# Line 695 | Line 839 | char   *po;
839                  overture = 0;
840          switch (vscale(VARIABILITY)) {
841          case LOW:
842 <                op = addarg(op, "-aw 128 -aa .25 -ad 196 -as 0");
842 >                op = addarg(op, "-aa .2 -ad 329 -as 42");
843                  break;
844          case MEDIUM:
845 <                op = addarg(op, "-aw 1024 -aa .2 -ad 400 -as 64");
845 >                op = addarg(op, "-aa .15 -ad 800 -as 128");
846                  break;
847          case HIGH:
848 <                op = addarg(op, "-aa .15 -ad 768 -as 196");
848 >                op = addarg(op, "-aa .1 -ad 1536 -as 392");
849                  break;
850          }
851          d = ambval();
852          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
853          op += strlen(op);
854 <        op = addarg(op, "-lr 6 -lw .002");
711 <        if (vdef(RENDER))
712 <                op = addarg(op, vval(RENDER));
854 >        op = addarg(op, "-lr 8 -lw 1e-4");
855   }
856  
857  
858 < hiqopts(op, po)                         /* high quality rendering options */
859 < register char   *op;
860 < char    *po;
858 > static void
859 > hiqopts(                                /* high quality rendering options */
860 >        char    *op,
861 >        char    *po
862 > )
863   {
864          double  d, org[3], siz[3], asz;
865  
# Line 725 | Line 869 | char   *po;
869                          &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6)
870                  badvalue(ZONE);
871          siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2];
872 <        if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
872 >        if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY))
873                  badvalue(ZONE);
874          getoctcube(org, &d);
875          asz = (siz[0]+siz[1]+siz[2])/3.;
# Line 734 | Line 878 | char   *po;
878          case LOW:
879                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
880                  op = addarg(op, "-dp 1024");
881 <                sprintf(op, " -ar %d", (int)(16*d));
881 >                sprintf(op, " -ar %d", (int)(32*d));
882                  op += strlen(op);
883                  sprintf(op, " -ms %.2g", asz/40.);
884                  op += strlen(op);
# Line 742 | Line 886 | char   *po;
886          case MEDIUM:
887                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
888                  op = addarg(op, "-dp 2048");
889 <                sprintf(op, " -ar %d", (int)(32*d));
889 >                sprintf(op, " -ar %d", (int)(64*d));
890                  op += strlen(op);
891                  sprintf(op, " -ms %.2g", asz/80.);
892                  op += strlen(op);
# Line 750 | Line 894 | char   *po;
894          case HIGH:
895                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
896                  op = addarg(op, "-dp 4096");
897 <                sprintf(op, " -ar %d", (int)(64*d));
897 >                sprintf(op, " -ar %d", (int)(128*d));
898                  op += strlen(op);
899                  sprintf(op, " -ms %.2g", asz/160.);
900                  op += strlen(op);
# Line 758 | Line 902 | char   *po;
902          }
903          po = addarg(po, "-pt .04");
904          if (vbool(PENUMBRAS))
905 <                op = addarg(op, "-ds .1 -dj .65");
905 >                op = addarg(op, "-ds .1 -dj .9");
906          else
907                  op = addarg(op, "-ds .2");
908 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
908 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 16 -st .01");
909          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
910          op += strlen(op);
911          if (vdef(AMBFILE)) {
# Line 771 | Line 915 | char   *po;
915                  overture = 0;
916          switch (vscale(VARIABILITY)) {
917          case LOW:
918 <                op = addarg(op, "-aw 128 -aa .15 -ad 256 -as 0");
918 >                op = addarg(op, "-aa .125 -ad 512 -as 64");
919                  break;
920          case MEDIUM:
921 <                op = addarg(op, "-aw 1024 -aa .125 -ad 512 -as 256");
921 >                op = addarg(op, "-aa .1 -ad 1536 -as 768");
922                  break;
923          case HIGH:
924 <                op = addarg(op, "-aa .08 -ad 1024 -as 512");
924 >                op = addarg(op, "-aa .075 -ad 4096 -as 2048");
925                  break;
926          }
927          d = ambval();
928          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
929          op += strlen(op);
930 <        op = addarg(op, "-lr 12 -lw .0005");
787 <        if (vdef(RENDER))
788 <                op = addarg(op, vval(RENDER));
930 >        op = addarg(op, "-lr 12 -lw 1e-5");
931   }
932  
933  
934 < xferopts(ro)                            /* transfer options if indicated */
935 < char    *ro;
934 > #ifdef _WIN32
935 > static void
936 > setenv(                 /* set an environment variable */
937 >        char    *vname,
938 >        char    *value
939 > )
940   {
941 +        char    *evp;
942 +
943 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
944 +        if (evp == NULL)
945 +                syserr(progname);
946 +        sprintf(evp, "%s=%s", vname, value);
947 +        if (putenv(evp) != 0) {
948 +                fprintf(stderr, "%s: out of environment space\n", progname);
949 +                quit(1);
950 +        }
951 +        if (!silent)
952 +                printf("set %s\n", evp);
953 + }
954 + #endif
955 +
956 +
957 + static void
958 + xferopts(                               /* transfer options if indicated */
959 +        char    *ro
960 + )
961 + {
962          int     fd, n;
963 <        register char   *cp;
963 >        char    *cp;
964          
965          n = strlen(ro);
966          if (n < 2)
# Line 811 | Line 978 | char   *ro;
978                          syserr(vval(OPTFILE));
979                  sprintf(ro, " @%s", vval(OPTFILE));
980          }
981 < #ifdef MSDOS
981 > #ifdef _WIN32
982          else if (n > 50) {
983                  setenv("ROPT", ro+1);
984                  strcpy(ro, " $ROPT");
# Line 820 | Line 987 | char   *ro;
987   }
988  
989  
990 < pfiltopts(po)                           /* get pfilt options */
991 < register char   *po;
990 > static void
991 > pfiltopts(                              /* get pfilt options */
992 >        char    *po
993 > )
994   {
995          *po = '\0';
996          if (vdef(EXPOSURE)) {
# Line 830 | Line 999 | register char  *po;
999          }
1000          switch (vscale(QUALITY)) {
1001          case MEDIUM:
1002 <                po = addarg(po, "-r 1");
1002 >                po = addarg(po, "-r .6");
1003                  break;
1004          case HIGH:
1005                  po = addarg(po, "-m .25");
1006                  break;
1007          }
1008          if (vdef(PFILT))
1009 <                po = addarg(po, vval(PFILT));
1009 >                if (vval(PFILT)[0] != '-') {
1010 >                        atos(c_pfilt, sizeof(c_pfilt), vval(PFILT));
1011 >                        po = addarg(po, sskip2(vval(PFILT), 1));
1012 >                } else
1013 >                        po = addarg(po, vval(PFILT));
1014   }
1015  
1016  
1017 < matchword(s1, s2)                       /* match white-delimited words */
1018 < register char   *s1, *s2;
1017 > static int
1018 > matchword(                      /* match white-delimited words */
1019 >        char    *s1,
1020 >        char    *s2
1021 > )
1022   {
1023          while (isspace(*s1)) s1++;
1024          while (isspace(*s2)) s2++;
# Line 853 | Line 1029 | register char  *s1, *s2;
1029   }
1030  
1031  
1032 < char *
1033 < specview(vs)                            /* get proper view spec from vs */
1034 < register char   *vs;
1032 > static char *
1033 > specview(                               /* get proper view spec from vs */
1034 >        char    *vs
1035 > )
1036   {
1037          static char     vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0",
1038                          "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"};
1039          static char     viewopts[128];
1040 <        register char   *cp;
1040 >        char    *cp;
1041          int     xpos, ypos, zpos, viewtype, upax;
1042 <        register int    i;
1042 >        int     i;
1043          double  cent[3], dim[3], mult, d;
1044  
1045          if (vs == NULL || *vs == '-')
# Line 873 | Line 1050 | register char  *vs;
1050                          upax = 1-'X'+UPPER(vval(UP)[1]);
1051                  else
1052                          upax = 1-'X'+vlet(UP);
1053 <                if (upax < 1 | upax > 3)
1053 >                if ((upax < 1) | (upax > 3))
1054                          badvalue(UP);
1055                  if (vval(UP)[0] == '-')
1056                          upax = -upax;
# Line 895 | Line 1072 | register char  *vs;
1072          } else if (*vs == 'z') {
1073                  zpos = -1; vs++;
1074          }
1075 <        viewtype = 'v';
1076 <        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c')
1075 >        switch (*vs) {
1076 >        case VT_PER:
1077 >        case VT_PAR:
1078 >        case VT_ANG:
1079 >        case VT_HEM:
1080 >        case VT_PLS:
1081 >        case VT_CYL:
1082                  viewtype = *vs++;
1083 +                break;
1084 +        default:
1085 +                viewtype = VT_PER;
1086 +                break;
1087 +        }
1088          cp = viewopts;
1089          if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
1090                  *cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype;
# Line 912 | Line 1099 | register char  *vs;
1099                          cent[i] += .5*dim[i];
1100                  }
1101                  mult = vlet(ZONE)=='E' ? 2. : .45 ;
1102 <                sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g",
1102 >                sprintf(cp, " -vp %.3g %.3g %.3g -vd %.3g %.3g %.3g",
1103                                  cent[0]+xpos*mult*dim[0],
1104                                  cent[1]+ypos*mult*dim[1],
1105                                  cent[2]+zpos*mult*dim[2],
# Line 939 | Line 1126 | register char  *vs;
1126                  }
1127                  cp = addarg(cp, vup[upax+3]);
1128                  switch (viewtype) {
1129 <                case 'v':
1129 >                case VT_PER:
1130                          cp = addarg(cp, "-vh 45 -vv 45");
1131                          break;
1132 <                case 'l':
1132 >                case VT_PAR:
1133                          d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]);
1134 <                        sprintf(cp, " -vh %.2g -vv %.2g", d, d);
1134 >                        sprintf(cp, " -vh %.3g -vv %.3g", d, d);
1135                          cp += strlen(cp);
1136                          break;
1137 <                case 'a':
1138 <                case 'h':
1137 >                case VT_ANG:
1138 >                case VT_HEM:
1139 >                case VT_PLS:
1140                          cp = addarg(cp, "-vh 180 -vv 180");
1141                          break;
1142 <                case 'c':
1142 >                case VT_CYL:
1143                          cp = addarg(cp, "-vh 180 -vv 90");
1144                          break;
1145                  }
# Line 959 | Line 1147 | register char  *vs;
1147                  while (!isspace(*vs))           /* else skip id */
1148                          if (!*vs++)
1149                                  return(NULL);
1150 <                if (upax) {                     /* specify up vector */
1150 >                if (upax) {                     /* prepend up vector */
1151                          strcpy(cp, vup[upax+3]);
1152                          cp += strlen(cp);
1153                  }
# Line 967 | Line 1155 | register char  *vs;
1155          if (cp == viewopts)             /* append any additional options */
1156                  vs++;           /* skip prefixed space if unneeded */
1157          strcpy(cp, vs);
1158 < #ifdef MSDOS
1158 > #ifdef _WIN32
1159          if (strlen(viewopts) > 40) {
1160                  setenv("VIEW", viewopts);
1161                  return("$VIEW");
# Line 977 | Line 1165 | register char  *vs;
1165   }
1166  
1167  
1168 < char *
1169 < getview(n, vn)                          /* get view n, or NULL if none */
1170 < int     n;
1171 < char    *vn;            /* returned view name */
1168 > static char *
1169 > getview(                                /* get view n, or NULL if none */
1170 >        int     n,
1171 >        char    *vn             /* returned view name */
1172 > )
1173   {
1174 <        register char   *mv;
1174 >        char    *mv;
1175  
1176          if (viewselect != NULL) {               /* command-line selected */
1177                  if (n)                          /* only do one */
1178                          return(NULL);
1179 +                                        
1180 +                if (isint(viewselect)) {        /* view number? */
1181 +                        n = atoi(viewselect)-1;
1182 +                        goto numview;
1183 +                }
1184                  if (viewselect[0] == '-') {     /* already specified */
1185 <                        if (vn != NULL) *vn = '\0';
1185 >                        if (vn != NULL)
1186 >                                strcpy(vn, "0");
1187                          return(viewselect);
1188                  }
1189                  if (vn != NULL) {
# Line 997 | Line 1192 | char   *vn;            /* returned view name */
1192                                  ;
1193                          *vn = '\0';
1194                  }
1000                                                /* view number? */
1001                if (isint(viewselect))
1002                        return(specview(nvalue(VIEW, atoi(viewselect)-1)));
1195                                                  /* check list */
1196 <                while ((mv = nvalue(VIEW, n++)) != NULL)
1196 >                while ((mv = nvalue(VIEWS, n++)) != NULL)
1197                          if (matchword(viewselect, mv))
1198                                  return(specview(mv));
1199 +
1200                  return(specview(viewselect));   /* standard view? */
1201          }
1202 <        mv = nvalue(VIEW, n);           /* use view n */
1203 <        if (vn != NULL & mv != NULL) {
1204 <                register char   *mv2 = mv;
1205 <                if (*mv2 != '-')
1202 > numview:
1203 >        mv = nvalue(VIEWS, n);          /* use view n */
1204 >        if ((vn != NULL) & (mv != NULL))
1205 >                if (*mv != '-') {
1206 >                        char    *mv2 = mv;
1207                          while (*mv2 && !isspace(*mv2))
1208                                  *vn++ = *mv2++;
1209 <                *vn = '\0';
1210 <        }
1209 >                        *vn = '\0';
1210 >                } else
1211 >                        sprintf(vn, "%d", n+1);
1212 >
1213          return(specview(mv));
1214   }
1215  
1216  
1217 < printview(vopts)                        /* print out selected view */
1218 < register char   *vopts;
1217 > static int
1218 > myprintview(                    /* print out selected view */
1219 >        char    *vopts,
1220 >        FILE    *fp
1221 > )
1222   {
1223 <        extern char     *atos(), *getenv();
1224 <        char    buf[256];
1225 <        FILE    *fp;
1226 <        register char   *cp;
1227 <
1223 >        VIEW    vwr;
1224 >        char    buf[128];
1225 >        char    *cp;
1226 > #ifdef _WIN32
1227 > /* XXX Should we allow something like this for all platforms? */
1228 > /* XXX Or is it still required at all? */
1229 > again:
1230 > #endif
1231          if (vopts == NULL)
1232                  return(-1);
1233 <        fputs("VIEW=", stdout);
1234 <        do {
1235 <                if (matchword(vopts, "-vf")) {          /* expand view file */
1236 <                        vopts = sskip(vopts);
1237 <                        if (!*atos(buf, sizeof(buf), vopts))
1036 <                                return(-1);
1037 <                        if ((fp = fopen(buf, "r")) == NULL)
1038 <                                return(-1);
1039 <                        for (buf[sizeof(buf)-2] = '\n';
1040 <                                        fgets(buf, sizeof(buf), fp) != NULL &&
1041 <                                                buf[0] != '\n';
1042 <                                        buf[sizeof(buf)-2] = '\n') {
1043 <                                if (buf[sizeof(buf)-2] != '\n') {
1044 <                                        ungetc(buf[sizeof(buf)-2], fp);
1045 <                                        buf[sizeof(buf)-2] = '\0';
1046 <                                }
1047 <                                if (matchword(buf, "VIEW=") ||
1048 <                                                matchword(buf, "rview")) {
1049 <                                        for (cp = sskip(buf); *cp && *cp != '\n'; cp++)
1050 <                                                putchar(*cp);
1051 <                                }
1052 <                        }
1053 <                        fclose(fp);
1054 <                        vopts = sskip(vopts);
1055 <                } else {
1056 <                        while (isspace(*vopts))
1057 <                                vopts++;
1058 <                        putchar(' ');
1059 < #ifdef MSDOS
1060 <                        if (*vopts == '$') {            /* expand env. var. */
1061 <                                if (!*atos(buf, sizeof(buf), vopts+1))
1062 <                                        return(-1);
1063 <                                if ((cp = getenv(buf)) == NULL)
1064 <                                        return(-1);
1065 <                                fputs(cp, stdout);
1066 <                                vopts = sskip(vopts);
1067 <                        } else
1233 > #ifdef _WIN32
1234 >        if (vopts[0] == '$') {
1235 >                vopts = getenv(vopts+1);
1236 >                goto again;
1237 >        }
1238   #endif
1239 <                                while (*vopts && !isspace(*vopts))
1240 <                                        putchar(*vopts++);
1241 <                }
1242 <        } while (*vopts++);
1243 <        putchar('\n');
1239 >        vwr = stdview;
1240 >        sscanview(&vwr, cp=vopts);              /* set initial options */
1241 >        while ((cp = strstr(cp, "-vf ")) != NULL &&
1242 >                        *atos(buf, sizeof(buf), cp += 4)) {
1243 >                viewfile(buf, &vwr, NULL);      /* load -vf file */
1244 >                sscanview(&vwr, cp);            /* reset tail */
1245 >        }
1246 >        fputs(VIEWSTR, fp);
1247 >        fprintview(&vwr, fp);                   /* print full spec. */
1248 >        fputc('\n', fp);
1249          return(0);
1250   }
1251  
1252  
1253 < rview(opts, po)                         /* run rview with first view */
1254 < char    *opts, *po;
1253 > static void
1254 > rvu(                            /* run rvu with first view */
1255 >        char    *opts,
1256 >        char    *po
1257 > )
1258   {
1259          char    *vw;
1260 <        char    combuf[512];
1260 >        char    combuf[PATH_MAX];
1261                                          /* build command */
1262          if (touchonly || (vw = getview(0, NULL)) == NULL)
1263                  return;
1264          if (sayview)
1265 <                printview(vw);
1266 <        sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname);
1265 >                myprintview(vw, stdout);
1266 >        sprintf(combuf, "%s %s%s%s -R %s ", c_rvu, vw, opts, po, rifname);
1267 >        if (nprocs > 1)
1268 >                sprintf(combuf+strlen(combuf), "-n %d ", nprocs);
1269          if (rvdevice != NULL)
1270                  sprintf(combuf+strlen(combuf), "-o %s ", rvdevice);
1271          if (vdef(EXPOSURE))
1272                  sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1273          strcat(combuf, oct1name);
1274          if (runcom(combuf)) {           /* run it */
1275 <                fprintf(stderr, "%s: error running rview\n", progname);
1275 >                fprintf(stderr, "%s: error running %s\n", progname, c_rvu);
1276                  quit(1);
1277          }
1278   }
1279  
1280  
1281 < rpict(opts, po)                         /* run rpict and pfilt for each view */
1282 < char    *opts, *po;
1281 > static int
1282 > syncf_done(                     /* check if an rpiece sync file is complete */
1283 >        char *sfname
1284 > )
1285   {
1286 <        char    combuf[1024];
1287 <        char    rawfile[MAXPATH], picfile[MAXPATH];
1288 <        char    zopt[MAXPATH+4], rep[MAXPATH+16], res[32];
1286 >        FILE    *fp = fopen(sfname, "r");
1287 >        int     todo = 1;
1288 >        int     x, y;
1289 >
1290 >        if (fp == NULL)
1291 >                return(0);
1292 >        if (fscanf(fp, "%d %d", &x, &y) != 2)
1293 >                goto checked;
1294 >        todo = x*y;             /* total number of tiles */
1295 >        if (fscanf(fp, "%d %d", &x, &y) != 2 || (x != 0) | (y != 0))
1296 >                goto checked;
1297 >                                /* XXX assume no redundant tiles */
1298 >        while (fscanf(fp, "%d %d", &x, &y) == 2)
1299 >                if (!--todo)
1300 >                        break;
1301 > checked:
1302 >        fclose(fp);
1303 >        return(!todo);
1304 > }
1305 >
1306 >
1307 > static void
1308 > rpict(                          /* run rpict and pfilt for each view */
1309 >        char    *opts,
1310 >        char    *po
1311 > )
1312 > {
1313 > #define do_rpiece       (sfile[0]!='\0')
1314 >        char    combuf[5*PATH_MAX+512];
1315 >        char    rawfile[PATH_MAX], picfile[PATH_MAX];
1316 >        char    zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32];
1317 >        char    rppopt[32], sfile[PATH_MAX], *pfile = NULL;
1318          char    pfopts[128];
1319          char    vs[32], *vw;
1320          int     vn, mult;
1321 +        FILE    *fp;
1322          time_t  rfdt, pfdt;
1323 +        int     xres, yres;
1324 +        double  aspect;
1325 +        int     n;
1326                                          /* get pfilt options */
1327          pfiltopts(pfopts);
1328                                          /* get resolution, reporting */
# Line 1122 | Line 1337 | char   *opts, *po;
1337                  mult = 3;
1338                  break;
1339          }
1340 <        {
1341 <                int     xres, yres;
1342 <                double  aspect;
1343 <                int     n;
1344 <                n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect);
1345 <                if (n == 3)
1346 <                        sprintf(res, "-x %d -y %d -pa %.3f",
1347 <                                        mult*xres, mult*yres, aspect);
1348 <                else if (n) {
1349 <                        if (n == 1) yres = xres;
1135 <                        sprintf(res, "-x %d -y %d", mult*xres, mult*yres);
1136 <                } else
1137 <                        badvalue(RESOLUTION);
1138 <        }
1340 >        n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect);
1341 >        if (n == 3)
1342 >                sprintf(res, "-x %d -y %d -pa %.3f",
1343 >                                mult*xres, mult*yres, aspect);
1344 >        else if (n) {
1345 >                aspect = 1.;
1346 >                if (n == 1) yres = xres;
1347 >                sprintf(res, "-x %d -y %d", mult*xres, mult*yres);
1348 >        } else
1349 >                badvalue(RESOLUTION);
1350          rep[0] = '\0';
1351          if (vdef(REPORT)) {
1352                  double  minutes;
1142                int     n;
1353                  n = sscanf(vval(REPORT), "%lf %s", &minutes, rawfile);
1354                  if (n == 2)
1355                          sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile);
# Line 1148 | Line 1358 | char   *opts, *po;
1358                  else
1359                          badvalue(REPORT);
1360          }
1361 <                                        /* do each view */
1362 <        vn = 0;
1361 >                                        /* set up parallel rendering */
1362 >        sfile[0] = '\0';
1363 >        if ((nprocs > 1) & !touchonly & !vdef(ZFILE) &&
1364 >                                        getview(0, vs) != NULL) {
1365 >                if (!strcmp(c_rpict, DEF_RPICT_PATH) &&
1366 >                                getview(1, NULL) == NULL) {
1367 >                        sprintf(sfile, "%s_%s_rpsync.txt",
1368 >                                vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE),
1369 >                                        vs);
1370 >                        strcpy(rppopt, "-PP pfXXXXXX");
1371 >                } else {
1372 >                        strcpy(rppopt, "-S 1 -PP pfXXXXXX");
1373 >                }
1374 >                pfile = rppopt + strlen(rppopt) - 8;
1375 >                if (mktemp(pfile) == NULL) {
1376 >                        if (do_rpiece) {
1377 >                                fprintf(stderr, "%s: cannot create\n", pfile);
1378 >                                quit(1);
1379 >                        }
1380 >                        pfile = NULL;
1381 >                }
1382 >        }
1383 >        vn = 0;                                 /* do each view */
1384          while ((vw = getview(vn++, vs)) != NULL) {
1385                  if (sayview)
1386 <                        printview(vw);
1387 <                if (!vs[0])
1157 <                        sprintf(vs, "%d", vn);
1158 <                sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1386 >                        myprintview(vw, stdout);
1387 >                sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs);
1388                  if (vdef(ZFILE))
1389                          sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1390                  else
# Line 1176 | Line 1405 | char   *opts, *po;
1405                                  touch(picfile);
1406                          continue;
1407                  }
1408 +                                                /* parallel running? */
1409 +                if (do_rpiece) {
1410 +                        if (rfdt < oct1date || !fdate(sfile)) {
1411 +                                int     xdiv = 8+nprocs/3, ydiv = 8+nprocs/3;
1412 +                                if (rfdt >= oct1date) {
1413 +                                        fprintf(stderr,
1414 +                "%s: partial output not created with %s\n", rawfile, c_rpiece);
1415 +                                        quit(1);
1416 +                                }
1417 +                                if (rfdt) {     /* start fresh */
1418 +                                        rmfile(rawfile);
1419 +                                        rfdt = 0;
1420 +                                }
1421 +                                if (!silent)
1422 +                                        printf("\techo %d %d > %s\n",
1423 +                                                        xdiv, ydiv, sfile);
1424 +                                if ((fp = fopen(sfile, "w")) == NULL) {
1425 +                                        fprintf(stderr, "%s: cannot create\n",
1426 +                                                        sfile);
1427 +                                        quit(1);
1428 +                                }
1429 +                                fprintf(fp, "%d %d\n", xdiv, ydiv);
1430 +                                fclose(fp);
1431 +                        }
1432 +                } else if (next_process(0)) {
1433 +                        if (pfile != NULL)
1434 +                                sleep(10);
1435 +                        continue;
1436 +                } else if (!inchild())
1437 +                        pfile = NULL;
1438 +                /* XXX Remember to call finish_process() */
1439                                                  /* build rpict command */
1440 <                if (rfdt >= oct1date)           /* recover */
1441 <                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1442 <                                rep, po, opts, zopt, rawfile, oct1name);
1443 <                else {
1440 >                if (rfdt >= oct1date) {         /* already in progress */
1441 >                        if (do_rpiece) {
1442 >                                sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s",
1443 >                                                c_rpiece, sfile, rppopt, rep, vw,
1444 >                                                res, opts, po, rawfile, oct1name);
1445 >                                while (next_process(1)) {
1446 >                                        sleep(10);
1447 >                                        combuf[strlen(c_rpiece)+2] = 'F';
1448 >                                }
1449 >                        } else
1450 >                                sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict,
1451 >                                        rep, opts, po, zopt, rawfile, oct1name);
1452 >                        if (runcom(combuf))     /* run rpict/rpiece */
1453 >                                goto rperror;
1454 >                } else {
1455                          if (overture) {         /* run overture calculation */
1456                                  sprintf(combuf,
1457 <                                "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1458 <                                                rep, vw, opts,
1457 >                                        "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1458 >                                                c_rpict, rep, vw, opts,
1459                                                  oct1name, overfile);
1460 <                                if (runcom(combuf)) {
1461 <                                        fprintf(stderr,
1460 >                                if (!do_rpiece || !next_process(0)) {
1461 >                                        if (runcom(combuf)) {
1462 >                                                fprintf(stderr,
1463                                          "%s: error in overture for view %s\n",
1464 <                                                progname, vs);
1465 <                                        quit(1);
1466 <                                }
1467 < #ifdef NIX
1468 <                                rmfile(overfile);
1464 >                                                        progname, vs);
1465 >                                                quit(1);
1466 >                                        }
1467 > #ifndef NULL_DEVICE
1468 >                                        rmfile(overfile);
1469   #endif
1470 +                                } else if (do_rpiece)
1471 +                                        sleep(20);
1472                          }
1473 <                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1474 <                                        rep, vw, res, po, opts, zopt,
1475 <                                        oct1name, rawfile);
1473 >                        if (do_rpiece) {
1474 >                                sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s",
1475 >                                                c_rpiece, sfile, rppopt, rep, vw,
1476 >                                                res, opts, po, rawfile, oct1name);
1477 >                                while (next_process(1))
1478 >                                        sleep(10);
1479 >                        } else {
1480 >                                sprintf(combuf, "%s%s %s %s%s%s%s %s > %s",
1481 >                                                c_rpict, rep, vw, res, opts, po,
1482 >                                                zopt, oct1name, rawfile);
1483 >                        }
1484 >                        if ((pfile != NULL) & !do_rpiece) {
1485 >                                if (!silent)
1486 >                                        printf("\t%s\n", combuf);
1487 >                                fflush(stdout);
1488 >                                sprintf(combuf, "%s%s %s %s%s%s %s > %s",
1489 >                                                c_rpict, rep, rppopt, res,
1490 >                                                opts, po, oct1name, rawfile);
1491 >                                fp = popen(combuf, "w");
1492 >                                if (fp == NULL)
1493 >                                        goto rperror;
1494 >                                myprintview(vw, fp);
1495 >                                if (pclose(fp))
1496 >                                        goto rperror;
1497 >                        } else if (runcom(combuf))
1498 >                                goto rperror;
1499                  }
1500 <                if (runcom(combuf)) {           /* run rpict */
1501 <                        fprintf(stderr, "%s: error rendering view %s\n",
1502 <                                        progname, vs);
1503 <                        quit(1);
1500 >                if (do_rpiece) {                /* need to finish raw, first */
1501 >                        finish_process();
1502 >                        wait_process(1);
1503 >                        if (!syncf_done(sfile)) {
1504 >                                fprintf(stderr,
1505 >                        "%s: %s did not complete rendering of view %s\n",
1506 >                                                progname, c_rpiece, vs);
1507 >                                quit(1);
1508 >                        }
1509                  }
1510                  if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1511                                                  /* build pfilt command */
1512 <                        if (mult > 1)
1513 <                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1514 <                                        pfopts, mult, mult, rawfile, picfile);
1512 >                        if (do_rpiece)
1513 >                                sprintf(combuf,
1514 >                                        "%s%s -x %d -y %d -p %.3f %s > %s",
1515 >                                        c_pfilt, pfopts, xres, yres, aspect,
1516 >                                        rawfile, picfile);
1517 >                        else if (mult > 1)
1518 >                                sprintf(combuf, "%s%s -x /%d -y /%d %s > %s",
1519 >                                        c_pfilt, pfopts, mult, mult,
1520 >                                        rawfile, picfile);
1521                          else
1522 <                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1523 <                                                rawfile, picfile);
1524 <                        if (runcom(combuf)) {           /* run pfilt */
1522 >                                sprintf(combuf, "%s%s %s > %s", c_pfilt,
1523 >                                        pfopts, rawfile, picfile);
1524 >                        if (runcom(combuf)) {   /* run pfilt */
1525                                  fprintf(stderr,
1526                                  "%s: error filtering view %s\n\t%s removed\n",
1527                                                  progname, vs, picfile);
# Line 1223 | Line 1531 | char   *opts, *po;
1531                  }
1532                                                  /* remove/rename raw file */
1533                  if (vdef(RAWFILE)) {
1534 <                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1534 >                        sprintf(combuf, "%s_%s.hdr", vval(RAWFILE), vs);
1535                          mvfile(rawfile, combuf);
1536                  } else
1537                          rmfile(rawfile);
1538 +                if (do_rpiece)                  /* done with sync file */
1539 +                        rmfile(sfile);
1540 +                else
1541 +                        finish_process();       /* exit if child */
1542          }
1543 +        wait_process(1);                /* wait for children to finish */
1544 +        if (pfile != NULL) {            /* clean up persistent rpict */
1545 +                RT_PID  pid;
1546 +                fp = fopen(pfile, "r");
1547 +                if (fp != NULL) {
1548 +                        if (fscanf(fp, "%*s %d", &pid) != 1 ||
1549 +                                        kill(pid, 1) < 0)
1550 +                                unlink(pfile);
1551 +                        fclose(fp);
1552 +                }
1553 +        }
1554 +        return;
1555 + rperror:
1556 +        fprintf(stderr, "%s: error rendering view %s\n", progname, vs);
1557 +        quit(1);
1558 + #undef do_rpiece
1559   }
1560  
1561  
1562 < touch(fn)                       /* update a file */
1563 < char    *fn;
1562 > static int
1563 > touch(                  /* update a file */
1564 >        char    *fn
1565 > )
1566   {
1567          if (!silent)
1568                  printf("\ttouch %s\n", fn);
1569 <        if (noaction)
1569 >        if (!nprocs)
1570                  return(0);
1241 #ifdef notused
1242        if (access(fn, F_OK) == -1)             /* create it */
1243                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1244                        return(-1);
1245 #endif
1571          return(setfdate(fn, time((time_t *)NULL)));
1572   }
1573  
1574  
1575 < runcom(cs)                      /* run command */
1576 < char    *cs;
1575 > static int
1576 > runcom(                 /* run command */
1577 >        char    *cs
1578 > )
1579   {
1580          if (!silent)            /* echo it */
1581                  printf("\t%s\n", cs);
1582 <        if (noaction)
1582 >        if (!nprocs)
1583                  return(0);
1584 <        fflush(stdout);         /* flush output and pass to shell */
1584 >        fflush(NULL);           /* flush output and pass to shell */
1585          return(system(cs));
1586   }
1587  
1588  
1589 < rmfile(fn)                      /* remove a file */
1590 < char    *fn;
1589 > static int
1590 > rmfile(                 /* remove a file */
1591 >        char    *fn
1592 > )
1593   {
1594          if (!silent)
1595 < #ifdef MSDOS
1596 <                printf("\tdel %s\n", fn);
1268 < #else
1269 <                printf("\trm -f %s\n", fn);
1270 < #endif
1271 <        if (noaction)
1595 >                printf("\t%s %s\n", DELCMD, fn);
1596 >        if (!nprocs)
1597                  return(0);
1598          return(unlink(fn));
1599   }
1600  
1601  
1602 < mvfile(fold, fnew)              /* move a file */
1603 < char    *fold, *fnew;
1602 > static int
1603 > mvfile(         /* move a file */
1604 >        char    *fold,
1605 >        char    *fnew
1606 > )
1607   {
1608          if (!silent)
1609 < #ifdef MSDOS
1610 <                printf("\trename %s %s\n", fold, fnew);
1283 < #else
1284 <                printf("\tmv %s %s\n", fold, fnew);
1285 < #endif
1286 <        if (noaction)
1609 >                printf("\t%s %s %s\n", RENAMECMD, fold, fnew);
1610 >        if (!nprocs)
1611                  return(0);
1612          return(rename(fold, fnew));
1613   }
1614  
1615  
1616 < #ifdef MSDOS
1617 < setenv(vname, value)            /* set an environment variable */
1618 < char    *vname, *value;
1616 > #ifdef RHAS_FORK_EXEC
1617 > static int
1618 > next_process(int reserve)               /* fork the next process */
1619   {
1620 <        register char   *evp;
1620 >        RT_PID  child_pid;
1621  
1622 <        evp = bmalloc(strlen(vname)+strlen(value)+2);
1623 <        if (evp == NULL)
1624 <                syserr(progname);
1625 <        sprintf(evp, "%s=%s", vname, value);
1626 <        if (putenv(evp) != 0) {
1303 <                fprintf(stderr, "%s: out of environment space\n", progname);
1622 >        if (nprocs <= 1)
1623 >                return(0);              /* it's us or no one */
1624 >        if (inchild()) {
1625 >                fprintf(stderr, "%s: internal error 1 in next_process()\n",
1626 >                                progname);
1627                  quit(1);
1628          }
1629 <        if (!silent)
1630 <                printf("set %s\n", evp);
1629 >        if (reserve > 0 && children_running >= nprocs-reserve)
1630 >                return(0);              /* caller holding back process(es) */
1631 >        if (children_running >= nprocs)
1632 >                wait_process(0);        /* wait for someone to finish */
1633 >        fflush(NULL);                   /* flush output */
1634 >        child_pid = fork();             /* split process */
1635 >        if (child_pid == 0) {           /* we're the child */
1636 >                children_running = -1;
1637 >                nprocs = 1;
1638 >                return(0);
1639 >        }
1640 >        if (child_pid > 0) {            /* we're the parent */
1641 >                ++children_running;
1642 >                return(1);
1643 >        }
1644 >        fprintf(stderr, "%s: warning -- fork() failed\n", progname);
1645 >        return(0);
1646   }
1309 #endif
1647  
1648 + static void
1649 + wait_process(                   /* wait for process(es) to finish */
1650 +        int     all
1651 + )
1652 + {
1653 +        int     ourstatus = 0, status;
1654 +        RT_PID  pid;
1655  
1656 < badvalue(vc)                    /* report bad variable value and exit */
1657 < int     vc;
1656 >        if (all)
1657 >                all = children_running;
1658 >        else if (children_running > 0)
1659 >                all = 1;
1660 >        while (all-- > 0) {
1661 >                pid = wait(&status);
1662 >                if (pid < 0)
1663 >                        syserr(progname);
1664 >                status = status>>8 & 0xff;
1665 >                --children_running;
1666 >                if (status != 0) {      /* child's problem is our problem */
1667 >                        if ((ourstatus == 0) & (children_running > 0))
1668 >                                fprintf(stderr, "%s: waiting for remaining processes\n",
1669 >                                                progname);
1670 >                        ourstatus = status;
1671 >                        all = children_running;
1672 >                }
1673 >        }
1674 >        if (ourstatus != 0)
1675 >                quit(ourstatus);        /* bad status from child */
1676 > }
1677 > #else   /* ! RHAS_FORK_EXEC */
1678 > static int
1679 > next_process(int reserve)
1680   {
1681 +        return(0);                      /* cannot start new process */
1682 + }
1683 + static void
1684 + wait_process(all)
1685 + int     all;
1686 + {
1687 +        (void)all;                      /* no one to wait for */
1688 + }
1689 + int
1690 + kill(pid, sig) /* win|unix_process.c should also wait and kill */
1691 + RT_PID pid;
1692 + int sig;
1693 + {
1694 +        return 0;
1695 + }
1696 + #endif  /* ! RHAS_FORK_EXEC */
1697 +
1698 + static void
1699 + finish_process(void)                    /* exit a child process */
1700 + {
1701 +        if (!inchild())
1702 +                return;                 /* in parent -- noop */
1703 +        exit(0);
1704 + }
1705 +
1706 +
1707 + static void
1708 + badvalue(                       /* report bad variable value and exit */
1709 +        int     vc
1710 + )
1711 + {
1712          fprintf(stderr, "%s: bad value for variable '%s'\n",
1713                          progname, vnam(vc));
1714          quit(1);
1715   }
1716  
1717  
1718 < syserr(s)                       /* report a system error and exit */
1719 < char    *s;
1718 > static void
1719 > syserr(                 /* report a system error and exit */
1720 >        char    *s
1721 > )
1722   {
1723          perror(s);
1724          quit(1);
1725   }
1726  
1727  
1728 + void
1729   quit(ec)                        /* exit program */
1730   int     ec;
1731   {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines