11 |
|
#include <time.h> |
12 |
|
|
13 |
|
#include "platform.h" |
14 |
+ |
#include "rtprocess.h" |
15 |
|
#include "view.h" |
16 |
|
#include "paths.h" |
17 |
|
#include "vars.h" |
22 |
|
#else |
23 |
|
#define DELCMD "rm -f" |
24 |
|
#define RENAMECMD "mv" |
25 |
+ |
#include <sys/types.h> |
26 |
+ |
#include <sys/wait.h> |
27 |
|
#endif |
28 |
|
|
29 |
|
/* variables (alphabetical by name) */ |
109 |
|
int touchonly = 0; /* touch files only */ |
110 |
|
int nprocs = 1; /* maximum executing processes */ |
111 |
|
int sayview = 0; /* print view out */ |
112 |
< |
char *rvdevice = NULL; /* rview output device */ |
112 |
> |
char *rvdevice = NULL; /* rvu output device */ |
113 |
|
char *viewselect = NULL; /* specific view only */ |
114 |
|
|
115 |
|
int overture = 0; /* overture calculation needed */ |
123 |
|
|
124 |
|
#define inchild() (children_running < 0) |
125 |
|
|
126 |
+ |
static void rootname(char *rn, char *fn); |
127 |
+ |
static time_t checklast(char *fnames); |
128 |
+ |
static char * newfname(char *orig, int pred); |
129 |
+ |
static void checkfiles(void); |
130 |
+ |
static void getoctcube(double org[3], double *sizp); |
131 |
+ |
static void setdefaults(void); |
132 |
+ |
static void oconv(void); |
133 |
+ |
static char * addarg(char *op, char *arg); |
134 |
+ |
static void oconvopts(char *oo); |
135 |
+ |
static void mkillumopts(char *mo); |
136 |
+ |
static void checkambfile(void); |
137 |
+ |
static double ambval(void); |
138 |
+ |
static void renderopts(char *op, char *po); |
139 |
+ |
static void lowqopts(char *op, char *po); |
140 |
+ |
static void medqopts(char *op, char *po); |
141 |
+ |
static void hiqopts(char *op, char *po); |
142 |
+ |
static void xferopts(char *ro); |
143 |
+ |
static void pfiltopts(char *po); |
144 |
+ |
static int matchword(char *s1, char *s2); |
145 |
+ |
static char * specview(char *vs); |
146 |
+ |
static char * getview(int n, char *vn); |
147 |
+ |
static int myprintview(char *vopts, FILE *fp); |
148 |
+ |
static void rvu(char *opts, char *po); |
149 |
+ |
static void rpict(char *opts, char *po); |
150 |
+ |
static int touch(char *fn); |
151 |
+ |
static int runcom(char *cs); |
152 |
+ |
static int rmfile(char *fn); |
153 |
+ |
static int mvfile(char *fold, char *fnew); |
154 |
+ |
static int next_process(void); |
155 |
+ |
static void wait_process(int all); |
156 |
+ |
static void finish_process(void); |
157 |
+ |
static void badvalue(int vc); |
158 |
+ |
static void syserr(char *s); |
159 |
|
|
160 |
< |
main(argc, argv) |
161 |
< |
int argc; |
162 |
< |
char *argv[]; |
160 |
> |
|
161 |
> |
int |
162 |
> |
main( |
163 |
> |
int argc, |
164 |
> |
char *argv[] |
165 |
> |
) |
166 |
|
{ |
167 |
|
char ropts[512]; |
168 |
|
char popts[64]; |
208 |
|
goto userr; |
209 |
|
rifname = argv[i]; |
210 |
|
/* check command-line options */ |
211 |
< |
if (nprocs > 1 & viewselect != NULL) |
211 |
> |
if ((nprocs > 1) & (viewselect != NULL)) |
212 |
|
nprocs = 1; |
213 |
|
/* assign Radiance root file name */ |
214 |
|
rootname(radname, rifname); |
238 |
|
renderopts(ropts, popts); |
239 |
|
xferopts(ropts); |
240 |
|
if (rvdevice != NULL) |
241 |
< |
rview(ropts, popts); |
241 |
> |
rvu(ropts, popts); |
242 |
|
else |
243 |
|
rpict(ropts, popts); |
244 |
|
quit(0); |
247 |
|
"Usage: %s [-w][-s][-n|-N npr][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", |
248 |
|
progname); |
249 |
|
quit(1); |
250 |
+ |
return 1; /* pro forma return */ |
251 |
|
} |
252 |
|
|
253 |
|
|
254 |
< |
rootname(rn, fn) /* remove tail from end of fn */ |
255 |
< |
register char *rn, *fn; |
254 |
> |
static void |
255 |
> |
rootname( /* remove tail from end of fn */ |
256 |
> |
register char *rn, |
257 |
> |
register char *fn |
258 |
> |
) |
259 |
|
{ |
260 |
|
char *tp, *dp; |
261 |
|
|
262 |
< |
for (tp = NULL, dp = rn; *rn = *fn++; rn++) |
262 |
> |
for (tp = NULL, dp = rn; (*rn = *fn++); rn++) |
263 |
|
if (ISDIRSEP(*rn)) |
264 |
|
dp = rn; |
265 |
|
else if (*rn == '.') |
269 |
|
} |
270 |
|
|
271 |
|
|
272 |
< |
time_t |
273 |
< |
checklast(fnames) /* check files and find most recent */ |
274 |
< |
register char *fnames; |
272 |
> |
static time_t |
273 |
> |
checklast( /* check files and find most recent */ |
274 |
> |
register char *fnames |
275 |
> |
) |
276 |
|
{ |
277 |
|
char thisfile[PATH_MAX]; |
278 |
|
time_t thisdate, lastdate = 0; |
281 |
|
return(0); |
282 |
|
while ((fnames = nextword(thisfile, PATH_MAX, fnames)) != NULL) { |
283 |
|
if (thisfile[0] == '!' || |
284 |
< |
(thisfile[0] == '\\' && thisfile[1] == '!')) |
284 |
> |
(thisfile[0] == '\\' && thisfile[1] == '!')) { |
285 |
> |
if (!lastdate) |
286 |
> |
lastdate = 1; |
287 |
|
continue; |
288 |
+ |
} |
289 |
|
if (!(thisdate = fdate(thisfile))) |
290 |
|
syserr(thisfile); |
291 |
|
if (thisdate > lastdate) |
295 |
|
} |
296 |
|
|
297 |
|
|
298 |
< |
char * |
299 |
< |
newfname(orig, pred) /* create modified file name */ |
300 |
< |
char *orig; |
301 |
< |
int pred; |
298 |
> |
static char * |
299 |
> |
newfname( /* create modified file name */ |
300 |
> |
char *orig, |
301 |
> |
int pred |
302 |
> |
) |
303 |
|
{ |
304 |
|
register char *cp; |
305 |
|
register int n; |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
< |
checkfiles() /* check for existence and modified times */ |
324 |
> |
static void |
325 |
> |
checkfiles(void) /* check for existence and modified times */ |
326 |
|
{ |
327 |
|
time_t objdate; |
328 |
|
|
357 |
|
} |
358 |
|
|
359 |
|
|
360 |
< |
getoctcube(org, sizp) /* get octree bounding cube */ |
361 |
< |
double org[3], *sizp; |
360 |
> |
static void |
361 |
> |
getoctcube( /* get octree bounding cube */ |
362 |
> |
double org[3], |
363 |
> |
double *sizp |
364 |
> |
) |
365 |
|
{ |
314 |
– |
extern FILE *popen(); |
366 |
|
static double oorg[3], osiz = 0.; |
367 |
|
double min[3], max[3]; |
368 |
|
char buf[1024]; |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
< |
setdefaults() /* set default values for unassigned var's */ |
413 |
> |
static void |
414 |
> |
setdefaults(void) /* set default values for unassigned var's */ |
415 |
|
{ |
416 |
|
double org[3], lim[3], size; |
417 |
|
char buf[128]; |
468 |
|
} |
469 |
|
|
470 |
|
|
471 |
< |
oconv() /* run oconv and mkillum if necessary */ |
471 |
> |
static void |
472 |
> |
oconv(void) /* run oconv and mkillum if necessary */ |
473 |
|
{ |
474 |
|
static char illumtmp[] = "ilXXXXXX"; |
475 |
< |
char combuf[PATH_MAX], ocopts[64], mkopts[64]; |
475 |
> |
char combuf[PATH_MAX], ocopts[64], mkopts[1024]; |
476 |
|
|
477 |
|
oconvopts(ocopts); /* get options */ |
478 |
|
if (octreedate < scenedate) { /* check date on original octree */ |
501 |
|
} |
502 |
|
if (oct1name == vval(OCTREE)) /* no mkillum? */ |
503 |
|
oct1date = octreedate > matdate ? octreedate : matdate; |
504 |
< |
if (oct1date >= octreedate & oct1date >= matdate |
505 |
< |
& oct1date >= illumdate) /* all done */ |
504 |
> |
if ((oct1date >= octreedate) & (oct1date >= matdate) |
505 |
> |
& (oct1date >= illumdate)) /* all done */ |
506 |
|
return; |
507 |
|
/* make octree0 */ |
508 |
< |
if (oct0date < scenedate | oct0date < illumdate) { |
508 |
> |
if ((oct0date < scenedate) | (oct0date < illumdate)) { |
509 |
|
if (touchonly && oct0date) |
510 |
|
touch(oct0name); |
511 |
|
else { /* build command */ |
571 |
|
} |
572 |
|
|
573 |
|
|
574 |
< |
char * |
575 |
< |
addarg(op, arg) /* add argument and advance pointer */ |
576 |
< |
register char *op, *arg; |
574 |
> |
static char * |
575 |
> |
addarg( /* add argument and advance pointer */ |
576 |
> |
register char *op, |
577 |
> |
register char *arg |
578 |
> |
) |
579 |
|
{ |
580 |
|
*op = ' '; |
581 |
< |
while (*++op = *arg++) |
581 |
> |
while ( (*++op = *arg++) ) |
582 |
|
; |
583 |
|
return(op); |
584 |
|
} |
585 |
|
|
586 |
|
|
587 |
< |
oconvopts(oo) /* get oconv options */ |
588 |
< |
register char *oo; |
587 |
> |
static void |
588 |
> |
oconvopts( /* get oconv options */ |
589 |
> |
register char *oo |
590 |
> |
) |
591 |
|
{ |
592 |
|
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
593 |
|
|
597 |
|
} |
598 |
|
|
599 |
|
|
600 |
< |
mkillumopts(mo) /* get mkillum options */ |
601 |
< |
register char *mo; |
600 |
> |
static void |
601 |
> |
mkillumopts( /* get mkillum options */ |
602 |
> |
char *mo |
603 |
> |
) |
604 |
|
{ |
605 |
|
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
606 |
|
|
607 |
< |
*mo = '\0'; |
607 |
> |
if (nprocs > 1) { |
608 |
> |
sprintf(mo, " -n %d", nprocs); |
609 |
> |
while (*mo) |
610 |
> |
mo++; |
611 |
> |
} else |
612 |
> |
*mo = '\0'; |
613 |
|
if (vdef(MKILLUM)) |
614 |
|
addarg(mo, vval(MKILLUM)); |
615 |
|
} |
616 |
|
|
617 |
|
|
618 |
< |
checkambfile() /* check date on ambient file */ |
618 |
> |
static void |
619 |
> |
checkambfile(void) /* check date on ambient file */ |
620 |
|
{ |
621 |
|
time_t afdate; |
622 |
|
|
633 |
|
} |
634 |
|
|
635 |
|
|
636 |
< |
double |
637 |
< |
ambval() /* compute ambient value */ |
636 |
> |
static double |
637 |
> |
ambval(void) /* compute ambient value */ |
638 |
|
{ |
639 |
|
if (vdef(EXPOSURE)) { |
640 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
646 |
|
if (vlet(ZONE) == 'I') |
647 |
|
return(.01); |
648 |
|
badvalue(ZONE); |
649 |
+ |
return 0; /* pro forma return */ |
650 |
|
} |
651 |
|
|
652 |
|
|
653 |
< |
renderopts(op, po) /* set rendering options */ |
654 |
< |
char *op, *po; |
653 |
> |
static void |
654 |
> |
renderopts( /* set rendering options */ |
655 |
> |
char *op, |
656 |
> |
char *po |
657 |
> |
) |
658 |
|
{ |
659 |
|
switch(vscale(QUALITY)) { |
660 |
|
case LOW: |
670 |
|
} |
671 |
|
|
672 |
|
|
673 |
< |
lowqopts(op, po) /* low quality rendering options */ |
674 |
< |
register char *op; |
675 |
< |
char *po; |
673 |
> |
static void |
674 |
> |
lowqopts( /* low quality rendering options */ |
675 |
> |
register char *op, |
676 |
> |
char *po |
677 |
> |
) |
678 |
|
{ |
679 |
|
double d, org[3], siz[3]; |
680 |
|
|
684 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
685 |
|
badvalue(ZONE); |
686 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
687 |
< |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
687 |
> |
if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) |
688 |
|
badvalue(ZONE); |
689 |
|
getoctcube(org, &d); |
690 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
692 |
|
case LOW: |
693 |
|
po = addarg(po, "-ps 16"); |
694 |
|
op = addarg(op, "-dp 64"); |
695 |
< |
sprintf(op, " -ar %d", (int)(4*d)); |
695 |
> |
sprintf(op, " -ar %d", (int)(8*d)); |
696 |
|
op += strlen(op); |
697 |
|
break; |
698 |
|
case MEDIUM: |
699 |
|
po = addarg(po, "-ps 8"); |
700 |
|
op = addarg(op, "-dp 128"); |
701 |
< |
sprintf(op, " -ar %d", (int)(8*d)); |
701 |
> |
sprintf(op, " -ar %d", (int)(16*d)); |
702 |
|
op += strlen(op); |
703 |
|
break; |
704 |
|
case HIGH: |
705 |
|
po = addarg(po, "-ps 4"); |
706 |
|
op = addarg(op, "-dp 256"); |
707 |
< |
sprintf(op, " -ar %d", (int)(16*d)); |
707 |
> |
sprintf(op, " -ar %d", (int)(32*d)); |
708 |
|
op += strlen(op); |
709 |
|
break; |
710 |
|
} |
721 |
|
overture = 0; |
722 |
|
switch (vscale(VARIABILITY)) { |
723 |
|
case LOW: |
724 |
< |
op = addarg(op, "-aa .4 -ad 64"); |
724 |
> |
op = addarg(op, "-aa .3 -ad 256"); |
725 |
|
break; |
726 |
|
case MEDIUM: |
727 |
< |
op = addarg(op, "-aa .3 -ad 128"); |
727 |
> |
op = addarg(op, "-aa .25 -ad 512"); |
728 |
|
break; |
729 |
|
case HIGH: |
730 |
< |
op = addarg(op, "-aa .25 -ad 256"); |
730 |
> |
op = addarg(op, "-aa .2 -ad 1024"); |
731 |
|
break; |
732 |
|
} |
733 |
|
op = addarg(op, "-as 0"); |
734 |
|
d = ambval(); |
735 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
736 |
|
op += strlen(op); |
737 |
< |
op = addarg(op, "-lr 3 -lw .02"); |
737 |
> |
op = addarg(op, "-lr 6 -lw .01"); |
738 |
|
if (vdef(RENDER)) |
739 |
|
op = addarg(op, vval(RENDER)); |
740 |
|
} |
741 |
|
|
742 |
|
|
743 |
< |
medqopts(op, po) /* medium quality rendering options */ |
744 |
< |
register char *op; |
745 |
< |
char *po; |
743 |
> |
static void |
744 |
> |
medqopts( /* medium quality rendering options */ |
745 |
> |
register char *op, |
746 |
> |
char *po |
747 |
> |
) |
748 |
|
{ |
749 |
|
double d, org[3], siz[3], asz; |
750 |
|
|
754 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
755 |
|
badvalue(ZONE); |
756 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
757 |
< |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
757 |
> |
if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) |
758 |
|
badvalue(ZONE); |
759 |
|
getoctcube(org, &d); |
760 |
|
asz = (siz[0]+siz[1]+siz[2])/3.; |
763 |
|
case LOW: |
764 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
765 |
|
op = addarg(op, "-dp 256"); |
766 |
< |
sprintf(op, " -ar %d", (int)(8*d)); |
766 |
> |
sprintf(op, " -ar %d", (int)(16*d)); |
767 |
|
op += strlen(op); |
768 |
|
sprintf(op, " -ms %.2g", asz/20.); |
769 |
|
op += strlen(op); |
771 |
|
case MEDIUM: |
772 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
773 |
|
op = addarg(op, "-dp 512"); |
774 |
< |
sprintf(op, " -ar %d", (int)(16*d)); |
774 |
> |
sprintf(op, " -ar %d", (int)(32*d)); |
775 |
|
op += strlen(op); |
776 |
|
sprintf(op, " -ms %.2g", asz/40.); |
777 |
|
op += strlen(op); |
779 |
|
case HIGH: |
780 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
781 |
|
op = addarg(op, "-dp 1024"); |
782 |
< |
sprintf(op, " -ar %d", (int)(32*d)); |
782 |
> |
sprintf(op, " -ar %d", (int)(64*d)); |
783 |
|
op += strlen(op); |
784 |
|
sprintf(op, " -ms %.2g", asz/80.); |
785 |
|
op += strlen(op); |
791 |
|
else |
792 |
|
op = addarg(op, "-ds .3"); |
793 |
|
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
794 |
< |
if (overture = vint(INDIRECT)) { |
794 |
> |
if ( (overture = vint(INDIRECT)) ) { |
795 |
|
sprintf(op, " -ab %d", overture); |
796 |
|
op += strlen(op); |
797 |
|
} |
802 |
|
overture = 0; |
803 |
|
switch (vscale(VARIABILITY)) { |
804 |
|
case LOW: |
805 |
< |
op = addarg(op, "-aa .25 -ad 196 -as 0"); |
805 |
> |
op = addarg(op, "-aa .2 -ad 329 -as 42"); |
806 |
|
break; |
807 |
|
case MEDIUM: |
808 |
< |
op = addarg(op, "-aa .2 -ad 400 -as 64"); |
808 |
> |
op = addarg(op, "-aa .15 -ad 800 -as 128"); |
809 |
|
break; |
810 |
|
case HIGH: |
811 |
< |
op = addarg(op, "-aa .15 -ad 768 -as 196"); |
811 |
> |
op = addarg(op, "-aa .1 -ad 1536 -as 392"); |
812 |
|
break; |
813 |
|
} |
814 |
|
d = ambval(); |
815 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
816 |
|
op += strlen(op); |
817 |
< |
op = addarg(op, "-lr 6 -lw .002"); |
817 |
> |
op = addarg(op, "-lr 8 -lw .002"); |
818 |
|
if (vdef(RENDER)) |
819 |
|
op = addarg(op, vval(RENDER)); |
820 |
|
} |
821 |
|
|
822 |
|
|
823 |
< |
hiqopts(op, po) /* high quality rendering options */ |
824 |
< |
register char *op; |
825 |
< |
char *po; |
823 |
> |
static void |
824 |
> |
hiqopts( /* high quality rendering options */ |
825 |
> |
register char *op, |
826 |
> |
char *po |
827 |
> |
) |
828 |
|
{ |
829 |
|
double d, org[3], siz[3], asz; |
830 |
|
|
834 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
835 |
|
badvalue(ZONE); |
836 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
837 |
< |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
837 |
> |
if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) |
838 |
|
badvalue(ZONE); |
839 |
|
getoctcube(org, &d); |
840 |
|
asz = (siz[0]+siz[1]+siz[2])/3.; |
843 |
|
case LOW: |
844 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
845 |
|
op = addarg(op, "-dp 1024"); |
846 |
< |
sprintf(op, " -ar %d", (int)(16*d)); |
846 |
> |
sprintf(op, " -ar %d", (int)(32*d)); |
847 |
|
op += strlen(op); |
848 |
|
sprintf(op, " -ms %.2g", asz/40.); |
849 |
|
op += strlen(op); |
851 |
|
case MEDIUM: |
852 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
853 |
|
op = addarg(op, "-dp 2048"); |
854 |
< |
sprintf(op, " -ar %d", (int)(32*d)); |
854 |
> |
sprintf(op, " -ar %d", (int)(64*d)); |
855 |
|
op += strlen(op); |
856 |
|
sprintf(op, " -ms %.2g", asz/80.); |
857 |
|
op += strlen(op); |
859 |
|
case HIGH: |
860 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
861 |
|
op = addarg(op, "-dp 4096"); |
862 |
< |
sprintf(op, " -ar %d", (int)(64*d)); |
862 |
> |
sprintf(op, " -ar %d", (int)(128*d)); |
863 |
|
op += strlen(op); |
864 |
|
sprintf(op, " -ms %.2g", asz/160.); |
865 |
|
op += strlen(op); |
880 |
|
overture = 0; |
881 |
|
switch (vscale(VARIABILITY)) { |
882 |
|
case LOW: |
883 |
< |
op = addarg(op, "-aa .15 -ad 256 -as 0"); |
883 |
> |
op = addarg(op, "-aa .125 -ad 512 -as 64"); |
884 |
|
break; |
885 |
|
case MEDIUM: |
886 |
< |
op = addarg(op, "-aa .125 -ad 512 -as 256"); |
886 |
> |
op = addarg(op, "-aa .1 -ad 1536 -as 768"); |
887 |
|
break; |
888 |
|
case HIGH: |
889 |
< |
op = addarg(op, "-aa .08 -ad 1024 -as 512"); |
889 |
> |
op = addarg(op, "-aa .075 -ad 4096 -as 2048"); |
890 |
|
break; |
891 |
|
} |
892 |
|
d = ambval(); |
898 |
|
} |
899 |
|
|
900 |
|
|
901 |
< |
xferopts(ro) /* transfer options if indicated */ |
902 |
< |
char *ro; |
901 |
> |
static void |
902 |
> |
xferopts( /* transfer options if indicated */ |
903 |
> |
char *ro |
904 |
> |
) |
905 |
|
{ |
906 |
|
int fd, n; |
907 |
|
register char *cp; |
931 |
|
} |
932 |
|
|
933 |
|
|
934 |
< |
pfiltopts(po) /* get pfilt options */ |
935 |
< |
register char *po; |
934 |
> |
static void |
935 |
> |
pfiltopts( /* get pfilt options */ |
936 |
> |
register char *po |
937 |
> |
) |
938 |
|
{ |
939 |
|
*po = '\0'; |
940 |
|
if (vdef(EXPOSURE)) { |
954 |
|
} |
955 |
|
|
956 |
|
|
957 |
< |
matchword(s1, s2) /* match white-delimited words */ |
958 |
< |
register char *s1, *s2; |
957 |
> |
static int |
958 |
> |
matchword( /* match white-delimited words */ |
959 |
> |
register char *s1, |
960 |
> |
register char *s2 |
961 |
> |
) |
962 |
|
{ |
963 |
|
while (isspace(*s1)) s1++; |
964 |
|
while (isspace(*s2)) s2++; |
969 |
|
} |
970 |
|
|
971 |
|
|
972 |
< |
char * |
973 |
< |
specview(vs) /* get proper view spec from vs */ |
974 |
< |
register char *vs; |
972 |
> |
static char * |
973 |
> |
specview( /* get proper view spec from vs */ |
974 |
> |
register char *vs |
975 |
> |
) |
976 |
|
{ |
977 |
|
static char vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0", |
978 |
|
"-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"}; |
990 |
|
upax = 1-'X'+UPPER(vval(UP)[1]); |
991 |
|
else |
992 |
|
upax = 1-'X'+vlet(UP); |
993 |
< |
if (upax < 1 | upax > 3) |
993 |
> |
if ((upax < 1) | (upax > 3)) |
994 |
|
badvalue(UP); |
995 |
|
if (vval(UP)[0] == '-') |
996 |
|
upax = -upax; |
1013 |
|
zpos = -1; vs++; |
1014 |
|
} |
1015 |
|
viewtype = 'v'; |
1016 |
< |
if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c') |
1016 |
> |
if ((*vs == 'v') | (*vs == 'l') | (*vs == 'a') | |
1017 |
> |
(*vs == 'h') | (*vs == 'c') | (*vs == 's')) |
1018 |
|
viewtype = *vs++; |
1019 |
|
cp = viewopts; |
1020 |
|
if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */ |
1095 |
|
} |
1096 |
|
|
1097 |
|
|
1098 |
< |
char * |
1099 |
< |
getview(n, vn) /* get view n, or NULL if none */ |
1100 |
< |
int n; |
1101 |
< |
char *vn; /* returned view name */ |
1098 |
> |
static char * |
1099 |
> |
getview( /* get view n, or NULL if none */ |
1100 |
> |
int n, |
1101 |
> |
char *vn /* returned view name */ |
1102 |
> |
) |
1103 |
|
{ |
1104 |
|
register char *mv; |
1105 |
|
|
1126 |
|
return(specview(viewselect)); /* standard view? */ |
1127 |
|
} |
1128 |
|
mv = nvalue(VIEWS, n); /* use view n */ |
1129 |
< |
if (vn != NULL & mv != NULL) { |
1129 |
> |
if ((vn != NULL) & (mv != NULL)) { |
1130 |
|
register char *mv2 = mv; |
1131 |
|
if (*mv2 != '-') |
1132 |
|
while (*mv2 && !isspace(*mv2)) |
1137 |
|
} |
1138 |
|
|
1139 |
|
|
1140 |
< |
int |
1141 |
< |
myprintview(vopts, fp) /* print out selected view */ |
1142 |
< |
register char *vopts; |
1143 |
< |
FILE *fp; |
1140 |
> |
static int |
1141 |
> |
myprintview( /* print out selected view */ |
1142 |
> |
register char *vopts, |
1143 |
> |
FILE *fp |
1144 |
> |
) |
1145 |
|
{ |
1146 |
|
VIEW vwr; |
1147 |
|
char buf[128]; |
1148 |
|
register char *cp; |
1149 |
+ |
#ifdef _WIN32 |
1150 |
+ |
/* XXX Should we allow something like this for all platforms? */ |
1151 |
+ |
/* XXX Or is it still required at all? */ |
1152 |
|
again: |
1153 |
+ |
#endif |
1154 |
|
if (vopts == NULL) |
1155 |
|
return(-1); |
1156 |
|
#ifdef _WIN32 |
1173 |
|
} |
1174 |
|
|
1175 |
|
|
1176 |
< |
rview(opts, po) /* run rview with first view */ |
1177 |
< |
char *opts, *po; |
1176 |
> |
static void |
1177 |
> |
rvu( /* run rvu with first view */ |
1178 |
> |
char *opts, |
1179 |
> |
char *po |
1180 |
> |
) |
1181 |
|
{ |
1182 |
|
char *vw; |
1183 |
|
char combuf[PATH_MAX]; |
1186 |
|
return; |
1187 |
|
if (sayview) |
1188 |
|
myprintview(vw, stdout); |
1189 |
< |
sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname); |
1189 |
> |
sprintf(combuf, "rvu %s%s%s -R %s ", vw, po, opts, rifname); |
1190 |
|
if (rvdevice != NULL) |
1191 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
1192 |
|
if (vdef(EXPOSURE)) |
1193 |
|
sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); |
1194 |
|
strcat(combuf, oct1name); |
1195 |
|
if (runcom(combuf)) { /* run it */ |
1196 |
< |
fprintf(stderr, "%s: error running rview\n", progname); |
1196 |
> |
fprintf(stderr, "%s: error running rvu\n", progname); |
1197 |
|
quit(1); |
1198 |
|
} |
1199 |
|
} |
1200 |
|
|
1201 |
|
|
1202 |
< |
rpict(opts, po) /* run rpict and pfilt for each view */ |
1203 |
< |
char *opts, *po; |
1202 |
> |
static void |
1203 |
> |
rpict( /* run rpict and pfilt for each view */ |
1204 |
> |
char *opts, |
1205 |
> |
char *po |
1206 |
> |
) |
1207 |
|
{ |
1208 |
|
char combuf[PATH_MAX]; |
1209 |
|
char rawfile[PATH_MAX], picfile[PATH_MAX]; |
1255 |
|
badvalue(REPORT); |
1256 |
|
} |
1257 |
|
/* set up parallel rendering */ |
1258 |
< |
if (nprocs > 1 & !vdef(ZFILE)) { |
1258 |
> |
if ((nprocs > 1) & (!vdef(ZFILE))) { |
1259 |
|
strcpy(rppopt, "-S 1 -PP pfXXXXXX"); |
1260 |
|
pfile = rppopt+9; |
1261 |
|
if (mktemp(pfile) == NULL) |
1323 |
|
/* rpict persistent mode */ |
1324 |
|
if (!silent) |
1325 |
|
printf("\t%s\n", combuf); |
1326 |
+ |
fflush(stdout); |
1327 |
|
sprintf(combuf, "rpict%s %s %s%s%s %s > %s", |
1328 |
|
rep, rppopt, res, po, opts, |
1329 |
|
oct1name, rawfile); |
1233 |
– |
fflush(stdout); |
1330 |
|
fp = popen(combuf, "w"); |
1331 |
|
if (fp == NULL) |
1332 |
|
goto rperror; |
1360 |
|
mvfile(rawfile, combuf); |
1361 |
|
} else |
1362 |
|
rmfile(rawfile); |
1363 |
< |
finish_process(); /* leave if child */ |
1363 |
> |
finish_process(); /* exit if child */ |
1364 |
|
} |
1365 |
|
wait_process(1); /* wait for children to finish */ |
1366 |
|
if (pfile != NULL) { /* clean up rpict persistent mode */ |
1367 |
< |
int pid; |
1367 |
> |
RT_PID pid; |
1368 |
|
fp = fopen(pfile, "r"); |
1369 |
|
if (fp != NULL) { |
1370 |
|
if (fscanf(fp, "%*s %d", &pid) != 1 || |
1371 |
< |
kill(pid, 1) == -1) |
1371 |
> |
kill(pid, 1) < 0) |
1372 |
|
unlink(pfile); |
1373 |
|
fclose(fp); |
1374 |
|
} |
1380 |
|
} |
1381 |
|
|
1382 |
|
|
1383 |
< |
touch(fn) /* update a file */ |
1384 |
< |
char *fn; |
1383 |
> |
static int |
1384 |
> |
touch( /* update a file */ |
1385 |
> |
char *fn |
1386 |
> |
) |
1387 |
|
{ |
1388 |
|
if (!silent) |
1389 |
|
printf("\ttouch %s\n", fn); |
1398 |
|
} |
1399 |
|
|
1400 |
|
|
1401 |
< |
runcom(cs) /* run command */ |
1402 |
< |
char *cs; |
1401 |
> |
static int |
1402 |
> |
runcom( /* run command */ |
1403 |
> |
char *cs |
1404 |
> |
) |
1405 |
|
{ |
1406 |
|
if (!silent) /* echo it */ |
1407 |
|
printf("\t%s\n", cs); |
1408 |
|
if (!nprocs) |
1409 |
|
return(0); |
1410 |
< |
fflush(stdout); /* flush output and pass to shell */ |
1410 |
> |
fflush(NULL); /* flush output and pass to shell */ |
1411 |
|
return(system(cs)); |
1412 |
|
} |
1413 |
|
|
1414 |
|
|
1415 |
< |
rmfile(fn) /* remove a file */ |
1416 |
< |
char *fn; |
1415 |
> |
static int |
1416 |
> |
rmfile( /* remove a file */ |
1417 |
> |
char *fn |
1418 |
> |
) |
1419 |
|
{ |
1420 |
|
if (!silent) |
1421 |
|
printf("\t%s %s\n", DELCMD, fn); |
1425 |
|
} |
1426 |
|
|
1427 |
|
|
1428 |
< |
mvfile(fold, fnew) /* move a file */ |
1429 |
< |
char *fold, *fnew; |
1428 |
> |
static int |
1429 |
> |
mvfile( /* move a file */ |
1430 |
> |
char *fold, |
1431 |
> |
char *fnew |
1432 |
> |
) |
1433 |
|
{ |
1434 |
|
if (!silent) |
1435 |
|
printf("\t%s %s %s\n", RENAMECMD, fold, fnew); |
1440 |
|
|
1441 |
|
|
1442 |
|
#ifdef RHAS_FORK_EXEC |
1443 |
< |
int |
1444 |
< |
next_process() /* fork the next process (max. nprocs) */ |
1443 |
> |
static int |
1444 |
> |
next_process(void) /* fork the next process (max. nprocs) */ |
1445 |
|
{ |
1446 |
< |
int child_pid; |
1446 |
> |
RT_PID child_pid; |
1447 |
|
|
1448 |
|
if (nprocs <= 1) |
1449 |
|
return(0); /* it's us or no one */ |
1450 |
|
if (inchild()) { |
1451 |
< |
fprintf(stderr, "%s: internal error 1 in spawn_process()\n", |
1451 |
> |
fprintf(stderr, "%s: internal error 1 in next_process()\n", |
1452 |
|
progname); |
1453 |
|
quit(1); |
1454 |
|
} |
1455 |
|
if (children_running >= nprocs) |
1456 |
|
wait_process(0); /* wait for someone to finish */ |
1457 |
< |
fflush(stdout); |
1457 |
> |
fflush(NULL); /* flush output */ |
1458 |
|
child_pid = fork(); /* split process */ |
1459 |
|
if (child_pid == 0) { /* we're the child */ |
1460 |
|
children_running = -1; |
1468 |
|
return(0); |
1469 |
|
} |
1470 |
|
|
1471 |
< |
wait_process(all) /* wait for process(es) to finish */ |
1472 |
< |
int all; |
1471 |
> |
static void |
1472 |
> |
wait_process( /* wait for process(es) to finish */ |
1473 |
> |
int all |
1474 |
> |
) |
1475 |
|
{ |
1476 |
|
int ourstatus = 0; |
1477 |
< |
int pid, status; |
1477 |
> |
RT_PID pid, status; |
1478 |
|
|
1479 |
|
if (all) |
1480 |
|
all = children_running; |
1487 |
|
status = status>>8 & 0xff; |
1488 |
|
--children_running; |
1489 |
|
if (status != 0) { /* child's problem is our problem */ |
1490 |
< |
if (ourstatus == 0 & children_running > 0) |
1490 |
> |
if ((ourstatus == 0) & (children_running > 0)) |
1491 |
|
fprintf(stderr, "%s: waiting for remaining processes\n", |
1492 |
|
progname); |
1493 |
|
ourstatus = status; |
1498 |
|
quit(ourstatus); /* bad status from child */ |
1499 |
|
} |
1500 |
|
#else /* ! RHAS_FORK_EXEC */ |
1501 |
< |
int |
1502 |
< |
next_process() |
1501 |
> |
static int |
1502 |
> |
next_process(void) |
1503 |
|
{ |
1504 |
|
return(0); /* cannot start new process */ |
1505 |
|
} |
1506 |
+ |
static void |
1507 |
|
wait_process(all) |
1508 |
|
int all; |
1509 |
|
{ |
1511 |
|
} |
1512 |
|
int |
1513 |
|
kill(pid, sig) /* win|unix_process.c should also wait and kill */ |
1514 |
< |
int pid, sig; |
1514 |
> |
RT_PID pid, sig; |
1515 |
|
{ |
1516 |
|
return 0; |
1517 |
|
} |
1518 |
|
#endif /* ! RHAS_FORK_EXEC */ |
1519 |
|
|
1520 |
< |
finish_process() /* exit a child process */ |
1520 |
> |
static void |
1521 |
> |
finish_process(void) /* exit a child process */ |
1522 |
|
{ |
1523 |
|
if (!inchild()) |
1524 |
|
return; /* in parent -- noop */ |
1545 |
|
#endif |
1546 |
|
|
1547 |
|
|
1548 |
< |
badvalue(vc) /* report bad variable value and exit */ |
1549 |
< |
int vc; |
1548 |
> |
static void |
1549 |
> |
badvalue( /* report bad variable value and exit */ |
1550 |
> |
int vc |
1551 |
> |
) |
1552 |
|
{ |
1553 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
1554 |
|
progname, vnam(vc)); |
1556 |
|
} |
1557 |
|
|
1558 |
|
|
1559 |
< |
syserr(s) /* report a system error and exit */ |
1560 |
< |
char *s; |
1559 |
> |
static void |
1560 |
> |
syserr( /* report a system error and exit */ |
1561 |
> |
char *s |
1562 |
> |
) |
1563 |
|
{ |
1564 |
|
perror(s); |
1565 |
|
quit(1); |