8 |
|
#include "standard.h" |
9 |
|
|
10 |
|
#include <ctype.h> |
11 |
+ |
#include <time.h> |
12 |
|
|
13 |
|
#include "platform.h" |
14 |
+ |
#include "rtprocess.h" |
15 |
|
#include "view.h" |
16 |
|
#include "paths.h" |
17 |
|
#include "vars.h" |
18 |
|
|
19 |
+ |
#ifdef _WIN32 |
20 |
+ |
#define DELCMD "del" |
21 |
+ |
#define RENAMECMD "rename" |
22 |
+ |
#else |
23 |
+ |
#define DELCMD "rm -f" |
24 |
+ |
#define RENAMECMD "mv" |
25 |
+ |
#include <sys/types.h> |
26 |
+ |
#include <sys/wait.h> |
27 |
+ |
#endif |
28 |
+ |
|
29 |
|
/* variables (alphabetical by name) */ |
30 |
|
#define AMBFILE 0 /* ambient file name */ |
31 |
|
#define DETAIL 1 /* level of scene detail */ |
92 |
|
char overfile[] = "overture.unf"; |
93 |
|
#endif |
94 |
|
|
83 |
– |
extern time_t time(); |
95 |
|
|
96 |
|
time_t scenedate; /* date of latest scene or object file */ |
97 |
|
time_t octreedate; /* date of octree */ |
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 |
|
{ |
306 |
– |
extern FILE *popen(); |
366 |
|
static double oorg[3], osiz = 0.; |
367 |
|
double min[3], max[3]; |
368 |
|
char buf[1024]; |
369 |
|
FILE *fp; |
370 |
|
register int i; |
371 |
|
|
372 |
< |
if (osiz <= FTINY) |
372 |
> |
if (osiz <= FTINY) { |
373 |
|
if (!nprocs && fdate(oct1name) < |
374 |
|
(scenedate>illumdate?scenedate:illumdate)) { |
375 |
|
/* run getbbox */ |
405 |
|
} |
406 |
|
pclose(fp); |
407 |
|
} |
408 |
+ |
} |
409 |
|
org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz; |
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]; |
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 |
> |
register char *mo |
603 |
> |
) |
604 |
|
{ |
605 |
|
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
606 |
|
|
610 |
|
} |
611 |
|
|
612 |
|
|
613 |
< |
checkambfile() /* check date on ambient file */ |
613 |
> |
static void |
614 |
> |
checkambfile(void) /* check date on ambient file */ |
615 |
|
{ |
616 |
|
time_t afdate; |
617 |
|
|
619 |
|
return; |
620 |
|
if (!(afdate = fdate(vval(AMBFILE)))) |
621 |
|
return; |
622 |
< |
if (oct1date > afdate) |
622 |
> |
if (oct1date > afdate) { |
623 |
|
if (touchonly) |
624 |
|
touch(vval(AMBFILE)); |
625 |
|
else |
626 |
|
rmfile(vval(AMBFILE)); |
627 |
+ |
} |
628 |
|
} |
629 |
|
|
630 |
|
|
631 |
< |
double |
632 |
< |
ambval() /* compute ambient value */ |
631 |
> |
static double |
632 |
> |
ambval(void) /* compute ambient value */ |
633 |
|
{ |
634 |
|
if (vdef(EXPOSURE)) { |
635 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
641 |
|
if (vlet(ZONE) == 'I') |
642 |
|
return(.01); |
643 |
|
badvalue(ZONE); |
644 |
+ |
return 0; /* pro forma return */ |
645 |
|
} |
646 |
|
|
647 |
|
|
648 |
< |
renderopts(op, po) /* set rendering options */ |
649 |
< |
char *op, *po; |
648 |
> |
static void |
649 |
> |
renderopts( /* set rendering options */ |
650 |
> |
char *op, |
651 |
> |
char *po |
652 |
> |
) |
653 |
|
{ |
654 |
|
switch(vscale(QUALITY)) { |
655 |
|
case LOW: |
665 |
|
} |
666 |
|
|
667 |
|
|
668 |
< |
lowqopts(op, po) /* low quality rendering options */ |
669 |
< |
register char *op; |
670 |
< |
char *po; |
668 |
> |
static void |
669 |
> |
lowqopts( /* low quality rendering options */ |
670 |
> |
register char *op, |
671 |
> |
char *po |
672 |
> |
) |
673 |
|
{ |
674 |
|
double d, org[3], siz[3]; |
675 |
|
|
679 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
680 |
|
badvalue(ZONE); |
681 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
682 |
< |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
682 |
> |
if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) |
683 |
|
badvalue(ZONE); |
684 |
|
getoctcube(org, &d); |
685 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
687 |
|
case LOW: |
688 |
|
po = addarg(po, "-ps 16"); |
689 |
|
op = addarg(op, "-dp 64"); |
690 |
< |
sprintf(op, " -ar %d", (int)(4*d)); |
690 |
> |
sprintf(op, " -ar %d", (int)(8*d)); |
691 |
|
op += strlen(op); |
692 |
|
break; |
693 |
|
case MEDIUM: |
694 |
|
po = addarg(po, "-ps 8"); |
695 |
|
op = addarg(op, "-dp 128"); |
696 |
< |
sprintf(op, " -ar %d", (int)(8*d)); |
696 |
> |
sprintf(op, " -ar %d", (int)(16*d)); |
697 |
|
op += strlen(op); |
698 |
|
break; |
699 |
|
case HIGH: |
700 |
|
po = addarg(po, "-ps 4"); |
701 |
|
op = addarg(op, "-dp 256"); |
702 |
< |
sprintf(op, " -ar %d", (int)(16*d)); |
702 |
> |
sprintf(op, " -ar %d", (int)(32*d)); |
703 |
|
op += strlen(op); |
704 |
|
break; |
705 |
|
} |
716 |
|
overture = 0; |
717 |
|
switch (vscale(VARIABILITY)) { |
718 |
|
case LOW: |
719 |
< |
op = addarg(op, "-aa .4 -ad 64"); |
719 |
> |
op = addarg(op, "-aa .3 -ad 256"); |
720 |
|
break; |
721 |
|
case MEDIUM: |
722 |
< |
op = addarg(op, "-aa .3 -ad 128"); |
722 |
> |
op = addarg(op, "-aa .25 -ad 512"); |
723 |
|
break; |
724 |
|
case HIGH: |
725 |
< |
op = addarg(op, "-aa .25 -ad 256"); |
725 |
> |
op = addarg(op, "-aa .2 -ad 1024"); |
726 |
|
break; |
727 |
|
} |
728 |
|
op = addarg(op, "-as 0"); |
729 |
|
d = ambval(); |
730 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
731 |
|
op += strlen(op); |
732 |
< |
op = addarg(op, "-lr 3 -lw .02"); |
732 |
> |
op = addarg(op, "-lr 6 -lw .01"); |
733 |
|
if (vdef(RENDER)) |
734 |
|
op = addarg(op, vval(RENDER)); |
735 |
|
} |
736 |
|
|
737 |
|
|
738 |
< |
medqopts(op, po) /* medium quality rendering options */ |
739 |
< |
register char *op; |
740 |
< |
char *po; |
738 |
> |
static void |
739 |
> |
medqopts( /* medium quality rendering options */ |
740 |
> |
register char *op, |
741 |
> |
char *po |
742 |
> |
) |
743 |
|
{ |
744 |
|
double d, org[3], siz[3], asz; |
745 |
|
|
749 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
750 |
|
badvalue(ZONE); |
751 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
752 |
< |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
752 |
> |
if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) |
753 |
|
badvalue(ZONE); |
754 |
|
getoctcube(org, &d); |
755 |
|
asz = (siz[0]+siz[1]+siz[2])/3.; |
758 |
|
case LOW: |
759 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
760 |
|
op = addarg(op, "-dp 256"); |
761 |
< |
sprintf(op, " -ar %d", (int)(8*d)); |
761 |
> |
sprintf(op, " -ar %d", (int)(16*d)); |
762 |
|
op += strlen(op); |
763 |
|
sprintf(op, " -ms %.2g", asz/20.); |
764 |
|
op += strlen(op); |
766 |
|
case MEDIUM: |
767 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
768 |
|
op = addarg(op, "-dp 512"); |
769 |
< |
sprintf(op, " -ar %d", (int)(16*d)); |
769 |
> |
sprintf(op, " -ar %d", (int)(32*d)); |
770 |
|
op += strlen(op); |
771 |
|
sprintf(op, " -ms %.2g", asz/40.); |
772 |
|
op += strlen(op); |
774 |
|
case HIGH: |
775 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
776 |
|
op = addarg(op, "-dp 1024"); |
777 |
< |
sprintf(op, " -ar %d", (int)(32*d)); |
777 |
> |
sprintf(op, " -ar %d", (int)(64*d)); |
778 |
|
op += strlen(op); |
779 |
|
sprintf(op, " -ms %.2g", asz/80.); |
780 |
|
op += strlen(op); |
786 |
|
else |
787 |
|
op = addarg(op, "-ds .3"); |
788 |
|
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
789 |
< |
if (overture = vint(INDIRECT)) { |
789 |
> |
if ( (overture = vint(INDIRECT)) ) { |
790 |
|
sprintf(op, " -ab %d", overture); |
791 |
|
op += strlen(op); |
792 |
|
} |
797 |
|
overture = 0; |
798 |
|
switch (vscale(VARIABILITY)) { |
799 |
|
case LOW: |
800 |
< |
op = addarg(op, "-aa .25 -ad 196 -as 0"); |
800 |
> |
op = addarg(op, "-aa .2 -ad 329 -as 42"); |
801 |
|
break; |
802 |
|
case MEDIUM: |
803 |
< |
op = addarg(op, "-aa .2 -ad 400 -as 64"); |
803 |
> |
op = addarg(op, "-aa .15 -ad 800 -as 128"); |
804 |
|
break; |
805 |
|
case HIGH: |
806 |
< |
op = addarg(op, "-aa .15 -ad 768 -as 196"); |
806 |
> |
op = addarg(op, "-aa .1 -ad 1536 -as 392"); |
807 |
|
break; |
808 |
|
} |
809 |
|
d = ambval(); |
810 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
811 |
|
op += strlen(op); |
812 |
< |
op = addarg(op, "-lr 6 -lw .002"); |
812 |
> |
op = addarg(op, "-lr 8 -lw .002"); |
813 |
|
if (vdef(RENDER)) |
814 |
|
op = addarg(op, vval(RENDER)); |
815 |
|
} |
816 |
|
|
817 |
|
|
818 |
< |
hiqopts(op, po) /* high quality rendering options */ |
819 |
< |
register char *op; |
820 |
< |
char *po; |
818 |
> |
static void |
819 |
> |
hiqopts( /* high quality rendering options */ |
820 |
> |
register char *op, |
821 |
> |
char *po |
822 |
> |
) |
823 |
|
{ |
824 |
|
double d, org[3], siz[3], asz; |
825 |
|
|
829 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
830 |
|
badvalue(ZONE); |
831 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
832 |
< |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
832 |
> |
if ((siz[0] <= FTINY) | (siz[1] <= FTINY) | (siz[2] <= FTINY)) |
833 |
|
badvalue(ZONE); |
834 |
|
getoctcube(org, &d); |
835 |
|
asz = (siz[0]+siz[1]+siz[2])/3.; |
838 |
|
case LOW: |
839 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
840 |
|
op = addarg(op, "-dp 1024"); |
841 |
< |
sprintf(op, " -ar %d", (int)(16*d)); |
841 |
> |
sprintf(op, " -ar %d", (int)(32*d)); |
842 |
|
op += strlen(op); |
843 |
|
sprintf(op, " -ms %.2g", asz/40.); |
844 |
|
op += strlen(op); |
846 |
|
case MEDIUM: |
847 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
848 |
|
op = addarg(op, "-dp 2048"); |
849 |
< |
sprintf(op, " -ar %d", (int)(32*d)); |
849 |
> |
sprintf(op, " -ar %d", (int)(64*d)); |
850 |
|
op += strlen(op); |
851 |
|
sprintf(op, " -ms %.2g", asz/80.); |
852 |
|
op += strlen(op); |
854 |
|
case HIGH: |
855 |
|
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
856 |
|
op = addarg(op, "-dp 4096"); |
857 |
< |
sprintf(op, " -ar %d", (int)(64*d)); |
857 |
> |
sprintf(op, " -ar %d", (int)(128*d)); |
858 |
|
op += strlen(op); |
859 |
|
sprintf(op, " -ms %.2g", asz/160.); |
860 |
|
op += strlen(op); |
875 |
|
overture = 0; |
876 |
|
switch (vscale(VARIABILITY)) { |
877 |
|
case LOW: |
878 |
< |
op = addarg(op, "-aa .15 -ad 256 -as 0"); |
878 |
> |
op = addarg(op, "-aa .125 -ad 512 -as 64"); |
879 |
|
break; |
880 |
|
case MEDIUM: |
881 |
< |
op = addarg(op, "-aa .125 -ad 512 -as 256"); |
881 |
> |
op = addarg(op, "-aa .1 -ad 1536 -as 768"); |
882 |
|
break; |
883 |
|
case HIGH: |
884 |
< |
op = addarg(op, "-aa .08 -ad 1024 -as 512"); |
884 |
> |
op = addarg(op, "-aa .075 -ad 4096 -as 2048"); |
885 |
|
break; |
886 |
|
} |
887 |
|
d = ambval(); |
893 |
|
} |
894 |
|
|
895 |
|
|
896 |
< |
xferopts(ro) /* transfer options if indicated */ |
897 |
< |
char *ro; |
896 |
> |
static void |
897 |
> |
xferopts( /* transfer options if indicated */ |
898 |
> |
char *ro |
899 |
> |
) |
900 |
|
{ |
901 |
|
int fd, n; |
902 |
|
register char *cp; |
926 |
|
} |
927 |
|
|
928 |
|
|
929 |
< |
pfiltopts(po) /* get pfilt options */ |
930 |
< |
register char *po; |
929 |
> |
static void |
930 |
> |
pfiltopts( /* get pfilt options */ |
931 |
> |
register char *po |
932 |
> |
) |
933 |
|
{ |
934 |
|
*po = '\0'; |
935 |
|
if (vdef(EXPOSURE)) { |
949 |
|
} |
950 |
|
|
951 |
|
|
952 |
< |
matchword(s1, s2) /* match white-delimited words */ |
953 |
< |
register char *s1, *s2; |
952 |
> |
static int |
953 |
> |
matchword( /* match white-delimited words */ |
954 |
> |
register char *s1, |
955 |
> |
register char *s2 |
956 |
> |
) |
957 |
|
{ |
958 |
|
while (isspace(*s1)) s1++; |
959 |
|
while (isspace(*s2)) s2++; |
964 |
|
} |
965 |
|
|
966 |
|
|
967 |
< |
char * |
968 |
< |
specview(vs) /* get proper view spec from vs */ |
969 |
< |
register char *vs; |
967 |
> |
static char * |
968 |
> |
specview( /* get proper view spec from vs */ |
969 |
> |
register char *vs |
970 |
> |
) |
971 |
|
{ |
972 |
|
static char vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0", |
973 |
|
"-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"}; |
985 |
|
upax = 1-'X'+UPPER(vval(UP)[1]); |
986 |
|
else |
987 |
|
upax = 1-'X'+vlet(UP); |
988 |
< |
if (upax < 1 | upax > 3) |
988 |
> |
if ((upax < 1) | (upax > 3)) |
989 |
|
badvalue(UP); |
990 |
|
if (vval(UP)[0] == '-') |
991 |
|
upax = -upax; |
1008 |
|
zpos = -1; vs++; |
1009 |
|
} |
1010 |
|
viewtype = 'v'; |
1011 |
< |
if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c') |
1011 |
> |
if((*vs == 'v') | (*vs == 'l') | (*vs == 'a') | (*vs == 'h') | (*vs == 'c')) |
1012 |
|
viewtype = *vs++; |
1013 |
|
cp = viewopts; |
1014 |
|
if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */ |
1089 |
|
} |
1090 |
|
|
1091 |
|
|
1092 |
< |
char * |
1093 |
< |
getview(n, vn) /* get view n, or NULL if none */ |
1094 |
< |
int n; |
1095 |
< |
char *vn; /* returned view name */ |
1092 |
> |
static char * |
1093 |
> |
getview( /* get view n, or NULL if none */ |
1094 |
> |
int n, |
1095 |
> |
char *vn /* returned view name */ |
1096 |
> |
) |
1097 |
|
{ |
1098 |
|
register char *mv; |
1099 |
|
|
1120 |
|
return(specview(viewselect)); /* standard view? */ |
1121 |
|
} |
1122 |
|
mv = nvalue(VIEWS, n); /* use view n */ |
1123 |
< |
if (vn != NULL & mv != NULL) { |
1123 |
> |
if ((vn != NULL) & (mv != NULL)) { |
1124 |
|
register char *mv2 = mv; |
1125 |
|
if (*mv2 != '-') |
1126 |
|
while (*mv2 && !isspace(*mv2)) |
1131 |
|
} |
1132 |
|
|
1133 |
|
|
1134 |
< |
int |
1135 |
< |
myprintview(vopts, fp) /* print out selected view */ |
1136 |
< |
register char *vopts; |
1137 |
< |
FILE *fp; |
1134 |
> |
static int |
1135 |
> |
myprintview( /* print out selected view */ |
1136 |
> |
register char *vopts, |
1137 |
> |
FILE *fp |
1138 |
> |
) |
1139 |
|
{ |
1140 |
|
VIEW vwr; |
1141 |
|
char buf[128]; |
1142 |
|
register char *cp; |
1053 |
– |
again: |
1143 |
|
if (vopts == NULL) |
1144 |
|
return(-1); |
1145 |
|
#ifdef _WIN32 |
1148 |
|
goto again; |
1149 |
|
} |
1150 |
|
#endif |
1151 |
< |
copystruct(&vwr, &stdview); |
1151 |
> |
vwr = stdview; |
1152 |
|
sscanview(&vwr, cp=vopts); /* set initial options */ |
1153 |
|
while ((cp = strstr(cp, "-vf ")) != NULL && |
1154 |
|
*atos(buf, sizeof(buf), cp += 4)) { |
1162 |
|
} |
1163 |
|
|
1164 |
|
|
1165 |
< |
rview(opts, po) /* run rview with first view */ |
1166 |
< |
char *opts, *po; |
1165 |
> |
static void |
1166 |
> |
rvu( /* run rvu with first view */ |
1167 |
> |
char *opts, |
1168 |
> |
char *po |
1169 |
> |
) |
1170 |
|
{ |
1171 |
|
char *vw; |
1172 |
|
char combuf[PATH_MAX]; |
1175 |
|
return; |
1176 |
|
if (sayview) |
1177 |
|
myprintview(vw, stdout); |
1178 |
< |
sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname); |
1178 |
> |
sprintf(combuf, "rvu %s%s%s -R %s ", vw, po, opts, rifname); |
1179 |
|
if (rvdevice != NULL) |
1180 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
1181 |
|
if (vdef(EXPOSURE)) |
1182 |
|
sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); |
1183 |
|
strcat(combuf, oct1name); |
1184 |
|
if (runcom(combuf)) { /* run it */ |
1185 |
< |
fprintf(stderr, "%s: error running rview\n", progname); |
1185 |
> |
fprintf(stderr, "%s: error running rvu\n", progname); |
1186 |
|
quit(1); |
1187 |
|
} |
1188 |
|
} |
1189 |
|
|
1190 |
|
|
1191 |
< |
rpict(opts, po) /* run rpict and pfilt for each view */ |
1192 |
< |
char *opts, *po; |
1191 |
> |
static void |
1192 |
> |
rpict( /* run rpict and pfilt for each view */ |
1193 |
> |
char *opts, |
1194 |
> |
char *po |
1195 |
> |
) |
1196 |
|
{ |
1197 |
|
char combuf[PATH_MAX]; |
1198 |
|
char rawfile[PATH_MAX], picfile[PATH_MAX]; |
1244 |
|
badvalue(REPORT); |
1245 |
|
} |
1246 |
|
/* set up parallel rendering */ |
1247 |
< |
if (nprocs > 1 & !vdef(ZFILE)) { |
1247 |
> |
if ((nprocs > 1) & (!vdef(ZFILE))) { |
1248 |
|
strcpy(rppopt, "-S 1 -PP pfXXXXXX"); |
1249 |
|
pfile = rppopt+9; |
1250 |
|
if (mktemp(pfile) == NULL) |
1349 |
|
mvfile(rawfile, combuf); |
1350 |
|
} else |
1351 |
|
rmfile(rawfile); |
1352 |
< |
finish_process(); /* leave if child */ |
1352 |
> |
finish_process(); /* exit if child */ |
1353 |
|
} |
1354 |
|
wait_process(1); /* wait for children to finish */ |
1355 |
|
if (pfile != NULL) { /* clean up rpict persistent mode */ |
1357 |
|
fp = fopen(pfile, "r"); |
1358 |
|
if (fp != NULL) { |
1359 |
|
if (fscanf(fp, "%*s %d", &pid) != 1 || |
1360 |
< |
kill(pid, 1) == -1) |
1360 |
> |
kill(pid, 1) < 0) |
1361 |
|
unlink(pfile); |
1362 |
|
fclose(fp); |
1363 |
|
} |
1369 |
|
} |
1370 |
|
|
1371 |
|
|
1372 |
< |
touch(fn) /* update a file */ |
1373 |
< |
char *fn; |
1372 |
> |
static int |
1373 |
> |
touch( /* update a file */ |
1374 |
> |
char *fn |
1375 |
> |
) |
1376 |
|
{ |
1377 |
|
if (!silent) |
1378 |
|
printf("\ttouch %s\n", fn); |
1387 |
|
} |
1388 |
|
|
1389 |
|
|
1390 |
< |
runcom(cs) /* run command */ |
1391 |
< |
char *cs; |
1390 |
> |
static int |
1391 |
> |
runcom( /* run command */ |
1392 |
> |
char *cs |
1393 |
> |
) |
1394 |
|
{ |
1395 |
|
if (!silent) /* echo it */ |
1396 |
|
printf("\t%s\n", cs); |
1401 |
|
} |
1402 |
|
|
1403 |
|
|
1404 |
< |
rmfile(fn) /* remove a file */ |
1405 |
< |
char *fn; |
1404 |
> |
static int |
1405 |
> |
rmfile( /* remove a file */ |
1406 |
> |
char *fn |
1407 |
> |
) |
1408 |
|
{ |
1409 |
|
if (!silent) |
1410 |
< |
#ifdef _WIN32 |
1310 |
< |
printf("\tdel %s\n", fn); |
1311 |
< |
#else |
1312 |
< |
printf("\trm -f %s\n", fn); |
1313 |
< |
#endif |
1410 |
> |
printf("\t%s %s\n", DELCMD, fn); |
1411 |
|
if (!nprocs) |
1412 |
|
return(0); |
1413 |
|
return(unlink(fn)); |
1414 |
|
} |
1415 |
|
|
1416 |
|
|
1417 |
< |
mvfile(fold, fnew) /* move a file */ |
1418 |
< |
char *fold, *fnew; |
1417 |
> |
static int |
1418 |
> |
mvfile( /* move a file */ |
1419 |
> |
char *fold, |
1420 |
> |
char *fnew |
1421 |
> |
) |
1422 |
|
{ |
1423 |
|
if (!silent) |
1424 |
< |
#ifdef _WIN32 |
1325 |
< |
printf("\trename %s %s\n", fold, fnew); |
1326 |
< |
#else |
1327 |
< |
printf("\tmv %s %s\n", fold, fnew); |
1328 |
< |
#endif |
1424 |
> |
printf("\t%s %s %s\n", RENAMECMD, fold, fnew); |
1425 |
|
if (!nprocs) |
1426 |
|
return(0); |
1427 |
|
return(rename(fold, fnew)); |
1429 |
|
|
1430 |
|
|
1431 |
|
#ifdef RHAS_FORK_EXEC |
1432 |
< |
int |
1433 |
< |
next_process() /* fork the next process (max. nprocs) */ |
1432 |
> |
static int |
1433 |
> |
next_process(void) /* fork the next process (max. nprocs) */ |
1434 |
|
{ |
1435 |
|
int child_pid; |
1436 |
|
|
1437 |
|
if (nprocs <= 1) |
1438 |
|
return(0); /* it's us or no one */ |
1439 |
|
if (inchild()) { |
1440 |
< |
fprintf(stderr, "%s: internal error 1 in spawn_process()\n", |
1440 |
> |
fprintf(stderr, "%s: internal error 1 in next_process()\n", |
1441 |
|
progname); |
1442 |
|
quit(1); |
1443 |
|
} |
1457 |
|
return(0); |
1458 |
|
} |
1459 |
|
|
1460 |
< |
wait_process(all) /* wait for process(es) to finish */ |
1461 |
< |
int all; |
1460 |
> |
static void |
1461 |
> |
wait_process( /* wait for process(es) to finish */ |
1462 |
> |
int all |
1463 |
> |
) |
1464 |
|
{ |
1465 |
|
int ourstatus = 0; |
1466 |
|
int pid, status; |
1476 |
|
status = status>>8 & 0xff; |
1477 |
|
--children_running; |
1478 |
|
if (status != 0) { /* child's problem is our problem */ |
1479 |
< |
if (ourstatus == 0 & children_running > 0) |
1479 |
> |
if ((ourstatus == 0) & (children_running > 0)) |
1480 |
|
fprintf(stderr, "%s: waiting for remaining processes\n", |
1481 |
|
progname); |
1482 |
|
ourstatus = status; |
1487 |
|
quit(ourstatus); /* bad status from child */ |
1488 |
|
} |
1489 |
|
#else /* ! RHAS_FORK_EXEC */ |
1490 |
< |
int |
1491 |
< |
next_process() |
1490 |
> |
static int |
1491 |
> |
next_process(void) |
1492 |
|
{ |
1493 |
|
return(0); /* cannot start new process */ |
1494 |
|
} |
1495 |
+ |
static void |
1496 |
|
wait_process(all) |
1497 |
|
int all; |
1498 |
|
{ |
1499 |
|
(void)all; /* no one to wait for */ |
1500 |
|
} |
1501 |
+ |
int |
1502 |
+ |
kill(pid, sig) /* win|unix_process.c should also wait and kill */ |
1503 |
+ |
int pid, sig; |
1504 |
+ |
{ |
1505 |
+ |
return 0; |
1506 |
+ |
} |
1507 |
|
#endif /* ! RHAS_FORK_EXEC */ |
1508 |
|
|
1509 |
< |
finish_process() /* exit a child process */ |
1509 |
> |
static void |
1510 |
> |
finish_process(void) /* exit a child process */ |
1511 |
|
{ |
1512 |
|
if (!inchild()) |
1513 |
|
return; /* in parent -- noop */ |
1534 |
|
#endif |
1535 |
|
|
1536 |
|
|
1537 |
< |
badvalue(vc) /* report bad variable value and exit */ |
1538 |
< |
int vc; |
1537 |
> |
static void |
1538 |
> |
badvalue( /* report bad variable value and exit */ |
1539 |
> |
int vc |
1540 |
> |
) |
1541 |
|
{ |
1542 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
1543 |
|
progname, vnam(vc)); |
1545 |
|
} |
1546 |
|
|
1547 |
|
|
1548 |
< |
syserr(s) /* report a system error and exit */ |
1549 |
< |
char *s; |
1548 |
> |
static void |
1549 |
> |
syserr( /* report a system error and exit */ |
1550 |
> |
char *s |
1551 |
> |
) |
1552 |
|
{ |
1553 |
|
perror(s); |
1554 |
|
quit(1); |