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.75 by greg, Thu Jan 1 19:31:46 2004 UTC vs.
Revision 2.111 by greg, Sun Oct 26 17:35:53 2014 UTC

# Line 22 | Line 22 | static const char      RCSid[] = "$Id$";
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) */
# Line 45 | Line 48 | static const char      RCSid[] = "$Id$";
48   #define RENDER          17              /* rendering options */
49   #define REPORT          18              /* report frequency and errfile */
50   #define RESOLUTION      19              /* maximum picture resolution */
51 < #define SCENE           20              /* scene files */
52 < #define UP              21              /* view up (X, Y or Z) */
53 < #define VARIABILITY     22              /* level of light variability */
54 < #define VIEWS           23              /* view(s) for picture(s) */
55 < #define ZFILE           24              /* distance file root name */
56 < #define ZONE            25              /* simulation zone */
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 = 26;
60 > int NVARS = 28;
61  
62   VARIABLE        vv[] = {                /* variable-value pairs */
63          {"AMBFILE",     3,      0,      NULL,   onevalue},
# Line 75 | Line 80 | VARIABLE       vv[] = {                /* variable-value pairs */
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},
87          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
# Line 110 | Line 117 | int    sayview = 0;            /* print view out */
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 */
# Line 121 | Line 138 | char   radname[PATH_MAX];      /* root Radiance file name */
138  
139   #define inchild()       (children_running < 0)
140  
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 < main(argc, argv)
176 < int     argc;
177 < char    *argv[];
175 >
176 > int
177 > main(
178 >        int     argc,
179 >        char    *argv[]
180 > )
181   {
182          char    ropts[512];
183          char    popts[64];
# Line 169 | Line 222 | char   *argv[];
222          if (i >= argc)
223                  goto userr;
224          rifname = argv[i];
172                                /* check command-line options */
173        if ((nprocs > 1) & (viewselect != NULL))
174                nprocs = 1;
225                                  /* assign Radiance root file name */
226          rootname(radname, rifname);
227                                  /* load variable values */
# Line 209 | Line 259 | userr:
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  
# Line 227 | 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[PATH_MAX];
290          time_t  thisdate, lastdate = 0;
# Line 238 | Line 293 | register char  *fnames;
293                  return(0);
294          while ((fnames = nextword(thisfile, PATH_MAX, fnames)) != NULL) {
295                  if (thisfile[0] == '!' ||
296 <                                (thisfile[0] == '\\' && thisfile[1] == '!'))
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 249 | 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 <        register char   *cp;
317 <        register int    n;
316 >        char    *cp;
317 >        int     n;
318          int     suffix;
319  
320          n = 0; cp = orig; suffix = -1;          /* suffix position, length */
# Line 274 | 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 309 | 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   {
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 (!nprocs && fdate(oct1name) <
# Line 359 | Line 422 | double org[3], *sizp;
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], lim[3], size;
429          char    buf[128];
# Line 416 | 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[PATH_MAX], 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 427 | 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 457 | Line 522 | oconv()                                /* run oconv and mkillum if necessary */
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);
465 <                        else
466 <                                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 484 | 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 518 | 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++) )
599                  ;
# Line 529 | Line 601 | register char  *op, *arg;
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 568 | Line 656 | checkambfile()                 /* check date on ambient file */
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 581 | 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 598 | 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 642 | 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 663 | Line 774 | char   *po;
774          d = ambval();
775          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
776          op += strlen(op);
777 <        op = addarg(op, "-lr 6 -lw .01");
667 <        if (vdef(RENDER))
668 <                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 714 | 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");
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);
# Line 741 | Line 852 | char   *po;
852          d = ambval();
853          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
854          op += strlen(op);
855 <        op = addarg(op, "-lr 8 -lw .002");
745 <        if (vdef(RENDER))
746 <                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 792 | 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 817 | Line 928 | char   *po;
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");
821 <        if (vdef(RENDER))
822 <                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 854 | 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 871 | Line 1007 | register char  *po;
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 887 | 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 929 | 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 946 | 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 973 | 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 993 | 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 1011 | 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 1031 | Line 1193 | char   *vn;            /* returned view name */
1193                                  ;
1194                          *vn = '\0';
1195                  }
1034                                                /* view number? */
1035                if (isint(viewselect))
1036                        return(specview(nvalue(VIEWS, atoi(viewselect)-1)));
1196                                                  /* check list */
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 + numview:
1204          mv = nvalue(VIEWS, n);          /* use view n */
1205 <        if ((vn != NULL) & (mv != NULL)) {
1206 <                register char   *mv2 = mv;
1207 <                if (*mv2 != '-')
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 < int
1219 < myprintview(vopts, fp)                  /* print out selected view */
1220 < register char   *vopts;
1221 < FILE    *fp;
1218 > static int
1219 > myprintview(                    /* print out selected view */
1220 >        char    *vopts,
1221 >        FILE    *fp
1222 > )
1223   {
1224          VIEW    vwr;
1225          char    buf[128];
1226 <        register char   *cp;
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   #ifdef _WIN32
# Line 1083 | Line 1251 | again:
1251   }
1252  
1253  
1254 < rvu(opts, po)                           /* run rvu 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[PATH_MAX];
# Line 1093 | Line 1264 | char   *opts, *po;
1264                  return;
1265          if (sayview)
1266                  myprintview(vw, stdout);
1267 <        sprintf(combuf, "rvu %s%s%s -R %s ", vw, po, opts, rifname);
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 rvu\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[PATH_MAX];
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[128], *pfile = NULL;
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 1132 | 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;
1145 <                        sprintf(res, "-x %d -y %d", mult*xres, mult*yres);
1146 <                } else
1147 <                        badvalue(RESOLUTION);
1148 <        }
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;
1152                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 1159 | Line 1360 | char   *opts, *po;
1360                          badvalue(REPORT);
1361          }
1362                                          /* set up parallel rendering */
1363 <        if ((nprocs > 1) & (!vdef(ZFILE))) {
1364 <                strcpy(rppopt, "-S 1 -PP pfXXXXXX");
1365 <                pfile = rppopt+9;
1366 <                if (mktemp(pfile) == NULL)
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                          myprintview(vw, stdout);
1388 <                if (!vs[0])
1173 <                        sprintf(vs, "%d", vn);
1174 <                sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
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 1192 | Line 1406 | char   *opts, *po;
1406                                  touch(picfile);
1407                          continue;
1408                  }
1409 <                if (next_process()) {           /* parallel running? */
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(20);
1435 >                                sleep(10);
1436                          continue;
1437 <                }
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 <                        if (runcom(combuf))     /* run rpict */
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 <                                }
1465 >                                                        progname, vs);
1466 >                                                quit(1);
1467 >                                        }
1468   #ifndef NULL_DEVICE
1469 <                                rmfile(overfile);
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,
1476 <                                        zopt, oct1name, rawfile);
1477 <                        if (pfile != NULL && inchild()) {
1478 <                                                /* rpict persistent mode */
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);
1230                                sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1231                                                rep, rppopt, res, po, opts,
1232                                                oct1name, rawfile);
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 {                /* rpict normal mode */
1499 <                                if (runcom(combuf))
1500 <                                        goto rperror;
1498 >                        } else if (runcom(combuf))
1499 >                                goto rperror;
1500 >                }
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);
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",
# Line 1260 | 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 <                finish_process();               /* exit if child */
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 rpict persistent mode */
1546 <                int     pid;
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 ||
# Line 1281 | Line 1556 | char   *opts, *po;
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 (!nprocs)
1571                  return(0);
1294 #ifdef notused
1295        if (access(fn, F_OK) == -1)             /* create it */
1296                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1297                        return(-1);
1298 #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 (!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                  printf("\t%s %s\n", DELCMD, fn);
# Line 1323 | Line 1600 | char   *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                  printf("\t%s %s %s\n", RENAMECMD, fold, fnew);
# Line 1335 | Line 1615 | char   *fold, *fnew;
1615  
1616  
1617   #ifdef RHAS_FORK_EXEC
1618 < int
1619 < next_process()                  /* fork the next process (max. nprocs) */
1618 > static int
1619 > next_process(int reserve)               /* fork the next process */
1620   {
1621 <        int     child_pid;
1621 >        RT_PID  child_pid;
1622  
1623          if (nprocs <= 1)
1624                  return(0);              /* it's us or no one */
# Line 1347 | Line 1627 | next_process()                 /* fork the next process (max. nprocs
1627                                  progname);
1628                  quit(1);
1629          }
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(stdout);
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 */
# Line 1363 | Line 1646 | next_process()                 /* fork the next process (max. nprocs
1646          return(0);
1647   }
1648  
1649 < wait_process(all)                       /* wait for process(es) to finish */
1650 < int     all;
1649 > static void
1650 > wait_process(                   /* wait for process(es) to finish */
1651 >        int     all
1652 > )
1653   {
1654 <        int     ourstatus = 0;
1655 <        int     pid, status;
1654 >        int     ourstatus = 0, status;
1655 >        RT_PID  pid;
1656  
1657          if (all)
1658                  all = children_running;
# Line 1391 | Line 1676 | int    all;
1676                  quit(ourstatus);        /* bad status from child */
1677   }
1678   #else   /* ! RHAS_FORK_EXEC */
1679 < int
1680 < next_process()
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   {
# Line 1403 | Line 1689 | int    all;
1689   }
1690   int
1691   kill(pid, sig) /* win|unix_process.c should also wait and kill */
1692 < int pid, sig;
1692 > RT_PID pid;
1693 > int sig;
1694   {
1695          return 0;
1696   }
1697   #endif  /* ! RHAS_FORK_EXEC */
1698  
1699 < finish_process()                        /* exit a child process */
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  
1419 #ifdef _WIN32
1420 setenv(vname, value)            /* set an environment variable */
1421 char    *vname, *value;
1422 {
1423        register char   *evp;
1707  
1708 <        evp = bmalloc(strlen(vname)+strlen(value)+2);
1709 <        if (evp == NULL)
1710 <                syserr(progname);
1711 <        sprintf(evp, "%s=%s", vname, value);
1429 <        if (putenv(evp) != 0) {
1430 <                fprintf(stderr, "%s: out of environment space\n", progname);
1431 <                quit(1);
1432 <        }
1433 <        if (!silent)
1434 <                printf("set %s\n", evp);
1435 < }
1436 < #endif
1437 <
1438 <
1439 < badvalue(vc)                    /* report bad variable value and exit */
1440 < int     vc;
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));
# Line 1445 | Line 1716 | int    vc;
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);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines