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.88 by greg, Fri Dec 5 00:51:59 2008 UTC vs.
Revision 2.114 by greg, Wed May 27 13:29:57 2015 UTC

# Line 24 | Line 24 | static const char      RCSid[] = "$Id$";
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 35 | Line 36 | static const char      RCSid[] = "$Id$";
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 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 */
39 > #define MKPMAP          8               /* mkpmap options */
40 > #define OBJECT          9               /* object files */
41 > #define OCONV           10              /* oconv options */
42 > #define OCTREE          11              /* octree file name */
43 > #define OPTFILE         12              /* rendering options file */
44 > #define PCMAP           13              /* caustic photon map */
45 > #define PENUMBRAS       14              /* shadow penumbras are desired */
46 > #define PFILT           15              /* pfilt options */
47 > #define PGMAP           16              /* global photon map */
48 > #define PICTURE         17              /* picture file root name */
49 > #define QUALITY         18              /* desired rendering quality */
50 > #define RAWFILE         19              /* raw picture file root name */
51 > #define RENDER          20              /* rendering options */
52 > #define REPORT          21              /* report frequency and errfile */
53 > #define RESOLUTION      22              /* maximum picture resolution */
54 > #define RPICT           23              /* rpict parameters */
55 > #define RVU             24              /* rvu parameters */
56 > #define SCENE           25              /* scene files */
57 > #define UP              26              /* view up (X, Y or Z) */
58 > #define VARIABILITY     27              /* level of light variability */
59 > #define VIEWS           28              /* view(s) for picture(s) */
60 > #define ZFILE           29              /* distance file root name */
61 > #define ZONE            30              /* simulation zone */
62                                  /* total number of variables */
63 < int NVARS = 26;
63 > int NVARS = 31;
64  
65   VARIABLE        vv[] = {                /* variable-value pairs */
66          {"AMBFILE",     3,      0,      NULL,   onevalue},
# Line 65 | Line 71 | VARIABLE       vv[] = {                /* variable-value pairs */
71          {"INDIRECT",    3,      0,      NULL,   intvalue},
72          {"materials",   3,      0,      NULL,   catvalues},
73          {"mkillum",     3,      0,      NULL,   catvalues},
74 +        {"mkpmap",      3,      0,      NULL,   catvalues},
75          {"objects",     3,      0,      NULL,   catvalues},
76          {"oconv",       3,      0,      NULL,   catvalues},
77          {"OCTREE",      3,      0,      NULL,   onevalue},
78          {"OPTFILE",     3,      0,      NULL,   onevalue},
79 +        {"PCMAP",       2,      0,      NULL,   onevalue},
80          {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
81          {"pfilt",       2,      0,      NULL,   catvalues},
82 +        {"PGMAP",       2,      0,      NULL,   onevalue},
83          {"PICTURE",     3,      0,      NULL,   onevalue},
84          {"QUALITY",     3,      0,      NULL,   qualvalue},
85          {"RAWFILE",     3,      0,      NULL,   onevalue},
86          {"render",      3,      0,      NULL,   catvalues},
87          {"REPORT",      3,      0,      NULL,   onevalue},
88          {"RESOLUTION",  3,      0,      NULL,   onevalue},
89 +        {"rpict",       3,      0,      NULL,   catvalues},
90 +        {"rvu",         3,      0,      NULL,   catvalues},
91          {"scene",       3,      0,      NULL,   catvalues},
92          {"UP",          2,      0,      NULL,   onevalue},
93          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
# Line 103 | Line 114 | time_t oct0date;               /* date of pre-mkillum octree */
114   char    *oct1name;              /* name of post-mkillum octree */
115   time_t  oct1date;               /* date of post-mkillum octree (>= matdate) */
116  
117 + char    *pgmapname;             /* name of global photon map */
118 + time_t  pgmapdate;              /* date of global photon map (>= oct1date) */
119 + char    *pcmapname;             /* name of caustic photon map */
120 + time_t  pcmapdate;              /* date of caustic photon map (>= oct1date) */
121 +
122   int     nowarn = 0;             /* no warnings */
123   int     explicate = 0;          /* explicate variables */
124   int     silent = 0;             /* do work silently */
# Line 112 | Line 128 | int    sayview = 0;            /* print view out */
128   char    *rvdevice = NULL;       /* rvu output device */
129   char    *viewselect = NULL;     /* specific view only */
130  
131 + #define DEF_RPICT_PATH  "rpict"         /* default rpict path */
132 +
133 +                                /* command paths */
134 + char    c_oconv[256] = "oconv";
135 + char    c_mkillum[256] = "mkillum";
136 + char    c_mkpmap[256] = "mkpmap";
137 + char    c_rvu[256] = "rvu";
138 + char    c_rpict[256] = DEF_RPICT_PATH;
139 + char    c_rpiece[] = "rpiece";
140 + char    c_pfilt[256] = "pfilt";
141 +
142   int     overture = 0;           /* overture calculation needed */
143  
144   int     children_running = 0;   /* set negative in children */
# Line 130 | Line 157 | static void checkfiles(void);
157   static void getoctcube(double   org[3], double  *sizp);
158   static void setdefaults(void);
159   static void oconv(void);
160 + static void mkpmap(void);
161   static char * addarg(char       *op, char       *arg);
162   static void oconvopts(char      *oo);
163   static void mkillumopts(char    *mo);
164 + static void mkpmapopts(char     *mo);
165   static void checkambfile(void);
166   static double ambval(void);
167   static void renderopts(char     *op, char       *po);
# Line 151 | Line 180 | static int touch(char  *fn);
180   static int runcom(char  *cs);
181   static int rmfile(char  *fn);
182   static int mvfile(char  *fold, char     *fnew);
183 < static int next_process(void);
183 > static int next_process(int     reserve);
184   static void wait_process(int    all);
185   static void finish_process(void);
186   static void badvalue(int        vc);
# Line 207 | Line 236 | main(
236          if (i >= argc)
237                  goto userr;
238          rifname = argv[i];
210                                /* check command-line options */
211        if ((nprocs > 1) & (viewselect != NULL) & (rvdevice == NULL))
212                nprocs = 1;
239                                  /* assign Radiance root file name */
240          rootname(radname, rifname);
241                                  /* load variable values */
# Line 232 | Line 258 | main(
258                  printvars(stdout);
259                                  /* build octree (and run mkillum) */
260          oconv();
261 +                                /* run mkpmap if indicated */
262 +        mkpmap();
263                                  /* check date on ambient file */
264          checkambfile();
265                                  /* run simulation */
# Line 253 | Line 281 | userr:
281  
282   static void
283   rootname(               /* remove tail from end of fn */
284 <        register char   *rn,
285 <        register char   *fn
284 >        char    *rn,
285 >        char    *fn
286   )
287   {
288          char    *tp, *dp;
# Line 271 | Line 299 | rootname(              /* remove tail from end of fn */
299  
300   static time_t
301   checklast(                      /* check files and find most recent */
302 <        register char   *fnames
302 >        char    *fnames
303   )
304   {
305          char    thisfile[PATH_MAX];
# Line 301 | Line 329 | newfname(              /* create modified file name */
329          int     pred
330   )
331   {
332 <        register char   *cp;
333 <        register int    n;
332 >        char    *cp;
333 >        int     n;
334          int     suffix;
335  
336          n = 0; cp = orig; suffix = -1;          /* suffix position, length */
# Line 324 | Line 352 | newfname(              /* create modified file name */
352   static void
353   checkfiles(void)                        /* check for existence and modified times */
354   {
355 +        char    fntemp[256];
356          time_t  objdate;
357  
358          if (!vdef(OCTREE)) {
# Line 353 | Line 382 | checkfiles(void)                       /* check for existence and modified
382                                  vnam(OCTREE), vnam(SCENE), vnam(ILLUM));
383                  quit(1);
384          }
385 +        if (vdef(PGMAP)) {
386 +                if (!*sskip2(vval(PGMAP),1)) {
387 +                        fprintf(stderr, "%s: '%s' missing # photons argument\n",
388 +                                        progname, vnam(PGMAP));
389 +                        quit(1);
390 +                }
391 +                atos(fntemp, sizeof(fntemp), vval(PGMAP));
392 +                pgmapname = savqstr(fntemp);
393 +                pgmapdate = fdate(pgmapname);
394 +        }
395 +        if (vdef(PCMAP)) {
396 +                if (!*sskip2(vval(PCMAP),1)) {
397 +                        fprintf(stderr, "%s: '%s' missing # photons argument\n",
398 +                                        progname, vnam(PCMAP));
399 +                        quit(1);
400 +                }
401 +                atos(fntemp, sizeof(fntemp), vval(PCMAP));
402 +                pcmapname = savqstr(fntemp);
403 +                pcmapdate = fdate(pcmapname);
404 +        }
405          matdate = checklast(vval(MATERIAL));
406   }      
407  
# Line 367 | Line 416 | getoctcube(            /* get octree bounding cube */
416          double  min[3], max[3];
417          char    buf[1024];
418          FILE    *fp;
419 <        register int    i;
419 >        int     i;
420  
421          if (osiz <= FTINY) {
422                  if (!nprocs && fdate(oct1name) <
# Line 480 | Line 529 | oconv(void)                            /* run oconv and mkillum if necessary *
529                          touch(vval(OCTREE));
530                  else {                          /* build command */
531                          if (vdef(MATERIAL))
532 <                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
533 <                                                vval(MATERIAL), vval(SCENE),
534 <                                                vval(OCTREE));
532 >                                sprintf(combuf, "%s%s %s %s > %s", c_oconv,
533 >                                                ocopts, vval(MATERIAL),
534 >                                                vval(SCENE), vval(OCTREE));
535                          else
536 <                                sprintf(combuf, "oconv%s %s > %s", ocopts,
536 >                                sprintf(combuf, "%s%s %s > %s", c_oconv, ocopts,
537                                                  vval(SCENE), vval(OCTREE));
538                          
539                          if (runcom(combuf)) {           /* run it */
# Line 510 | Line 559 | oconv(void)                            /* run oconv and mkillum if necessary *
559                          touch(oct0name);
560                  else {                          /* build command */
561                          if (octreedate)
562 <                                sprintf(combuf, "oconv%s -i %s %s > %s", ocopts,
563 <                                        vval(OCTREE), vval(ILLUM), oct0name);
562 >                                sprintf(combuf, "%s%s -i %s %s > %s", c_oconv,
563 >                                        ocopts, vval(OCTREE),
564 >                                        vval(ILLUM), oct0name);
565                          else if (vdef(MATERIAL))
566 <                                sprintf(combuf, "oconv%s %s %s > %s", ocopts,
567 <                                        vval(MATERIAL), vval(ILLUM), oct0name);
518 <                        else
519 <                                sprintf(combuf, "oconv%s %s > %s", ocopts,
566 >                                sprintf(combuf, "%s%s %s %s > %s", c_oconv,
567 >                                        ocopts, vval(MATERIAL),
568                                          vval(ILLUM), oct0name);
569 +                        else
570 +                                sprintf(combuf, "%s%s %s > %s", c_oconv,
571 +                                        ocopts, vval(ILLUM), oct0name);
572                          if (runcom(combuf)) {           /* run it */
573                                  fprintf(stderr,
574                                  "%s: error generating octree\n\t%s removed\n",
# Line 537 | Line 588 | oconv(void)                            /* run oconv and mkillum if necessary *
588          else {
589                  mkillumopts(mkopts);            /* build mkillum command */
590                  mktemp(illumtmp);
591 <                sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts,
591 >                sprintf(combuf, "%s%s %s \"<\" %s > %s", c_mkillum, mkopts,
592                                  oct0name, vval(ILLUM), illumtmp);
593                  if (runcom(combuf)) {                   /* run it */
594 <                        fprintf(stderr, "%s: error running mkillum\n",
595 <                                        progname);
594 >                        fprintf(stderr, "%s: error running %s\n",
595 >                                        progname, c_mkillum);
596                          unlink(illumtmp);
597                          quit(1);
598                  }
599 +                rmfile(oct0name);
600                                                  /* make octree1 (frozen) */
601                  if (octreedate)
602 <                        sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts,
603 <                                vval(OCTREE), illumtmp, oct1name);
602 >                        sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv,
603 >                                ocopts, vval(OCTREE), illumtmp, oct1name);
604                  else if (vdef(MATERIAL))
605 <                        sprintf(combuf, "oconv%s -f %s %s > %s", ocopts,
606 <                                vval(MATERIAL), illumtmp, oct1name);
605 >                        sprintf(combuf, "%s%s -f %s %s > %s", c_oconv,
606 >                                ocopts, vval(MATERIAL), illumtmp, oct1name);
607                  else
608 <                        sprintf(combuf, "oconv%s -f %s > %s", ocopts,
608 >                        sprintf(combuf, "%s%s -f %s > %s", c_oconv, ocopts,
609                                  illumtmp, oct1name);
610                  if (runcom(combuf)) {           /* run it */
611                          fprintf(stderr,
# Line 571 | Line 623 | oconv(void)                            /* run oconv and mkillum if necessary *
623   }
624  
625  
626 + static void
627 + mkpmap(void)                    /* run mkpmap if indicated */
628 + {
629 +        char    combuf[2048], *cp;
630 +        time_t  tnow;
631 +                                /* nothing to do? */
632 +        if ((pgmapname == NULL) | (pgmapdate >= oct1date) &&
633 +                        (pcmapname == NULL) | (pcmapdate >= oct1date))
634 +                return;
635 +                                /* just update existing file dates? */
636 +        if (touchonly && (pgmapname == NULL) | (pgmapdate > 0) &&
637 +                        (pcmapname == NULL) | (pcmapdate > 0)) {
638 +                if (pgmapname != NULL)
639 +                        touch(pgmapname);
640 +                if (pcmapname != NULL)
641 +                        touch(pcmapname);
642 +        } else {                /* else need to (re)run pkpmap */
643 +                strcpy(combuf, c_mkpmap);
644 +                for (cp = combuf; *cp; cp++)
645 +                        ;
646 +                mkpmapopts(cp);
647 +                if (vdef(REPORT)) {
648 +                        char    errfile[256];
649 +                        int     n;
650 +                        double  minutes;
651 +                        n = sscanf(vval(REPORT), "%lf %s", &minutes, errfile);
652 +                        if (n == 2)
653 +                                sprintf(cp, " -t %d -e %s", (int)(minutes*60), errfile);
654 +                        else if (n == 1)
655 +                                sprintf(cp, " -t %d", (int)(minutes*60));
656 +                        else
657 +                                badvalue(REPORT);
658 +                }
659 +                if (pgmapname != NULL && pgmapdate < oct1date) {
660 +                        cp = addarg(cp, "-apg");
661 +                        addarg(cp, vval(PGMAP));
662 +                        cp = sskip(sskip(cp));  /* remove any bandwidth */
663 +                        *cp = '\0';
664 +                }
665 +                if (pcmapname != NULL && pcmapdate < oct1date) {
666 +                        cp = addarg(cp, "-apc");
667 +                        addarg(cp, vval(PCMAP));
668 +                        cp = sskip(sskip(cp));  /* remove any bandwidth */
669 +                        *cp = '\0';
670 +                }
671 +                cp = addarg(cp, oct1name);
672 +                if (runcom(combuf)) {
673 +                        fprintf(stderr, "%s: error running %s\n",
674 +                                        progname, c_mkpmap);
675 +                        if (pgmapname != NULL)
676 +                                unlink(pgmapname);
677 +                        if (pcmapname != NULL)
678 +                                unlink(pcmapname);
679 +                        quit(1);
680 +                }
681 +        }
682 +        tnow = time((time_t *)NULL);
683 +        if (pgmapname != NULL)
684 +                pgmapdate = tnow;
685 +        if (pcmapname != NULL)
686 +                pcmapdate = tnow;
687 +        oct1date = tnow;        /* trigger ambient file removal if needed */
688 + }
689 +
690 +
691   static char *
692 < addarg(                         /* add argument and advance pointer */
693 < register char   *op,
694 < register char   *arg
692 > addarg(                         /* append argument and advance pointer */
693 > char    *op,
694 > char    *arg
695   )
696   {
697 +        while (*op)
698 +                op++;
699          *op = ' ';
700          while ( (*++op = *arg++) )
701                  ;
# Line 586 | Line 705 | register char  *arg
705  
706   static void
707   oconvopts(                              /* get oconv options */
708 <        register char   *oo
708 >        char    *oo
709   )
710   {
711          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
712  
713          *oo = '\0';
714 <        if (vdef(OCONV))
715 <                addarg(oo, vval(OCONV));
714 >        if (!vdef(OCONV))
715 >                return;
716 >        if (vval(OCONV)[0] != '-') {
717 >                atos(c_oconv, sizeof(c_oconv), vval(OCONV));
718 >                oo = addarg(oo, sskip2(vval(OCONV), 1));
719 >        } else
720 >                oo = addarg(oo, vval(OCONV));
721   }
722  
723  
# Line 604 | Line 728 | mkillumopts(                           /* get mkillum options */
728   {
729          /* BEWARE:  This may be called via setdefaults(), so no assumptions */
730  
731 <        if (nprocs > 1) {
731 >        if (nprocs > 1)
732                  sprintf(mo, " -n %d", nprocs);
733 <                while (*mo)
610 <                        mo++;
611 <        } else
733 >        else
734                  *mo = '\0';
735 <        if (vdef(MKILLUM))
736 <                addarg(mo, vval(MKILLUM));
735 >        if (!vdef(MKILLUM))
736 >                return;
737 >        if (vval(MKILLUM)[0] != '-') {
738 >                atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM));
739 >                mo = addarg(mo, sskip2(vval(MKILLUM), 1));
740 >        } else
741 >                mo = addarg(mo, vval(MKILLUM));
742   }
743  
744  
745   static void
746 + mkpmapopts(                             /* get mkpmap options */
747 +        char    *mo
748 + )
749 + {
750 +        /* BEWARE:  This may be called via setdefaults(), so no assumptions */
751 +
752 +        *mo = '\0';
753 +        if (!vdef(MKPMAP))
754 +                return;
755 +        if (vval(MKPMAP)[0] != '-') {
756 +                atos(c_mkpmap, sizeof(c_mkpmap), vval(MKPMAP));
757 +                mo = addarg(mo, sskip2(vval(MKPMAP), 1));
758 +        } else
759 +                mo = addarg(mo, vval(MKPMAP));
760 + }
761 +
762 +
763 + static void
764   checkambfile(void)                      /* check date on ambient file */
765   {
766          time_t  afdate;
# Line 656 | Line 801 | renderopts(                    /* set rendering options */
801          char    *po
802   )
803   {
804 +        char    pmapf[256], *bw;
805 +
806          switch(vscale(QUALITY)) {
807          case LOW:
808                  lowqopts(op, po);
# Line 667 | Line 814 | renderopts(                    /* set rendering options */
814                  hiqopts(op, po);
815                  break;
816          }
817 +        if (vdef(PGMAP)) {
818 +                bw = sskip2(vval(PGMAP), 2);
819 +                atos(pmapf, sizeof(pmapf), vval(PGMAP));
820 +                op = addarg(addarg(op, "-ap"), pmapf);
821 +                if (atoi(bw) > 0) op = addarg(op, bw);
822 +        }
823 +        if (vdef(PCMAP)) {
824 +                bw = sskip2(vval(PCMAP), 2);
825 +                atos(pmapf, sizeof(pmapf), vval(PCMAP));
826 +                op = addarg(addarg(op, "-ap"), pmapf);
827 +                if (atoi(bw) > 0) op = addarg(op, bw);
828 +        }
829 +        if (vdef(RENDER))
830 +                op = addarg(op, vval(RENDER));
831 +        if (rvdevice != NULL) {
832 +                if (vdef(RVU))
833 +                        if (vval(RVU)[0] != '-') {
834 +                                atos(c_rvu, sizeof(c_rvu), vval(RVU));
835 +                                po = addarg(po, sskip2(vval(RVU), 1));
836 +                        } else
837 +                                po = addarg(po, vval(RVU));
838 +        } else {
839 +                if (vdef(RPICT))
840 +                        if (vval(RPICT)[0] != '-') {
841 +                                atos(c_rpict, sizeof(c_rpict), vval(RPICT));
842 +                                po = addarg(po, sskip2(vval(RPICT), 1));
843 +                        } else
844 +                                po = addarg(po, vval(RPICT));
845 +        }
846   }
847  
848  
849   static void
850   lowqopts(                       /* low quality rendering options */
851 <        register char   *op,
851 >        char    *op,
852          char    *po
853   )
854   {
# Line 713 | Line 889 | lowqopts(                      /* low quality rendering options */
889                  op = addarg(op, "-ds .4");
890          else
891                  op = addarg(op, "-ds 0");
892 <        op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5");
892 >        op = addarg(op, "-dt .2 -dc .25 -dr 0 -ss 0 -st .5");
893          if (vdef(AMBFILE)) {
894                  sprintf(op, " -af %s", vval(AMBFILE));
895                  op += strlen(op);
# Line 734 | Line 910 | lowqopts(                      /* low quality rendering options */
910          d = ambval();
911          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
912          op += strlen(op);
913 <        op = addarg(op, "-lr 6 -lw .01");
738 <        if (vdef(RENDER))
739 <                op = addarg(op, vval(RENDER));
913 >        op = addarg(op, "-lr 6 -lw .003");
914   }
915  
916  
917   static void
918   medqopts(                       /* medium quality rendering options */
919 <        register char   *op,
919 >        char    *op,
920          char    *po
921   )
922   {
# Line 787 | Line 961 | medqopts(                      /* medium quality rendering options */
961          }
962          po = addarg(po, "-pt .08");
963          if (vbool(PENUMBRAS))
964 <                op = addarg(op, "-ds .2 -dj .5");
964 >                op = addarg(op, "-ds .2 -dj .9");
965          else
966                  op = addarg(op, "-ds .3");
967 <        op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1");
967 >        op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss 1 -st .1");
968          if ( (overture = vint(INDIRECT)) ) {
969                  sprintf(op, " -ab %d", overture);
970                  op += strlen(op);
# Line 814 | Line 988 | medqopts(                      /* medium quality rendering options */
988          d = ambval();
989          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
990          op += strlen(op);
991 <        op = addarg(op, "-lr 8 -lw .002");
818 <        if (vdef(RENDER))
819 <                op = addarg(op, vval(RENDER));
991 >        op = addarg(op, "-lr 8 -lw 1e-4");
992   }
993  
994  
995   static void
996   hiqopts(                                /* high quality rendering options */
997 <        register char   *op,
997 >        char    *op,
998          char    *po
999   )
1000   {
# Line 867 | Line 1039 | hiqopts(                               /* high quality rendering options */
1039          }
1040          po = addarg(po, "-pt .04");
1041          if (vbool(PENUMBRAS))
1042 <                op = addarg(op, "-ds .1 -dj .65");
1042 >                op = addarg(op, "-ds .1 -dj .9");
1043          else
1044                  op = addarg(op, "-ds .2");
1045 <        op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01");
1045 >        op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 16 -st .01");
1046          sprintf(op, " -ab %d", overture=vint(INDIRECT)+1);
1047          op += strlen(op);
1048          if (vdef(AMBFILE)) {
# Line 892 | Line 1064 | hiqopts(                               /* high quality rendering options */
1064          d = ambval();
1065          sprintf(op, " -av %.2g %.2g %.2g", d, d, d);
1066          op += strlen(op);
1067 <        op = addarg(op, "-lr 12 -lw .0005");
896 <        if (vdef(RENDER))
897 <                op = addarg(op, vval(RENDER));
1067 >        op = addarg(op, "-lr 12 -lw 1e-5");
1068   }
1069  
1070  
1071 + #ifdef _WIN32
1072   static void
1073 + setenv(                 /* set an environment variable */
1074 +        char    *vname,
1075 +        char    *value
1076 + )
1077 + {
1078 +        char    *evp;
1079 +
1080 +        evp = bmalloc(strlen(vname)+strlen(value)+2);
1081 +        if (evp == NULL)
1082 +                syserr(progname);
1083 +        sprintf(evp, "%s=%s", vname, value);
1084 +        if (putenv(evp) != 0) {
1085 +                fprintf(stderr, "%s: out of environment space\n", progname);
1086 +                quit(1);
1087 +        }
1088 +        if (!silent)
1089 +                printf("set %s\n", evp);
1090 + }
1091 + #endif
1092 +
1093 +
1094 + static void
1095   xferopts(                               /* transfer options if indicated */
1096          char    *ro
1097   )
1098   {
1099          int     fd, n;
1100 <        register char   *cp;
1100 >        char    *cp;
1101          
1102          n = strlen(ro);
1103          if (n < 2)
# Line 933 | Line 1126 | xferopts(                              /* transfer options if indicated */
1126  
1127   static void
1128   pfiltopts(                              /* get pfilt options */
1129 <        register char   *po
1129 >        char    *po
1130   )
1131   {
1132          *po = '\0';
# Line 950 | Line 1143 | pfiltopts(                             /* get pfilt options */
1143                  break;
1144          }
1145          if (vdef(PFILT))
1146 <                po = addarg(po, vval(PFILT));
1146 >                if (vval(PFILT)[0] != '-') {
1147 >                        atos(c_pfilt, sizeof(c_pfilt), vval(PFILT));
1148 >                        po = addarg(po, sskip2(vval(PFILT), 1));
1149 >                } else
1150 >                        po = addarg(po, vval(PFILT));
1151   }
1152  
1153  
1154   static int
1155   matchword(                      /* match white-delimited words */
1156 <        register char   *s1,
1157 <        register char   *s2
1156 >        char    *s1,
1157 >        char    *s2
1158   )
1159   {
1160          while (isspace(*s1)) s1++;
# Line 971 | Line 1168 | matchword(                     /* match white-delimited words */
1168  
1169   static char *
1170   specview(                               /* get proper view spec from vs */
1171 <        register char   *vs
1171 >        char    *vs
1172   )
1173   {
1174          static char     vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0",
1175                          "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"};
1176          static char     viewopts[128];
1177 <        register char   *cp;
1177 >        char    *cp;
1178          int     xpos, ypos, zpos, viewtype, upax;
1179 <        register int    i;
1179 >        int     i;
1180          double  cent[3], dim[3], mult, d;
1181  
1182          if (vs == NULL || *vs == '-')
# Line 1039 | Line 1236 | specview(                              /* get proper view spec from vs */
1236                          cent[i] += .5*dim[i];
1237                  }
1238                  mult = vlet(ZONE)=='E' ? 2. : .45 ;
1239 <                sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g",
1239 >                sprintf(cp, " -vp %.3g %.3g %.3g -vd %.3g %.3g %.3g",
1240                                  cent[0]+xpos*mult*dim[0],
1241                                  cent[1]+ypos*mult*dim[1],
1242                                  cent[2]+zpos*mult*dim[2],
# Line 1071 | Line 1268 | specview(                              /* get proper view spec from vs */
1268                          break;
1269                  case VT_PAR:
1270                          d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]);
1271 <                        sprintf(cp, " -vh %.2g -vv %.2g", d, d);
1271 >                        sprintf(cp, " -vh %.3g -vv %.3g", d, d);
1272                          cp += strlen(cp);
1273                          break;
1274                  case VT_ANG:
# Line 1087 | Line 1284 | specview(                              /* get proper view spec from vs */
1284                  while (!isspace(*vs))           /* else skip id */
1285                          if (!*vs++)
1286                                  return(NULL);
1287 <                if (upax) {                     /* specify up vector */
1287 >                if (upax) {                     /* prepend up vector */
1288                          strcpy(cp, vup[upax+3]);
1289                          cp += strlen(cp);
1290                  }
# Line 1111 | Line 1308 | getview(                               /* get view n, or NULL if none */
1308          char    *vn             /* returned view name */
1309   )
1310   {
1311 <        register char   *mv;
1311 >        char    *mv;
1312  
1313          if (viewselect != NULL) {               /* command-line selected */
1314                  if (n)                          /* only do one */
1315                          return(NULL);
1316 +                                        
1317 +                if (isint(viewselect)) {        /* view number? */
1318 +                        n = atoi(viewselect)-1;
1319 +                        goto numview;
1320 +                }
1321                  if (viewselect[0] == '-') {     /* already specified */
1322 <                        if (vn != NULL) *vn = '\0';
1322 >                        if (vn != NULL)
1323 >                                strcpy(vn, "0");
1324                          return(viewselect);
1325                  }
1326                  if (vn != NULL) {
# Line 1126 | Line 1329 | getview(                               /* get view n, or NULL if none */
1329                                  ;
1330                          *vn = '\0';
1331                  }
1129                                                /* view number? */
1130                if (isint(viewselect))
1131                        return(specview(nvalue(VIEWS, atoi(viewselect)-1)));
1332                                                  /* check list */
1333                  while ((mv = nvalue(VIEWS, n++)) != NULL)
1334                          if (matchword(viewselect, mv))
1335                                  return(specview(mv));
1336 +
1337                  return(specview(viewselect));   /* standard view? */
1338          }
1339 + numview:
1340          mv = nvalue(VIEWS, n);          /* use view n */
1341 <        if ((vn != NULL) & (mv != NULL)) {
1342 <                register char   *mv2 = mv;
1343 <                if (*mv2 != '-')
1341 >        if ((vn != NULL) & (mv != NULL))
1342 >                if (*mv != '-') {
1343 >                        char    *mv2 = mv;
1344                          while (*mv2 && !isspace(*mv2))
1345                                  *vn++ = *mv2++;
1346 <                *vn = '\0';
1347 <        }
1346 >                        *vn = '\0';
1347 >                } else
1348 >                        sprintf(vn, "%d", n+1);
1349 >
1350          return(specview(mv));
1351   }
1352  
1353  
1354   static int
1355   myprintview(                    /* print out selected view */
1356 <        register char   *vopts,
1356 >        char    *vopts,
1357          FILE    *fp
1358   )
1359   {
1360          VIEW    vwr;
1361          char    buf[128];
1362 <        register char   *cp;
1362 >        char    *cp;
1363   #ifdef _WIN32
1364   /* XXX Should we allow something like this for all platforms? */
1365   /* XXX Or is it still required at all? */
# Line 1196 | Line 1400 | rvu(                           /* run rvu with first view */
1400                  return;
1401          if (sayview)
1402                  myprintview(vw, stdout);
1403 <        sprintf(combuf, "rvu %s%s%s -R %s ", vw, po, opts, rifname);
1403 >        sprintf(combuf, "%s %s%s%s -R %s ", c_rvu, vw, opts, po, rifname);
1404          if (nprocs > 1)
1405                  sprintf(combuf+strlen(combuf), "-n %d ", nprocs);
1406          if (rvdevice != NULL)
# Line 1205 | Line 1409 | rvu(                           /* run rvu with first view */
1409                  sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE));
1410          strcat(combuf, oct1name);
1411          if (runcom(combuf)) {           /* run it */
1412 <                fprintf(stderr, "%s: error running rvu\n", progname);
1412 >                fprintf(stderr, "%s: error running %s\n", progname, c_rvu);
1413                  quit(1);
1414          }
1415   }
1416  
1417  
1418 + static int
1419 + syncf_done(                     /* check if an rpiece sync file is complete */
1420 +        char *sfname
1421 + )
1422 + {
1423 +        FILE    *fp = fopen(sfname, "r");
1424 +        int     todo = 1;
1425 +        int     x, y;
1426 +
1427 +        if (fp == NULL)
1428 +                return(0);
1429 +        if (fscanf(fp, "%d %d", &x, &y) != 2)
1430 +                goto checked;
1431 +        todo = x*y;             /* total number of tiles */
1432 +        if (fscanf(fp, "%d %d", &x, &y) != 2 || (x != 0) | (y != 0))
1433 +                goto checked;
1434 +                                /* XXX assume no redundant tiles */
1435 +        while (fscanf(fp, "%d %d", &x, &y) == 2)
1436 +                if (!--todo)
1437 +                        break;
1438 + checked:
1439 +        fclose(fp);
1440 +        return(!todo);
1441 + }
1442 +
1443 +
1444   static void
1445   rpict(                          /* run rpict and pfilt for each view */
1446          char    *opts,
1447          char    *po
1448   )
1449   {
1450 <        char    combuf[PATH_MAX];
1450 > #define do_rpiece       (sfile[0]!='\0')
1451 >        char    combuf[5*PATH_MAX+512];
1452          char    rawfile[PATH_MAX], picfile[PATH_MAX];
1453          char    zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32];
1454 <        char    rppopt[128], *pfile = NULL;
1454 >        char    rppopt[32], sfile[PATH_MAX], *pfile = NULL;
1455          char    pfopts[128];
1456          char    vs[32], *vw;
1457          int     vn, mult;
1458          FILE    *fp;
1459          time_t  rfdt, pfdt;
1460 +        int     xres, yres;
1461 +        double  aspect;
1462 +        int     n;
1463                                          /* get pfilt options */
1464          pfiltopts(pfopts);
1465                                          /* get resolution, reporting */
# Line 1240 | Line 1474 | rpict(                         /* run rpict and pfilt for each view */
1474                  mult = 3;
1475                  break;
1476          }
1477 <        {
1478 <                int     xres, yres;
1479 <                double  aspect;
1480 <                int     n;
1481 <                n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect);
1482 <                if (n == 3)
1483 <                        sprintf(res, "-x %d -y %d -pa %.3f",
1484 <                                        mult*xres, mult*yres, aspect);
1485 <                else if (n) {
1486 <                        if (n == 1) yres = xres;
1253 <                        sprintf(res, "-x %d -y %d", mult*xres, mult*yres);
1254 <                } else
1255 <                        badvalue(RESOLUTION);
1256 <        }
1477 >        n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect);
1478 >        if (n == 3)
1479 >                sprintf(res, "-x %d -y %d -pa %.3f",
1480 >                                mult*xres, mult*yres, aspect);
1481 >        else if (n) {
1482 >                aspect = 1.;
1483 >                if (n == 1) yres = xres;
1484 >                sprintf(res, "-x %d -y %d", mult*xres, mult*yres);
1485 >        } else
1486 >                badvalue(RESOLUTION);
1487          rep[0] = '\0';
1488          if (vdef(REPORT)) {
1489                  double  minutes;
1260                int     n;
1490                  n = sscanf(vval(REPORT), "%lf %s", &minutes, rawfile);
1491                  if (n == 2)
1492                          sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile);
# Line 1267 | Line 1496 | rpict(                         /* run rpict and pfilt for each view */
1496                          badvalue(REPORT);
1497          }
1498                                          /* set up parallel rendering */
1499 <        if ((nprocs > 1) & (!vdef(ZFILE))) {
1500 <                strcpy(rppopt, "-S 1 -PP pfXXXXXX");
1501 <                pfile = rppopt+9;
1502 <                if (mktemp(pfile) == NULL)
1499 >        sfile[0] = '\0';
1500 >        if ((nprocs > 1) & !touchonly & !vdef(ZFILE) &&
1501 >                                        getview(0, vs) != NULL) {
1502 >                if (!strcmp(c_rpict, DEF_RPICT_PATH) &&
1503 >                                getview(1, NULL) == NULL) {
1504 >                        sprintf(sfile, "%s_%s_rpsync.txt",
1505 >                                vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE),
1506 >                                        vs);
1507 >                        strcpy(rppopt, "-PP pfXXXXXX");
1508 >                } else {
1509 >                        strcpy(rppopt, "-S 1 -PP pfXXXXXX");
1510 >                }
1511 >                pfile = rppopt + strlen(rppopt) - 8;
1512 >                if (mktemp(pfile) == NULL) {
1513 >                        if (do_rpiece) {
1514 >                                fprintf(stderr, "%s: cannot create\n", pfile);
1515 >                                quit(1);
1516 >                        }
1517                          pfile = NULL;
1518 +                }
1519          }
1520          vn = 0;                                 /* do each view */
1521          while ((vw = getview(vn++, vs)) != NULL) {
1522                  if (sayview)
1523                          myprintview(vw, stdout);
1280                if (!vs[0])
1281                        sprintf(vs, "%d", vn);
1524                  sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs);
1525                  if (vdef(ZFILE))
1526                          sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
# Line 1300 | Line 1542 | rpict(                         /* run rpict and pfilt for each view */
1542                                  touch(picfile);
1543                          continue;
1544                  }
1545 <                if (next_process()) {           /* parallel running? */
1545 >                                                /* parallel running? */
1546 >                if (do_rpiece) {
1547 >                        if (rfdt < oct1date || !fdate(sfile)) {
1548 >                                int     xdiv = 8+nprocs/3, ydiv = 8+nprocs/3;
1549 >                                if (rfdt >= oct1date) {
1550 >                                        fprintf(stderr,
1551 >                "%s: partial output not created with %s\n", rawfile, c_rpiece);
1552 >                                        quit(1);
1553 >                                }
1554 >                                if (rfdt) {     /* start fresh */
1555 >                                        rmfile(rawfile);
1556 >                                        rfdt = 0;
1557 >                                }
1558 >                                if (!silent)
1559 >                                        printf("\techo %d %d > %s\n",
1560 >                                                        xdiv, ydiv, sfile);
1561 >                                if ((fp = fopen(sfile, "w")) == NULL) {
1562 >                                        fprintf(stderr, "%s: cannot create\n",
1563 >                                                        sfile);
1564 >                                        quit(1);
1565 >                                }
1566 >                                fprintf(fp, "%d %d\n", xdiv, ydiv);
1567 >                                fclose(fp);
1568 >                        }
1569 >                } else if (next_process(0)) {
1570                          if (pfile != NULL)
1571 <                                sleep(20);
1571 >                                sleep(10);
1572                          continue;
1573 <                }
1573 >                } else if (!inchild())
1574 >                        pfile = NULL;
1575                  /* XXX Remember to call finish_process() */
1576                                                  /* build rpict command */
1577 <                if (rfdt >= oct1date) {         /* recover */
1578 <                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1579 <                                rep, po, opts, zopt, rawfile, oct1name);
1580 <                        if (runcom(combuf))     /* run rpict */
1577 >                if (rfdt >= oct1date) {         /* already in progress */
1578 >                        if (do_rpiece) {
1579 >                                sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s",
1580 >                                                c_rpiece, sfile, rppopt, rep, vw,
1581 >                                                res, opts, po, rawfile, oct1name);
1582 >                                while (next_process(1)) {
1583 >                                        sleep(10);
1584 >                                        combuf[strlen(c_rpiece)+2] = 'F';
1585 >                                }
1586 >                        } else
1587 >                                sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict,
1588 >                                        rep, opts, po, zopt, rawfile, oct1name);
1589 >                        if (runcom(combuf))     /* run rpict/rpiece */
1590                                  goto rperror;
1591                  } else {
1592                          if (overture) {         /* run overture calculation */
1593                                  sprintf(combuf,
1594 <                                "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1595 <                                                rep, vw, opts,
1594 >                                        "%s%s %s%s -x 64 -y 64 -ps 1 %s > %s",
1595 >                                                c_rpict, rep, vw, opts,
1596                                                  oct1name, overfile);
1597 <                                if (runcom(combuf)) {
1598 <                                        fprintf(stderr,
1597 >                                if (!do_rpiece || !next_process(0)) {
1598 >                                        if (runcom(combuf)) {
1599 >                                                fprintf(stderr,
1600                                          "%s: error in overture for view %s\n",
1601 <                                                progname, vs);
1602 <                                        quit(1);
1603 <                                }
1601 >                                                        progname, vs);
1602 >                                                quit(1);
1603 >                                        }
1604   #ifndef NULL_DEVICE
1605 <                                rmfile(overfile);
1605 >                                        rmfile(overfile);
1606   #endif
1607 +                                } else if (do_rpiece)
1608 +                                        sleep(20);
1609                          }
1610 <                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1611 <                                        rep, vw, res, po, opts,
1612 <                                        zopt, oct1name, rawfile);
1613 <                        if (pfile != NULL && inchild()) {
1614 <                                                /* rpict persistent mode */
1610 >                        if (do_rpiece) {
1611 >                                sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s",
1612 >                                                c_rpiece, sfile, rppopt, rep, vw,
1613 >                                                res, opts, po, rawfile, oct1name);
1614 >                                while (next_process(1))
1615 >                                        sleep(10);
1616 >                        } else {
1617 >                                sprintf(combuf, "%s%s %s %s%s%s%s %s > %s",
1618 >                                                c_rpict, rep, vw, res, opts, po,
1619 >                                                zopt, oct1name, rawfile);
1620 >                        }
1621 >                        if ((pfile != NULL) & !do_rpiece) {
1622                                  if (!silent)
1623                                          printf("\t%s\n", combuf);
1624                                  fflush(stdout);
1625 <                                sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1626 <                                                rep, rppopt, res, po, opts,
1627 <                                                oct1name, rawfile);
1625 >                                sprintf(combuf, "%s%s %s %s%s%s %s > %s",
1626 >                                                c_rpict, rep, rppopt, res,
1627 >                                                opts, po, oct1name, rawfile);
1628                                  fp = popen(combuf, "w");
1629                                  if (fp == NULL)
1630                                          goto rperror;
1631                                  myprintview(vw, fp);
1632                                  if (pclose(fp))
1633                                          goto rperror;
1634 <                        } else {                /* rpict normal mode */
1635 <                                if (runcom(combuf))
1636 <                                        goto rperror;
1634 >                        } else if (runcom(combuf))
1635 >                                goto rperror;
1636 >                }
1637 >                if (do_rpiece) {                /* need to finish raw, first */
1638 >                        finish_process();
1639 >                        wait_process(1);
1640 >                        if (!syncf_done(sfile)) {
1641 >                                fprintf(stderr,
1642 >                        "%s: %s did not complete rendering of view %s\n",
1643 >                                                progname, c_rpiece, vs);
1644 >                                quit(1);
1645                          }
1646                  }
1647                  if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1648                                                  /* build pfilt command */
1649 <                        if (mult > 1)
1650 <                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1651 <                                        pfopts, mult, mult, rawfile, picfile);
1649 >                        if (do_rpiece)
1650 >                                sprintf(combuf,
1651 >                                        "%s%s -x %d -y %d -p %.3f %s > %s",
1652 >                                        c_pfilt, pfopts, xres, yres, aspect,
1653 >                                        rawfile, picfile);
1654 >                        else if (mult > 1)
1655 >                                sprintf(combuf, "%s%s -x /%d -y /%d %s > %s",
1656 >                                        c_pfilt, pfopts, mult, mult,
1657 >                                        rawfile, picfile);
1658                          else
1659 <                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1660 <                                                rawfile, picfile);
1659 >                                sprintf(combuf, "%s%s %s > %s", c_pfilt,
1660 >                                        pfopts, rawfile, picfile);
1661                          if (runcom(combuf)) {   /* run pfilt */
1662                                  fprintf(stderr,
1663                                  "%s: error filtering view %s\n\t%s removed\n",
# Line 1372 | Line 1672 | rpict(                         /* run rpict and pfilt for each view */
1672                          mvfile(rawfile, combuf);
1673                  } else
1674                          rmfile(rawfile);
1675 <                finish_process();               /* exit if child */
1675 >                if (do_rpiece)                  /* done with sync file */
1676 >                        rmfile(sfile);
1677 >                else
1678 >                        finish_process();       /* exit if child */
1679          }
1680          wait_process(1);                /* wait for children to finish */
1681 <        if (pfile != NULL) {            /* clean up rpict persistent mode */
1681 >        if (pfile != NULL) {            /* clean up persistent rpict */
1682                  RT_PID  pid;
1683                  fp = fopen(pfile, "r");
1684                  if (fp != NULL) {
# Line 1389 | Line 1692 | rpict(                         /* run rpict and pfilt for each view */
1692   rperror:
1693          fprintf(stderr, "%s: error rendering view %s\n", progname, vs);
1694          quit(1);
1695 + #undef do_rpiece
1696   }
1697  
1698  
# Line 1401 | Line 1705 | touch(                 /* update a file */
1705                  printf("\ttouch %s\n", fn);
1706          if (!nprocs)
1707                  return(0);
1404 #ifdef notused
1405        if (access(fn, F_OK) == -1)             /* create it */
1406                if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1)
1407                        return(-1);
1408 #endif
1708          return(setfdate(fn, time((time_t *)NULL)));
1709   }
1710  
# Line 1453 | Line 1752 | mvfile(                /* move a file */
1752  
1753   #ifdef RHAS_FORK_EXEC
1754   static int
1755 < next_process(void)                      /* fork the next process (max. nprocs) */
1755 > next_process(int reserve)               /* fork the next process */
1756   {
1757          RT_PID  child_pid;
1758  
# Line 1464 | Line 1763 | next_process(void)                     /* fork the next process (max. np
1763                                  progname);
1764                  quit(1);
1765          }
1766 +        if (reserve > 0 && children_running >= nprocs-reserve)
1767 +                return(0);              /* caller holding back process(es) */
1768          if (children_running >= nprocs)
1769                  wait_process(0);        /* wait for someone to finish */
1770          fflush(NULL);                   /* flush output */
1771          child_pid = fork();             /* split process */
1772          if (child_pid == 0) {           /* we're the child */
1773                  children_running = -1;
1774 +                nprocs = 1;
1775                  return(0);
1776          }
1777          if (child_pid > 0) {            /* we're the parent */
# Line 1511 | Line 1813 | wait_process(                  /* wait for process(es) to finish */
1813   }
1814   #else   /* ! RHAS_FORK_EXEC */
1815   static int
1816 < next_process(void)
1816 > next_process(int reserve)
1817   {
1818          return(0);                      /* cannot start new process */
1819   }
# Line 1537 | Line 1839 | finish_process(void)                   /* exit a child process */
1839                  return;                 /* in parent -- noop */
1840          exit(0);
1841   }
1540
1541 #ifdef _WIN32
1542 setenv(vname, value)            /* set an environment variable */
1543 char    *vname, *value;
1544 {
1545        register char   *evp;
1546
1547        evp = bmalloc(strlen(vname)+strlen(value)+2);
1548        if (evp == NULL)
1549                syserr(progname);
1550        sprintf(evp, "%s=%s", vname, value);
1551        if (putenv(evp) != 0) {
1552                fprintf(stderr, "%s: out of environment space\n", progname);
1553                quit(1);
1554        }
1555        if (!silent)
1556                printf("set %s\n", evp);
1557 }
1558 #endif
1842  
1843  
1844   static void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines