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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines