9 |
|
|
10 |
|
#include <ctype.h> |
11 |
|
#include <time.h> |
12 |
+ |
#include <signal.h> |
13 |
|
|
14 |
|
#include "platform.h" |
15 |
|
#include "rtprocess.h" |
25 |
|
#define RENAMECMD "mv" |
26 |
|
#include <sys/types.h> |
27 |
|
#include <sys/wait.h> |
28 |
+ |
#include <signal.h> |
29 |
|
#endif |
30 |
|
|
31 |
|
/* variables (alphabetical by name) */ |
37 |
|
#define INDIRECT 5 /* indirection in lighting */ |
38 |
|
#define MATERIAL 6 /* material files */ |
39 |
|
#define MKILLUM 7 /* mkillum options */ |
40 |
< |
#define OBJECT 8 /* object files */ |
41 |
< |
#define OCONV 9 /* oconv options */ |
42 |
< |
#define OCTREE 10 /* octree file name */ |
43 |
< |
#define OPTFILE 11 /* rendering options file */ |
44 |
< |
#define PENUMBRAS 12 /* shadow penumbras are desired */ |
45 |
< |
#define PFILT 13 /* pfilt options */ |
46 |
< |
#define PICTURE 14 /* picture file root name */ |
47 |
< |
#define QUALITY 15 /* desired rendering quality */ |
48 |
< |
#define RAWFILE 16 /* raw picture file root name */ |
49 |
< |
#define RENDER 17 /* rendering options */ |
50 |
< |
#define REPORT 18 /* report frequency and errfile */ |
51 |
< |
#define RESOLUTION 19 /* maximum picture resolution */ |
52 |
< |
#define RPICT 20 /* rpict parameters */ |
53 |
< |
#define RVU 21 /* rvu parameters */ |
54 |
< |
#define SCENE 22 /* scene files */ |
55 |
< |
#define UP 23 /* view up (X, Y or Z) */ |
56 |
< |
#define VARIABILITY 24 /* level of light variability */ |
57 |
< |
#define VIEWS 25 /* view(s) for picture(s) */ |
58 |
< |
#define ZFILE 26 /* distance file root name */ |
59 |
< |
#define ZONE 27 /* simulation zone */ |
40 |
> |
#define MKPMAP 8 /* mkpmap options */ |
41 |
> |
#define OBJECT 9 /* object files */ |
42 |
> |
#define OCONV 10 /* oconv options */ |
43 |
> |
#define OCTREE 11 /* octree file name */ |
44 |
> |
#define OPTFILE 12 /* rendering options file */ |
45 |
> |
#define PCMAP 13 /* caustic photon map */ |
46 |
> |
#define PENUMBRAS 14 /* shadow penumbras are desired */ |
47 |
> |
#define PFILT 15 /* pfilt options */ |
48 |
> |
#define PGMAP 16 /* global photon map */ |
49 |
> |
#define PICTURE 17 /* picture file root name */ |
50 |
> |
#define QUALITY 18 /* desired rendering quality */ |
51 |
> |
#define RAWFILE 19 /* raw picture file root name */ |
52 |
> |
#define RENDER 20 /* rendering options */ |
53 |
> |
#define REPORT 21 /* report frequency and errfile */ |
54 |
> |
#define RESOLUTION 22 /* maximum picture resolution */ |
55 |
> |
#define RPICT 23 /* rpict parameters */ |
56 |
> |
#define RVU 24 /* rvu parameters */ |
57 |
> |
#define SCENE 25 /* scene files */ |
58 |
> |
#define UP 26 /* view up (X, Y or Z) */ |
59 |
> |
#define VARIABILITY 27 /* level of light variability */ |
60 |
> |
#define VIEWS 28 /* view(s) for picture(s) */ |
61 |
> |
#define ZFILE 29 /* distance file root name */ |
62 |
> |
#define ZONE 30 /* simulation zone */ |
63 |
|
/* total number of variables */ |
64 |
< |
int NVARS = 28; |
64 |
> |
int NVARS = 31; |
65 |
|
|
66 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
67 |
|
{"AMBFILE", 3, 0, NULL, onevalue}, |
72 |
|
{"INDIRECT", 3, 0, NULL, intvalue}, |
73 |
|
{"materials", 3, 0, NULL, catvalues}, |
74 |
|
{"mkillum", 3, 0, NULL, catvalues}, |
75 |
+ |
{"mkpmap", 3, 0, NULL, catvalues}, |
76 |
|
{"objects", 3, 0, NULL, catvalues}, |
77 |
|
{"oconv", 3, 0, NULL, catvalues}, |
78 |
|
{"OCTREE", 3, 0, NULL, onevalue}, |
79 |
|
{"OPTFILE", 3, 0, NULL, onevalue}, |
80 |
+ |
{"PCMAP", 2, 0, NULL, onevalue}, |
81 |
|
{"PENUMBRAS", 3, 0, NULL, boolvalue}, |
82 |
|
{"pfilt", 2, 0, NULL, catvalues}, |
83 |
+ |
{"PGMAP", 2, 0, NULL, onevalue}, |
84 |
|
{"PICTURE", 3, 0, NULL, onevalue}, |
85 |
|
{"QUALITY", 3, 0, NULL, qualvalue}, |
86 |
|
{"RAWFILE", 3, 0, NULL, onevalue}, |
115 |
|
char *oct1name; /* name of post-mkillum octree */ |
116 |
|
time_t oct1date; /* date of post-mkillum octree (>= matdate) */ |
117 |
|
|
118 |
+ |
char *pgmapname; /* name of global photon map */ |
119 |
+ |
time_t pgmapdate; /* date of global photon map (>= oct1date) */ |
120 |
+ |
char *pcmapname; /* name of caustic photon map */ |
121 |
+ |
time_t pcmapdate; /* date of caustic photon map (>= oct1date) */ |
122 |
+ |
|
123 |
|
int nowarn = 0; /* no warnings */ |
124 |
|
int explicate = 0; /* explicate variables */ |
125 |
|
int silent = 0; /* do work silently */ |
129 |
|
char *rvdevice = NULL; /* rvu output device */ |
130 |
|
char *viewselect = NULL; /* specific view only */ |
131 |
|
|
132 |
+ |
#define DEF_RPICT_PATH "rpict" /* default rpict path */ |
133 |
+ |
|
134 |
|
/* command paths */ |
135 |
|
char c_oconv[256] = "oconv"; |
136 |
|
char c_mkillum[256] = "mkillum"; |
137 |
+ |
char c_mkpmap[256] = "mkpmap"; |
138 |
|
char c_rvu[256] = "rvu"; |
139 |
< |
char c_rpict[256] = "rpict"; |
139 |
> |
char c_rpict[256] = DEF_RPICT_PATH; |
140 |
> |
char c_rpiece[] = "rpiece"; |
141 |
|
char c_pfilt[256] = "pfilt"; |
142 |
|
|
143 |
|
int overture = 0; /* overture calculation needed */ |
158 |
|
static void getoctcube(double org[3], double *sizp); |
159 |
|
static void setdefaults(void); |
160 |
|
static void oconv(void); |
161 |
+ |
static void mkpmap(void); |
162 |
|
static char * addarg(char *op, char *arg); |
163 |
|
static void oconvopts(char *oo); |
164 |
|
static void mkillumopts(char *mo); |
165 |
+ |
static void mkpmapopts(char *mo); |
166 |
|
static void checkambfile(void); |
167 |
|
static double ambval(void); |
168 |
|
static void renderopts(char *op, char *po); |
181 |
|
static int runcom(char *cs); |
182 |
|
static int rmfile(char *fn); |
183 |
|
static int mvfile(char *fold, char *fnew); |
184 |
< |
static int next_process(void); |
184 |
> |
static int next_process(int reserve); |
185 |
|
static void wait_process(int all); |
186 |
|
static void finish_process(void); |
187 |
|
static void badvalue(int vc); |
237 |
|
if (i >= argc) |
238 |
|
goto userr; |
239 |
|
rifname = argv[i]; |
221 |
– |
/* check command-line options */ |
222 |
– |
if ((nprocs > 1) & (viewselect != NULL) & (rvdevice == NULL)) |
223 |
– |
nprocs = 1; |
240 |
|
/* assign Radiance root file name */ |
241 |
|
rootname(radname, rifname); |
242 |
|
/* load variable values */ |
259 |
|
printvars(stdout); |
260 |
|
/* build octree (and run mkillum) */ |
261 |
|
oconv(); |
262 |
+ |
/* run mkpmap if indicated */ |
263 |
+ |
mkpmap(); |
264 |
|
/* check date on ambient file */ |
265 |
|
checkambfile(); |
266 |
|
/* run simulation */ |
282 |
|
|
283 |
|
static void |
284 |
|
rootname( /* remove tail from end of fn */ |
285 |
< |
register char *rn, |
286 |
< |
register char *fn |
285 |
> |
char *rn, |
286 |
> |
char *fn |
287 |
|
) |
288 |
|
{ |
289 |
|
char *tp, *dp; |
300 |
|
|
301 |
|
static time_t |
302 |
|
checklast( /* check files and find most recent */ |
303 |
< |
register char *fnames |
303 |
> |
char *fnames |
304 |
|
) |
305 |
|
{ |
306 |
|
char thisfile[PATH_MAX]; |
330 |
|
int pred |
331 |
|
) |
332 |
|
{ |
333 |
< |
register char *cp; |
334 |
< |
register int n; |
333 |
> |
char *cp; |
334 |
> |
int n; |
335 |
|
int suffix; |
336 |
|
|
337 |
|
n = 0; cp = orig; suffix = -1; /* suffix position, length */ |
353 |
|
static void |
354 |
|
checkfiles(void) /* check for existence and modified times */ |
355 |
|
{ |
356 |
+ |
char fntemp[256]; |
357 |
|
time_t objdate; |
358 |
|
|
359 |
|
if (!vdef(OCTREE)) { |
383 |
|
vnam(OCTREE), vnam(SCENE), vnam(ILLUM)); |
384 |
|
quit(1); |
385 |
|
} |
386 |
+ |
if (vdef(PGMAP)) { |
387 |
+ |
if (!*sskip2(vval(PGMAP),1)) { |
388 |
+ |
fprintf(stderr, "%s: '%s' missing # photons argument\n", |
389 |
+ |
progname, vnam(PGMAP)); |
390 |
+ |
quit(1); |
391 |
+ |
} |
392 |
+ |
atos(fntemp, sizeof(fntemp), vval(PGMAP)); |
393 |
+ |
pgmapname = savqstr(fntemp); |
394 |
+ |
pgmapdate = fdate(pgmapname); |
395 |
+ |
} |
396 |
+ |
if (vdef(PCMAP)) { |
397 |
+ |
if (!*sskip2(vval(PCMAP),1)) { |
398 |
+ |
fprintf(stderr, "%s: '%s' missing # photons argument\n", |
399 |
+ |
progname, vnam(PCMAP)); |
400 |
+ |
quit(1); |
401 |
+ |
} |
402 |
+ |
atos(fntemp, sizeof(fntemp), vval(PCMAP)); |
403 |
+ |
pcmapname = savqstr(fntemp); |
404 |
+ |
pcmapdate = fdate(pcmapname); |
405 |
+ |
} |
406 |
|
matdate = checklast(vval(MATERIAL)); |
407 |
|
} |
408 |
|
|
417 |
|
double min[3], max[3]; |
418 |
|
char buf[1024]; |
419 |
|
FILE *fp; |
420 |
< |
register int i; |
420 |
> |
int i; |
421 |
|
|
422 |
|
if (osiz <= FTINY) { |
423 |
|
if (!nprocs && fdate(oct1name) < |
597 |
|
unlink(illumtmp); |
598 |
|
quit(1); |
599 |
|
} |
600 |
+ |
rmfile(oct0name); |
601 |
|
/* make octree1 (frozen) */ |
602 |
|
if (octreedate) |
603 |
|
sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv, |
624 |
|
} |
625 |
|
|
626 |
|
|
627 |
+ |
static void |
628 |
+ |
mkpmap(void) /* run mkpmap if indicated */ |
629 |
+ |
{ |
630 |
+ |
char combuf[2048], *cp; |
631 |
+ |
time_t tnow; |
632 |
+ |
/* nothing to do? */ |
633 |
+ |
if ((pgmapname == NULL) | (pgmapdate >= oct1date) && |
634 |
+ |
(pcmapname == NULL) | (pcmapdate >= oct1date)) |
635 |
+ |
return; |
636 |
+ |
/* just update existing file dates? */ |
637 |
+ |
if (touchonly && (pgmapname == NULL) | (pgmapdate > 0) && |
638 |
+ |
(pcmapname == NULL) | (pcmapdate > 0)) { |
639 |
+ |
if (pgmapname != NULL) |
640 |
+ |
touch(pgmapname); |
641 |
+ |
if (pcmapname != NULL) |
642 |
+ |
touch(pcmapname); |
643 |
+ |
} else { /* else need to (re)run pkpmap */ |
644 |
+ |
strcpy(combuf, c_mkpmap); |
645 |
+ |
for (cp = combuf; *cp; cp++) |
646 |
+ |
; |
647 |
+ |
mkpmapopts(cp); |
648 |
+ |
/* force file overwrite */ |
649 |
+ |
cp = addarg(cp, "-fo+"); |
650 |
+ |
if (vdef(REPORT)) { |
651 |
+ |
char errfile[256]; |
652 |
+ |
int n; |
653 |
+ |
double minutes; |
654 |
+ |
n = sscanf(vval(REPORT), "%lf %s", &minutes, errfile); |
655 |
+ |
if (n == 2) |
656 |
+ |
sprintf(cp, " -t %d -e %s", (int)(minutes*60), errfile); |
657 |
+ |
else if (n == 1) |
658 |
+ |
sprintf(cp, " -t %d", (int)(minutes*60)); |
659 |
+ |
else |
660 |
+ |
badvalue(REPORT); |
661 |
+ |
} |
662 |
+ |
if (pgmapname != NULL && pgmapdate < oct1date) { |
663 |
+ |
cp = addarg(cp, "-apg"); |
664 |
+ |
addarg(cp, vval(PGMAP)); |
665 |
+ |
cp = sskip(sskip(cp)); /* remove any bandwidth */ |
666 |
+ |
*cp = '\0'; |
667 |
+ |
} |
668 |
+ |
if (pcmapname != NULL && pcmapdate < oct1date) { |
669 |
+ |
cp = addarg(cp, "-apc"); |
670 |
+ |
addarg(cp, vval(PCMAP)); |
671 |
+ |
cp = sskip(sskip(cp)); /* remove any bandwidth */ |
672 |
+ |
*cp = '\0'; |
673 |
+ |
} |
674 |
+ |
cp = addarg(cp, oct1name); |
675 |
+ |
if (runcom(combuf)) { |
676 |
+ |
fprintf(stderr, "%s: error running %s\n", |
677 |
+ |
progname, c_mkpmap); |
678 |
+ |
if (pgmapname != NULL && pgmapdate < oct1date) |
679 |
+ |
unlink(pgmapname); |
680 |
+ |
if (pcmapname != NULL && pcmapdate < oct1date) |
681 |
+ |
unlink(pcmapname); |
682 |
+ |
quit(1); |
683 |
+ |
} |
684 |
+ |
} |
685 |
+ |
tnow = time((time_t *)NULL); |
686 |
+ |
if (pgmapname != NULL) |
687 |
+ |
pgmapdate = tnow; |
688 |
+ |
if (pcmapname != NULL) |
689 |
+ |
pcmapdate = tnow; |
690 |
+ |
oct1date = tnow; /* trigger ambient file removal if needed */ |
691 |
+ |
} |
692 |
+ |
|
693 |
+ |
|
694 |
|
static char * |
695 |
|
addarg( /* append argument and advance pointer */ |
696 |
< |
register char *op, |
697 |
< |
register char *arg |
696 |
> |
char *op, |
697 |
> |
char *arg |
698 |
|
) |
699 |
|
{ |
700 |
|
while (*op) |
708 |
|
|
709 |
|
static void |
710 |
|
oconvopts( /* get oconv options */ |
711 |
< |
register char *oo |
711 |
> |
char *oo |
712 |
|
) |
713 |
|
{ |
714 |
|
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
715 |
|
|
716 |
|
*oo = '\0'; |
717 |
< |
if (vdef(OCONV)) |
718 |
< |
if (vval(OCONV)[0] != '-') { |
719 |
< |
atos(c_oconv, sizeof(c_oconv), vval(OCONV)); |
720 |
< |
oo = addarg(oo, sskip2(vval(OCONV), 1)); |
721 |
< |
} else |
722 |
< |
oo = addarg(oo, vval(OCONV)); |
717 |
> |
if (!vdef(OCONV)) |
718 |
> |
return; |
719 |
> |
if (vval(OCONV)[0] != '-') { |
720 |
> |
atos(c_oconv, sizeof(c_oconv), vval(OCONV)); |
721 |
> |
oo = addarg(oo, sskip2(vval(OCONV), 1)); |
722 |
> |
} else |
723 |
> |
oo = addarg(oo, vval(OCONV)); |
724 |
|
} |
725 |
|
|
726 |
|
|
735 |
|
sprintf(mo, " -n %d", nprocs); |
736 |
|
else |
737 |
|
*mo = '\0'; |
738 |
< |
if (vdef(MKILLUM)) |
739 |
< |
if (vval(MKILLUM)[0] != '-') { |
740 |
< |
atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM)); |
741 |
< |
mo = addarg(mo, sskip2(vval(MKILLUM), 1)); |
742 |
< |
} else |
743 |
< |
mo = addarg(mo, vval(MKILLUM)); |
738 |
> |
if (!vdef(MKILLUM)) |
739 |
> |
return; |
740 |
> |
if (vval(MKILLUM)[0] != '-') { |
741 |
> |
atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM)); |
742 |
> |
mo = addarg(mo, sskip2(vval(MKILLUM), 1)); |
743 |
> |
} else |
744 |
> |
mo = addarg(mo, vval(MKILLUM)); |
745 |
|
} |
746 |
|
|
747 |
|
|
748 |
|
static void |
749 |
+ |
mkpmapopts( /* get mkpmap options */ |
750 |
+ |
char *mo |
751 |
+ |
) |
752 |
+ |
{ |
753 |
+ |
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
754 |
+ |
|
755 |
+ |
*mo = '\0'; |
756 |
+ |
if (!vdef(MKPMAP)) |
757 |
+ |
return; |
758 |
+ |
if (vval(MKPMAP)[0] != '-') { |
759 |
+ |
atos(c_mkpmap, sizeof(c_mkpmap), vval(MKPMAP)); |
760 |
+ |
mo = addarg(mo, sskip2(vval(MKPMAP), 1)); |
761 |
+ |
} else |
762 |
+ |
mo = addarg(mo, vval(MKPMAP)); |
763 |
+ |
} |
764 |
+ |
|
765 |
+ |
|
766 |
+ |
static void |
767 |
|
checkambfile(void) /* check date on ambient file */ |
768 |
|
{ |
769 |
|
time_t afdate; |
804 |
|
char *po |
805 |
|
) |
806 |
|
{ |
807 |
+ |
char pmapf[256], *bw; |
808 |
+ |
|
809 |
+ |
if (vdef(PGMAP)) { |
810 |
+ |
*op = '\0'; |
811 |
+ |
bw = sskip2(vval(PGMAP), 2); |
812 |
+ |
atos(pmapf, sizeof(pmapf), vval(PGMAP)); |
813 |
+ |
op = addarg(addarg(op, "-ap"), pmapf); |
814 |
+ |
if (atoi(bw) > 0) op = addarg(op, bw); |
815 |
+ |
} |
816 |
|
switch(vscale(QUALITY)) { |
817 |
|
case LOW: |
818 |
|
lowqopts(op, po); |
824 |
|
hiqopts(op, po); |
825 |
|
break; |
826 |
|
} |
827 |
+ |
if (vdef(PCMAP)) { |
828 |
+ |
bw = sskip2(vval(PCMAP), 2); |
829 |
+ |
atos(pmapf, sizeof(pmapf), vval(PCMAP)); |
830 |
+ |
op = addarg(addarg(op, "-ap"), pmapf); |
831 |
+ |
if (atoi(bw) > 0) op = addarg(op, bw); |
832 |
+ |
} |
833 |
|
if (vdef(RENDER)) |
834 |
|
op = addarg(op, vval(RENDER)); |
835 |
|
if (rvdevice != NULL) { |
836 |
< |
if (vdef(RVU)) |
836 |
> |
if (vdef(RVU)) { |
837 |
|
if (vval(RVU)[0] != '-') { |
838 |
|
atos(c_rvu, sizeof(c_rvu), vval(RVU)); |
839 |
|
po = addarg(po, sskip2(vval(RVU), 1)); |
840 |
|
} else |
841 |
|
po = addarg(po, vval(RVU)); |
842 |
+ |
} |
843 |
|
} else { |
844 |
< |
if (vdef(RPICT)) |
844 |
> |
if (vdef(RPICT)) { |
845 |
|
if (vval(RPICT)[0] != '-') { |
846 |
|
atos(c_rpict, sizeof(c_rpict), vval(RPICT)); |
847 |
|
po = addarg(po, sskip2(vval(RPICT), 1)); |
848 |
|
} else |
849 |
|
po = addarg(po, vval(RPICT)); |
850 |
+ |
} |
851 |
|
} |
852 |
|
} |
853 |
|
|
854 |
|
|
855 |
|
static void |
856 |
|
lowqopts( /* low quality rendering options */ |
857 |
< |
register char *op, |
857 |
> |
char *op, |
858 |
|
char *po |
859 |
|
) |
860 |
|
{ |
895 |
|
op = addarg(op, "-ds .4"); |
896 |
|
else |
897 |
|
op = addarg(op, "-ds 0"); |
898 |
< |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); |
898 |
> |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -ss 0 -st .5"); |
899 |
|
if (vdef(AMBFILE)) { |
900 |
|
sprintf(op, " -af %s", vval(AMBFILE)); |
901 |
|
op += strlen(op); |
916 |
|
d = ambval(); |
917 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
918 |
|
op += strlen(op); |
919 |
< |
op = addarg(op, "-lr 6 -lw .01"); |
919 |
> |
op = addarg(op, "-lr 6 -lw .003"); |
920 |
|
} |
921 |
|
|
922 |
|
|
923 |
|
static void |
924 |
|
medqopts( /* medium quality rendering options */ |
925 |
< |
register char *op, |
925 |
> |
char *op, |
926 |
|
char *po |
927 |
|
) |
928 |
|
{ |
970 |
|
op = addarg(op, "-ds .2 -dj .9"); |
971 |
|
else |
972 |
|
op = addarg(op, "-ds .3"); |
973 |
< |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
973 |
> |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss 1 -st .1"); |
974 |
|
if ( (overture = vint(INDIRECT)) ) { |
975 |
|
sprintf(op, " -ab %d", overture); |
976 |
|
op += strlen(op); |
994 |
|
d = ambval(); |
995 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
996 |
|
op += strlen(op); |
997 |
< |
op = addarg(op, "-lr 8 -lw .002"); |
997 |
> |
op = addarg(op, "-lr 8 -lw 1e-4"); |
998 |
|
} |
999 |
|
|
1000 |
|
|
1001 |
|
static void |
1002 |
|
hiqopts( /* high quality rendering options */ |
1003 |
< |
register char *op, |
1003 |
> |
char *op, |
1004 |
|
char *po |
1005 |
|
) |
1006 |
|
{ |
1048 |
|
op = addarg(op, "-ds .1 -dj .9"); |
1049 |
|
else |
1050 |
|
op = addarg(op, "-ds .2"); |
1051 |
< |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
1051 |
> |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 16 -st .01"); |
1052 |
|
sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); |
1053 |
|
op += strlen(op); |
1054 |
|
if (vdef(AMBFILE)) { |
1070 |
|
d = ambval(); |
1071 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
1072 |
|
op += strlen(op); |
1073 |
< |
op = addarg(op, "-lr 12 -lw .0005"); |
1073 |
> |
op = addarg(op, "-lr 12 -lw 1e-5"); |
1074 |
|
} |
1075 |
|
|
1076 |
|
|
1077 |
+ |
#ifdef _WIN32 |
1078 |
|
static void |
1079 |
+ |
setenv( /* set an environment variable */ |
1080 |
+ |
char *vname, |
1081 |
+ |
char *value |
1082 |
+ |
) |
1083 |
+ |
{ |
1084 |
+ |
char *evp; |
1085 |
+ |
|
1086 |
+ |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
1087 |
+ |
if (evp == NULL) |
1088 |
+ |
syserr(progname); |
1089 |
+ |
sprintf(evp, "%s=%s", vname, value); |
1090 |
+ |
if (putenv(evp) != 0) { |
1091 |
+ |
fprintf(stderr, "%s: out of environment space\n", progname); |
1092 |
+ |
quit(1); |
1093 |
+ |
} |
1094 |
+ |
if (!silent) |
1095 |
+ |
printf("set %s\n", evp); |
1096 |
+ |
} |
1097 |
+ |
#endif |
1098 |
+ |
|
1099 |
+ |
|
1100 |
+ |
static void |
1101 |
|
xferopts( /* transfer options if indicated */ |
1102 |
|
char *ro |
1103 |
|
) |
1104 |
|
{ |
1105 |
|
int fd, n; |
1106 |
< |
register char *cp; |
1106 |
> |
char *cp; |
1107 |
|
|
1108 |
|
n = strlen(ro); |
1109 |
|
if (n < 2) |
1132 |
|
|
1133 |
|
static void |
1134 |
|
pfiltopts( /* get pfilt options */ |
1135 |
< |
register char *po |
1135 |
> |
char *po |
1136 |
|
) |
1137 |
|
{ |
1138 |
|
*po = '\0'; |
1148 |
|
po = addarg(po, "-m .25"); |
1149 |
|
break; |
1150 |
|
} |
1151 |
< |
if (vdef(PFILT)) |
1151 |
> |
if (vdef(PFILT)) { |
1152 |
|
if (vval(PFILT)[0] != '-') { |
1153 |
|
atos(c_pfilt, sizeof(c_pfilt), vval(PFILT)); |
1154 |
|
po = addarg(po, sskip2(vval(PFILT), 1)); |
1155 |
|
} else |
1156 |
|
po = addarg(po, vval(PFILT)); |
1157 |
+ |
} |
1158 |
|
} |
1159 |
|
|
1160 |
|
|
1161 |
|
static int |
1162 |
|
matchword( /* match white-delimited words */ |
1163 |
< |
register char *s1, |
1164 |
< |
register char *s2 |
1163 |
> |
char *s1, |
1164 |
> |
char *s2 |
1165 |
|
) |
1166 |
|
{ |
1167 |
|
while (isspace(*s1)) s1++; |
1175 |
|
|
1176 |
|
static char * |
1177 |
|
specview( /* get proper view spec from vs */ |
1178 |
< |
register char *vs |
1178 |
> |
char *vs |
1179 |
|
) |
1180 |
|
{ |
1181 |
|
static char vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0", |
1182 |
|
"-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"}; |
1183 |
|
static char viewopts[128]; |
1184 |
< |
register char *cp; |
1184 |
> |
char *cp; |
1185 |
|
int xpos, ypos, zpos, viewtype, upax; |
1186 |
< |
register int i; |
1186 |
> |
int i; |
1187 |
|
double cent[3], dim[3], mult, d; |
1188 |
|
|
1189 |
|
if (vs == NULL || *vs == '-') |
1243 |
|
cent[i] += .5*dim[i]; |
1244 |
|
} |
1245 |
|
mult = vlet(ZONE)=='E' ? 2. : .45 ; |
1246 |
< |
sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g", |
1246 |
> |
sprintf(cp, " -vp %.3g %.3g %.3g -vd %.3g %.3g %.3g", |
1247 |
|
cent[0]+xpos*mult*dim[0], |
1248 |
|
cent[1]+ypos*mult*dim[1], |
1249 |
|
cent[2]+zpos*mult*dim[2], |
1275 |
|
break; |
1276 |
|
case VT_PAR: |
1277 |
|
d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]); |
1278 |
< |
sprintf(cp, " -vh %.2g -vv %.2g", d, d); |
1278 |
> |
sprintf(cp, " -vh %.3g -vv %.3g", d, d); |
1279 |
|
cp += strlen(cp); |
1280 |
|
break; |
1281 |
|
case VT_ANG: |
1291 |
|
while (!isspace(*vs)) /* else skip id */ |
1292 |
|
if (!*vs++) |
1293 |
|
return(NULL); |
1294 |
< |
if (upax) { /* specify up vector */ |
1294 |
> |
if (upax) { /* prepend up vector */ |
1295 |
|
strcpy(cp, vup[upax+3]); |
1296 |
|
cp += strlen(cp); |
1297 |
|
} |
1315 |
|
char *vn /* returned view name */ |
1316 |
|
) |
1317 |
|
{ |
1318 |
< |
register char *mv; |
1318 |
> |
char *mv; |
1319 |
|
|
1320 |
|
if (viewselect != NULL) { /* command-line selected */ |
1321 |
|
if (n) /* only do one */ |
1322 |
|
return(NULL); |
1323 |
+ |
|
1324 |
+ |
if (isint(viewselect)) { /* view number? */ |
1325 |
+ |
n = atoi(viewselect)-1; |
1326 |
+ |
goto numview; |
1327 |
+ |
} |
1328 |
|
if (viewselect[0] == '-') { /* already specified */ |
1329 |
< |
if (vn != NULL) *vn = '\0'; |
1329 |
> |
if (vn != NULL) |
1330 |
> |
strcpy(vn, "0"); |
1331 |
|
return(viewselect); |
1332 |
|
} |
1333 |
|
if (vn != NULL) { |
1336 |
|
; |
1337 |
|
*vn = '\0'; |
1338 |
|
} |
1165 |
– |
/* view number? */ |
1166 |
– |
if (isint(viewselect)) |
1167 |
– |
return(specview(nvalue(VIEWS, atoi(viewselect)-1))); |
1339 |
|
/* check list */ |
1340 |
|
while ((mv = nvalue(VIEWS, n++)) != NULL) |
1341 |
|
if (matchword(viewselect, mv)) |
1342 |
|
return(specview(mv)); |
1343 |
+ |
|
1344 |
|
return(specview(viewselect)); /* standard view? */ |
1345 |
|
} |
1346 |
+ |
numview: |
1347 |
|
mv = nvalue(VIEWS, n); /* use view n */ |
1348 |
|
if ((vn != NULL) & (mv != NULL)) { |
1349 |
< |
register char *mv2 = mv; |
1350 |
< |
if (*mv2 != '-') |
1349 |
> |
if (*mv != '-') { |
1350 |
> |
char *mv2 = mv; |
1351 |
|
while (*mv2 && !isspace(*mv2)) |
1352 |
|
*vn++ = *mv2++; |
1353 |
< |
*vn = '\0'; |
1353 |
> |
*vn = '\0'; |
1354 |
> |
} else |
1355 |
> |
sprintf(vn, "%d", n+1); |
1356 |
|
} |
1357 |
|
return(specview(mv)); |
1358 |
|
} |
1360 |
|
|
1361 |
|
static int |
1362 |
|
myprintview( /* print out selected view */ |
1363 |
< |
register char *vopts, |
1363 |
> |
char *vopts, |
1364 |
|
FILE *fp |
1365 |
|
) |
1366 |
|
{ |
1367 |
|
VIEW vwr; |
1368 |
|
char buf[128]; |
1369 |
< |
register char *cp; |
1369 |
> |
char *cp; |
1370 |
|
#ifdef _WIN32 |
1371 |
|
/* XXX Should we allow something like this for all platforms? */ |
1372 |
|
/* XXX Or is it still required at all? */ |
1422 |
|
} |
1423 |
|
|
1424 |
|
|
1425 |
+ |
static int |
1426 |
+ |
syncf_done( /* check if an rpiece sync file is complete */ |
1427 |
+ |
char *sfname |
1428 |
+ |
) |
1429 |
+ |
{ |
1430 |
+ |
FILE *fp = fopen(sfname, "r"); |
1431 |
+ |
int todo = 1; |
1432 |
+ |
int x, y; |
1433 |
+ |
|
1434 |
+ |
if (fp == NULL) |
1435 |
+ |
return(0); |
1436 |
+ |
if (fscanf(fp, "%d %d", &x, &y) != 2) |
1437 |
+ |
goto checked; |
1438 |
+ |
todo = x*y; /* total number of tiles */ |
1439 |
+ |
if (fscanf(fp, "%d %d", &x, &y) != 2 || (x != 0) | (y != 0)) |
1440 |
+ |
goto checked; |
1441 |
+ |
/* XXX assume no redundant tiles */ |
1442 |
+ |
while (fscanf(fp, "%d %d", &x, &y) == 2) |
1443 |
+ |
if (!--todo) |
1444 |
+ |
break; |
1445 |
+ |
checked: |
1446 |
+ |
fclose(fp); |
1447 |
+ |
return(!todo); |
1448 |
+ |
} |
1449 |
+ |
|
1450 |
+ |
|
1451 |
|
static void |
1452 |
|
rpict( /* run rpict and pfilt for each view */ |
1453 |
|
char *opts, |
1454 |
|
char *po |
1455 |
|
) |
1456 |
|
{ |
1457 |
< |
char combuf[PATH_MAX]; |
1457 |
> |
#define do_rpiece (sfile[0]!='\0') |
1458 |
> |
char combuf[5*PATH_MAX+512]; |
1459 |
|
char rawfile[PATH_MAX], picfile[PATH_MAX]; |
1460 |
|
char zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32]; |
1461 |
< |
char rppopt[128], *pfile = NULL; |
1461 |
> |
char rppopt[32], sfile[PATH_MAX], *pfile = NULL; |
1462 |
|
char pfopts[128]; |
1463 |
|
char vs[32], *vw; |
1464 |
|
int vn, mult; |
1465 |
|
FILE *fp; |
1466 |
|
time_t rfdt, pfdt; |
1467 |
+ |
int xres, yres; |
1468 |
+ |
double aspect; |
1469 |
+ |
int n; |
1470 |
|
/* get pfilt options */ |
1471 |
|
pfiltopts(pfopts); |
1472 |
|
/* get resolution, reporting */ |
1481 |
|
mult = 3; |
1482 |
|
break; |
1483 |
|
} |
1484 |
< |
{ |
1485 |
< |
int xres, yres; |
1486 |
< |
double aspect; |
1487 |
< |
int n; |
1488 |
< |
n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect); |
1489 |
< |
if (n == 3) |
1490 |
< |
sprintf(res, "-x %d -y %d -pa %.3f", |
1491 |
< |
mult*xres, mult*yres, aspect); |
1492 |
< |
else if (n) { |
1493 |
< |
if (n == 1) yres = xres; |
1289 |
< |
sprintf(res, "-x %d -y %d", mult*xres, mult*yres); |
1290 |
< |
} else |
1291 |
< |
badvalue(RESOLUTION); |
1292 |
< |
} |
1484 |
> |
n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect); |
1485 |
> |
if (n == 3) |
1486 |
> |
sprintf(res, "-x %d -y %d -pa %.3f", |
1487 |
> |
mult*xres, mult*yres, aspect); |
1488 |
> |
else if (n) { |
1489 |
> |
aspect = 1.; |
1490 |
> |
if (n == 1) yres = xres; |
1491 |
> |
sprintf(res, "-x %d -y %d", mult*xres, mult*yres); |
1492 |
> |
} else |
1493 |
> |
badvalue(RESOLUTION); |
1494 |
|
rep[0] = '\0'; |
1495 |
|
if (vdef(REPORT)) { |
1496 |
|
double minutes; |
1296 |
– |
int n; |
1497 |
|
n = sscanf(vval(REPORT), "%lf %s", &minutes, rawfile); |
1498 |
|
if (n == 2) |
1499 |
|
sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile); |
1503 |
|
badvalue(REPORT); |
1504 |
|
} |
1505 |
|
/* set up parallel rendering */ |
1506 |
< |
if ((nprocs > 1) & (!vdef(ZFILE))) { |
1507 |
< |
strcpy(rppopt, "-S 1 -PP pfXXXXXX"); |
1508 |
< |
pfile = rppopt+9; |
1509 |
< |
if (mktemp(pfile) == NULL) |
1506 |
> |
sfile[0] = '\0'; |
1507 |
> |
if ((nprocs > 1) & !touchonly & !vdef(ZFILE) && |
1508 |
> |
getview(0, vs) != NULL) { |
1509 |
> |
if (!strcmp(c_rpict, DEF_RPICT_PATH) && |
1510 |
> |
getview(1, NULL) == NULL) { |
1511 |
> |
sprintf(sfile, "%s_%s_rpsync.txt", |
1512 |
> |
vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), |
1513 |
> |
vs); |
1514 |
> |
strcpy(rppopt, "-PP pfXXXXXX"); |
1515 |
> |
} else { |
1516 |
> |
strcpy(rppopt, "-S 1 -PP pfXXXXXX"); |
1517 |
> |
} |
1518 |
> |
pfile = rppopt + strlen(rppopt) - 8; |
1519 |
> |
if (mktemp(pfile) == NULL) { |
1520 |
> |
if (do_rpiece) { |
1521 |
> |
fprintf(stderr, "%s: cannot create\n", pfile); |
1522 |
> |
quit(1); |
1523 |
> |
} |
1524 |
> |
pfile[-5] = '\0'; |
1525 |
|
pfile = NULL; |
1526 |
+ |
} |
1527 |
|
} |
1528 |
|
vn = 0; /* do each view */ |
1529 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1530 |
|
if (sayview) |
1531 |
|
myprintview(vw, stdout); |
1316 |
– |
if (!vs[0]) |
1317 |
– |
sprintf(vs, "%d", vn); |
1532 |
|
sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs); |
1533 |
|
if (vdef(ZFILE)) |
1534 |
|
sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs); |
1550 |
|
touch(picfile); |
1551 |
|
continue; |
1552 |
|
} |
1553 |
< |
if (next_process()) { /* parallel running? */ |
1553 |
> |
/* parallel running? */ |
1554 |
> |
if (do_rpiece) { |
1555 |
> |
if (rfdt < oct1date || !fdate(sfile)) { |
1556 |
> |
int xdiv = 8+nprocs/3, ydiv = 8+nprocs/3; |
1557 |
> |
if (rfdt >= oct1date) { |
1558 |
> |
fprintf(stderr, |
1559 |
> |
"%s: partial output not created with %s\n", rawfile, c_rpiece); |
1560 |
> |
quit(1); |
1561 |
> |
} |
1562 |
> |
if (rfdt) { /* start fresh */ |
1563 |
> |
rmfile(rawfile); |
1564 |
> |
rfdt = 0; |
1565 |
> |
} |
1566 |
> |
if (!silent) |
1567 |
> |
printf("\techo %d %d > %s\n", |
1568 |
> |
xdiv, ydiv, sfile); |
1569 |
> |
if ((fp = fopen(sfile, "w")) == NULL) { |
1570 |
> |
fprintf(stderr, "%s: cannot create\n", |
1571 |
> |
sfile); |
1572 |
> |
quit(1); |
1573 |
> |
} |
1574 |
> |
fprintf(fp, "%d %d\n", xdiv, ydiv); |
1575 |
> |
fclose(fp); |
1576 |
> |
} |
1577 |
> |
} else if (next_process(0)) { |
1578 |
|
if (pfile != NULL) |
1579 |
< |
sleep(20); |
1579 |
> |
sleep(10); |
1580 |
|
continue; |
1581 |
< |
} |
1581 |
> |
} else if (!inchild()) |
1582 |
> |
pfile = NULL; |
1583 |
|
/* XXX Remember to call finish_process() */ |
1584 |
|
/* build rpict command */ |
1585 |
< |
if (rfdt >= oct1date) { /* recover */ |
1586 |
< |
sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict, |
1587 |
< |
rep, opts, po, zopt, rawfile, oct1name); |
1588 |
< |
if (runcom(combuf)) /* run rpict */ |
1585 |
> |
if (rfdt >= oct1date) { /* already in progress */ |
1586 |
> |
if (do_rpiece) { |
1587 |
> |
sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s", |
1588 |
> |
c_rpiece, sfile, rppopt, rep, vw, |
1589 |
> |
res, opts, po, rawfile, oct1name); |
1590 |
> |
while (next_process(1)) { |
1591 |
> |
sleep(10); |
1592 |
> |
combuf[strlen(c_rpiece)+2] = 'F'; |
1593 |
> |
} |
1594 |
> |
} else |
1595 |
> |
sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict, |
1596 |
> |
rep, opts, po, zopt, rawfile, oct1name); |
1597 |
> |
if (runcom(combuf)) /* run rpict/rpiece */ |
1598 |
|
goto rperror; |
1599 |
|
} else { |
1600 |
|
if (overture) { /* run overture calculation */ |
1601 |
|
sprintf(combuf, |
1602 |
< |
"%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1602 |
> |
"%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1603 |
|
c_rpict, rep, vw, opts, |
1604 |
|
oct1name, overfile); |
1605 |
< |
if (runcom(combuf)) { |
1606 |
< |
fprintf(stderr, |
1605 |
> |
if (!do_rpiece || !next_process(0)) { |
1606 |
> |
if (runcom(combuf)) { |
1607 |
> |
fprintf(stderr, |
1608 |
|
"%s: error in overture for view %s\n", |
1609 |
< |
progname, vs); |
1610 |
< |
quit(1); |
1611 |
< |
} |
1609 |
> |
progname, vs); |
1610 |
> |
quit(1); |
1611 |
> |
} |
1612 |
|
#ifndef NULL_DEVICE |
1613 |
< |
rmfile(overfile); |
1613 |
> |
rmfile(overfile); |
1614 |
|
#endif |
1615 |
+ |
} else if (do_rpiece) |
1616 |
+ |
sleep(20); |
1617 |
|
} |
1618 |
< |
sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", |
1619 |
< |
c_rpict, rep, vw, res, opts, po, |
1620 |
< |
zopt, oct1name, rawfile); |
1621 |
< |
if (pfile != NULL && inchild()) { |
1622 |
< |
/* rpict persistent mode */ |
1618 |
> |
if (do_rpiece) { |
1619 |
> |
sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s", |
1620 |
> |
c_rpiece, sfile, rppopt, rep, vw, |
1621 |
> |
res, opts, po, rawfile, oct1name); |
1622 |
> |
while (next_process(1)) |
1623 |
> |
sleep(10); |
1624 |
> |
} else { |
1625 |
> |
sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", |
1626 |
> |
c_rpict, rep, vw, res, opts, po, |
1627 |
> |
zopt, oct1name, rawfile); |
1628 |
> |
} |
1629 |
> |
if ((pfile != NULL) & !do_rpiece) { |
1630 |
|
if (!silent) |
1631 |
|
printf("\t%s\n", combuf); |
1632 |
|
fflush(stdout); |
1633 |
|
sprintf(combuf, "%s%s %s %s%s%s %s > %s", |
1634 |
< |
c_rpict, rep, rppopt, res, opts, |
1635 |
< |
po, oct1name, rawfile); |
1634 |
> |
c_rpict, rep, rppopt, res, |
1635 |
> |
opts, po, oct1name, rawfile); |
1636 |
|
fp = popen(combuf, "w"); |
1637 |
|
if (fp == NULL) |
1638 |
|
goto rperror; |
1639 |
|
myprintview(vw, fp); |
1640 |
|
if (pclose(fp)) |
1641 |
|
goto rperror; |
1642 |
< |
} else { /* rpict normal mode */ |
1643 |
< |
if (runcom(combuf)) |
1644 |
< |
goto rperror; |
1642 |
> |
} else if (runcom(combuf)) |
1643 |
> |
goto rperror; |
1644 |
> |
} |
1645 |
> |
if (do_rpiece) { /* need to finish raw, first */ |
1646 |
> |
finish_process(); |
1647 |
> |
wait_process(1); |
1648 |
> |
if (!syncf_done(sfile)) { |
1649 |
> |
fprintf(stderr, |
1650 |
> |
"%s: %s did not complete rendering of view %s\n", |
1651 |
> |
progname, c_rpiece, vs); |
1652 |
> |
quit(1); |
1653 |
|
} |
1654 |
|
} |
1655 |
|
if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { |
1656 |
|
/* build pfilt command */ |
1657 |
< |
if (mult > 1) |
1657 |
> |
if (do_rpiece) |
1658 |
> |
sprintf(combuf, |
1659 |
> |
"%s%s -x %d -y %d -p %.3f %s > %s", |
1660 |
> |
c_pfilt, pfopts, xres, yres, aspect, |
1661 |
> |
rawfile, picfile); |
1662 |
> |
else if (mult > 1) |
1663 |
|
sprintf(combuf, "%s%s -x /%d -y /%d %s > %s", |
1664 |
|
c_pfilt, pfopts, mult, mult, |
1665 |
|
rawfile, picfile); |
1680 |
|
mvfile(rawfile, combuf); |
1681 |
|
} else |
1682 |
|
rmfile(rawfile); |
1683 |
< |
finish_process(); /* exit if child */ |
1683 |
> |
if (do_rpiece) /* done with sync file */ |
1684 |
> |
rmfile(sfile); |
1685 |
> |
else |
1686 |
> |
finish_process(); /* exit if child */ |
1687 |
|
} |
1688 |
|
wait_process(1); /* wait for children to finish */ |
1689 |
< |
if (pfile != NULL) { /* clean up rpict persistent mode */ |
1689 |
> |
if (pfile != NULL) { /* clean up persistent rpict */ |
1690 |
|
RT_PID pid; |
1691 |
|
fp = fopen(pfile, "r"); |
1692 |
|
if (fp != NULL) { |
1700 |
|
rperror: |
1701 |
|
fprintf(stderr, "%s: error rendering view %s\n", progname, vs); |
1702 |
|
quit(1); |
1703 |
+ |
#undef do_rpiece |
1704 |
|
} |
1705 |
|
|
1706 |
|
|
1713 |
|
printf("\ttouch %s\n", fn); |
1714 |
|
if (!nprocs) |
1715 |
|
return(0); |
1441 |
– |
#ifdef notused |
1442 |
– |
if (access(fn, F_OK) == -1) /* create it */ |
1443 |
– |
if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) |
1444 |
– |
return(-1); |
1445 |
– |
#endif |
1716 |
|
return(setfdate(fn, time((time_t *)NULL))); |
1717 |
|
} |
1718 |
|
|
1760 |
|
|
1761 |
|
#ifdef RHAS_FORK_EXEC |
1762 |
|
static int |
1763 |
< |
next_process(void) /* fork the next process (max. nprocs) */ |
1763 |
> |
next_process(int reserve) /* fork the next process */ |
1764 |
|
{ |
1765 |
|
RT_PID child_pid; |
1766 |
|
|
1771 |
|
progname); |
1772 |
|
quit(1); |
1773 |
|
} |
1774 |
+ |
if (reserve > 0 && children_running >= nprocs-reserve) |
1775 |
+ |
return(0); /* caller holding back process(es) */ |
1776 |
|
if (children_running >= nprocs) |
1777 |
|
wait_process(0); /* wait for someone to finish */ |
1778 |
|
fflush(NULL); /* flush output */ |
1779 |
|
child_pid = fork(); /* split process */ |
1780 |
|
if (child_pid == 0) { /* we're the child */ |
1781 |
|
children_running = -1; |
1782 |
+ |
nprocs = 1; |
1783 |
|
return(0); |
1784 |
|
} |
1785 |
|
if (child_pid > 0) { /* we're the parent */ |
1821 |
|
} |
1822 |
|
#else /* ! RHAS_FORK_EXEC */ |
1823 |
|
static int |
1824 |
< |
next_process(void) |
1824 |
> |
next_process(int reserve) |
1825 |
|
{ |
1826 |
|
return(0); /* cannot start new process */ |
1827 |
|
} |
1847 |
|
return; /* in parent -- noop */ |
1848 |
|
exit(0); |
1849 |
|
} |
1577 |
– |
|
1578 |
– |
#ifdef _WIN32 |
1579 |
– |
setenv(vname, value) /* set an environment variable */ |
1580 |
– |
char *vname, *value; |
1581 |
– |
{ |
1582 |
– |
register char *evp; |
1583 |
– |
|
1584 |
– |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
1585 |
– |
if (evp == NULL) |
1586 |
– |
syserr(progname); |
1587 |
– |
sprintf(evp, "%s=%s", vname, value); |
1588 |
– |
if (putenv(evp) != 0) { |
1589 |
– |
fprintf(stderr, "%s: out of environment space\n", progname); |
1590 |
– |
quit(1); |
1591 |
– |
} |
1592 |
– |
if (!silent) |
1593 |
– |
printf("set %s\n", evp); |
1594 |
– |
} |
1595 |
– |
#endif |
1850 |
|
|
1851 |
|
|
1852 |
|
static void |