15 |
|
|
16 |
|
#include "copyright.h" |
17 |
|
|
18 |
< |
#include "standard.h" |
18 |
> |
#include <stdio.h> |
19 |
|
#include <ctype.h> |
20 |
|
#include <sys/stat.h> |
21 |
+ |
#include <time.h> |
22 |
+ |
#include <signal.h> |
23 |
+ |
|
24 |
+ |
#include "platform.h" |
25 |
+ |
#include "paths.h" |
26 |
+ |
#include "standard.h" |
27 |
|
#include "view.h" |
28 |
|
#include "vars.h" |
29 |
|
#include "netproc.h" |
32 |
|
#define DEF_NBLUR 5 |
33 |
|
#endif |
34 |
|
/* default remote shell */ |
29 |
– |
#ifdef _AUX_SOURCE |
30 |
– |
#define REMSH "remsh" |
31 |
– |
#else |
35 |
|
#define REMSH "rsh" |
33 |
– |
#endif |
36 |
|
/* input variables (alphabetical by name) */ |
37 |
|
#define ANIMATE 0 /* animation command */ |
38 |
|
#define ARCHIVE 1 /* archiving command */ |
121 |
|
int npslots; /* number of process slots */ |
122 |
|
|
123 |
|
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
122 |
– |
|
123 |
– |
struct pslot *findpslot(); |
124 |
– |
|
124 |
|
PSERVER *lastpserver; /* last process server with error */ |
125 |
|
|
126 |
< |
VIEW *getview(); |
127 |
< |
char *getexp(), *dirfile(); |
128 |
< |
int getblur(); |
126 |
> |
static struct pslot * findpslot(int pid); |
127 |
> |
static void checkdir(void); |
128 |
> |
static VIEW * getview(int n); |
129 |
|
|
130 |
< |
extern time_t time(); |
130 |
> |
static char * dirfile(char *df, register char *path); |
131 |
> |
static char * getexp(int n); |
132 |
> |
static int getblur(double *bf); |
133 |
> |
static int getastat(void); |
134 |
> |
static void getradfile(char *rfargs); |
135 |
> |
static void badvalue(int vc); |
136 |
> |
static int rmfile(char *fn); |
137 |
> |
static int runcom(char *cs); |
138 |
> |
static int pruncom(char *com, char *ppins, int maxcopies); |
139 |
> |
static void bwait(int ncoms); |
140 |
> |
static int bruncom(char *com, int fout, int (*rf)()); |
141 |
> |
static int serverdown(void); |
142 |
> |
static pscompfunc donecom; |
143 |
> |
static int countviews(void); |
144 |
> |
static int dofilt(int frame, int rvr); |
145 |
> |
static void archive(void); |
146 |
> |
static int frecover(int frame); |
147 |
> |
static int recover(int frame); |
148 |
> |
static void sethosts(void); |
149 |
> |
static void walkwait(int first, int last, char *vfn); |
150 |
> |
static void animrend(int frame, VIEW *vp); |
151 |
> |
static void transferframes(void); |
152 |
> |
static void filterframes(void); |
153 |
> |
static void renderframes(int nframes); |
154 |
> |
static void animate(void); |
155 |
> |
static void setdefaults(void); |
156 |
> |
static void putastat(void); |
157 |
|
|
158 |
|
|
159 |
< |
main(argc, argv) |
160 |
< |
int argc; |
161 |
< |
char *argv[]; |
159 |
> |
int |
160 |
> |
main( |
161 |
> |
int argc, |
162 |
> |
char *argv[] |
163 |
> |
) |
164 |
|
{ |
165 |
|
int explicate = 0; |
166 |
|
int i; |
223 |
|
quit(1); |
224 |
|
} |
225 |
|
quit(0); |
226 |
+ |
return 0; /* pro forma return */ |
227 |
|
userr: |
228 |
|
fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname); |
229 |
|
quit(1); |
230 |
+ |
return 1; /* pro forma return */ |
231 |
|
} |
232 |
|
|
233 |
|
|
234 |
< |
getastat() /* check/set animation status */ |
234 |
> |
static int |
235 |
> |
getastat(void) /* check/set animation status */ |
236 |
|
{ |
237 |
|
char sfname[256]; |
238 |
|
FILE *fp; |
296 |
|
} |
297 |
|
|
298 |
|
|
299 |
< |
putastat() /* put out current status */ |
299 |
> |
static void |
300 |
> |
putastat(void) /* put out current status */ |
301 |
|
{ |
302 |
|
char buf[256]; |
303 |
|
FILE *fp; |
319 |
|
} |
320 |
|
|
321 |
|
|
322 |
< |
checkdir() /* make sure we have our directory */ |
322 |
> |
static void |
323 |
> |
checkdir(void) /* make sure we have our directory */ |
324 |
|
{ |
325 |
|
struct stat stb; |
326 |
|
|
342 |
|
} |
343 |
|
|
344 |
|
|
345 |
< |
setdefaults() /* set default values */ |
345 |
> |
static void |
346 |
> |
setdefaults(void) /* set default values */ |
347 |
|
{ |
348 |
|
extern char *atos(); |
349 |
|
int decades; |
431 |
|
} |
432 |
|
|
433 |
|
|
434 |
< |
sethosts() /* set up process servers */ |
434 |
> |
static void |
435 |
> |
sethosts(void) /* set up process servers */ |
436 |
|
{ |
437 |
|
extern char *iskip(); |
438 |
|
char buf[256], *dir, *uname; |
487 |
|
} |
488 |
|
} |
489 |
|
|
490 |
< |
|
491 |
< |
getradfile(rfargs) /* run rad and get needed variables */ |
458 |
< |
char *rfargs; |
490 |
> |
static void |
491 |
> |
getradfile(char *rfargs) /* run rad and get needed variables */ |
492 |
|
{ |
493 |
|
static short mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1}; |
494 |
|
char combuf[256]; |
495 |
|
register int i; |
496 |
|
register char *cp; |
497 |
< |
char *pippt; |
497 |
> |
char *pippt = NULL; |
498 |
|
/* create rad command */ |
499 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
500 |
|
sprintf(combuf, |
513 |
|
pippt = NULL; |
514 |
|
} |
515 |
|
if (pippt != NULL) |
516 |
< |
strcpy(pippt, "> /dev/null"); /* nothing to match */ |
516 |
> |
strcpy(pippt, "> " NULL_DEVICE); /* nothing to match */ |
517 |
|
else { |
518 |
|
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
519 |
|
cp += 11; /* point to file name */ |
526 |
|
} |
527 |
|
|
528 |
|
|
529 |
< |
animate() /* run animation */ |
529 |
> |
static void |
530 |
> |
animate(void) /* run animation */ |
531 |
|
{ |
532 |
|
int xres, yres; |
533 |
|
float pa, mult; |
598 |
|
} |
599 |
|
|
600 |
|
|
601 |
< |
renderframes(nframes) /* render next nframes frames */ |
602 |
< |
int nframes; |
601 |
> |
static void |
602 |
> |
renderframes(int nframes) /* render next nframes frames */ |
603 |
|
{ |
604 |
|
static char vendbuf[16]; |
605 |
|
VIEW *vp; |
655 |
|
} |
656 |
|
|
657 |
|
|
658 |
< |
filterframes() /* catch up with filtering */ |
658 |
> |
static void |
659 |
> |
filterframes(void) /* catch up with filtering */ |
660 |
|
{ |
626 |
– |
VIEW *vp; |
661 |
|
register int i; |
662 |
|
|
663 |
|
if (astat.tnext < astat.fnext) /* other work to do first */ |
664 |
|
return; |
665 |
|
/* filter each view */ |
666 |
< |
for (i = astat.fnext; i < astat.rnext; i++) { |
667 |
< |
if ((vp = getview(i)) == NULL) { /* get view i */ |
668 |
< |
fprintf(stderr, |
635 |
< |
"%s: unexpected error reading view for frame %d\n", |
636 |
< |
progname, i); |
637 |
< |
quit(1); |
638 |
< |
} |
639 |
< |
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
640 |
< |
} |
666 |
> |
for (i = astat.fnext; i < astat.rnext; i++) |
667 |
> |
dofilt(i, 0); |
668 |
> |
|
669 |
|
bwait(0); /* wait for filter processes */ |
670 |
|
archive(); /* archive originals */ |
671 |
|
astat.fnext = i; /* update status */ |
673 |
|
} |
674 |
|
|
675 |
|
|
676 |
< |
transferframes() /* catch up with picture transfers */ |
676 |
> |
static void |
677 |
> |
transferframes(void) /* catch up with picture transfers */ |
678 |
|
{ |
679 |
|
char combuf[10240], *fbase; |
680 |
|
register char *cp; |
714 |
|
} |
715 |
|
|
716 |
|
|
717 |
< |
animrend(frame, vp) /* start animation frame */ |
718 |
< |
int frame; |
719 |
< |
VIEW *vp; |
717 |
> |
static void |
718 |
> |
animrend( /* start animation frame */ |
719 |
> |
int frame, |
720 |
> |
VIEW *vp |
721 |
> |
) |
722 |
|
{ |
692 |
– |
extern int recover(); |
723 |
|
char combuf[2048]; |
724 |
|
char fname[128]; |
725 |
|
|
733 |
|
} |
734 |
|
|
735 |
|
|
736 |
< |
walkwait(first, last, vfn) /* walk-through frames */ |
737 |
< |
int first, last; |
738 |
< |
char *vfn; |
736 |
> |
static void |
737 |
> |
walkwait( /* walk-through frames */ |
738 |
> |
int first, |
739 |
> |
int last, |
740 |
> |
char *vfn |
741 |
> |
) |
742 |
|
{ |
743 |
|
double blurf; |
744 |
|
int nblur = getblur(&blurf); |
788 |
|
} |
789 |
|
|
790 |
|
|
791 |
< |
int |
792 |
< |
recover(frame) /* recover the specified frame */ |
760 |
< |
int frame; |
791 |
> |
static int |
792 |
> |
recover(int frame) /* recover the specified frame */ |
793 |
|
{ |
794 |
|
static int *rfrm; /* list of recovered frames */ |
795 |
|
static int nrfrms = 0; |
842 |
|
} |
843 |
|
|
844 |
|
|
845 |
< |
int |
846 |
< |
frecover(frame) /* recover filtered frame */ |
815 |
< |
int frame; |
845 |
> |
static int |
846 |
> |
frecover(int frame) /* recover filtered frame */ |
847 |
|
{ |
848 |
< |
VIEW *vp; |
818 |
< |
char *ex; |
819 |
< |
|
820 |
< |
vp = getview(frame); |
821 |
< |
ex = getexp(frame); |
822 |
< |
if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1)) |
848 |
> |
if (dofilt(frame, 2) && dofilt(frame, 1)) |
849 |
|
return(1); |
850 |
|
return(0); |
851 |
|
} |
852 |
|
|
853 |
|
|
854 |
< |
archive() /* archive and remove renderings */ |
854 |
> |
static void |
855 |
> |
archive(void) /* archive and remove renderings */ |
856 |
|
{ |
857 |
|
#define RMCOML (sizeof(rmcom)-1) |
858 |
|
static char rmcom[] = "rm -f"; |
895 |
|
} |
896 |
|
|
897 |
|
|
898 |
< |
int |
899 |
< |
dofilt(frame, vp, ep, rvr) /* filter frame */ |
900 |
< |
int frame; |
901 |
< |
VIEW *vp; |
902 |
< |
char *ep; |
876 |
< |
int rvr; |
898 |
> |
static int |
899 |
> |
dofilt( /* filter frame */ |
900 |
> |
int frame, |
901 |
> |
int rvr |
902 |
> |
) |
903 |
|
{ |
878 |
– |
extern int frecover(); |
904 |
|
static int iter = 0; |
905 |
|
double blurf; |
906 |
|
int nblur = getblur(&blurf); |
907 |
+ |
VIEW *vp = getview(frame); |
908 |
+ |
char *ep = getexp(frame); |
909 |
|
char fnbefore[128], fnafter[128], *fbase; |
910 |
|
char combuf[1024], fname0[128], fname1[128]; |
911 |
|
int usepinterp, usepfilt, nora_rgbe; |
912 |
|
int frseq[2]; |
913 |
|
/* check what is needed */ |
914 |
+ |
if (vp == NULL) { |
915 |
+ |
fprintf(stderr, |
916 |
+ |
"%s: unexpected error reading view for frame %d\n", |
917 |
+ |
progname, frame); |
918 |
+ |
quit(1); |
919 |
+ |
} |
920 |
|
usepinterp = (nblur > 1); |
921 |
< |
usepfilt = pfiltalways | ep==NULL; |
921 |
> |
usepfilt = pfiltalways | (ep==NULL); |
922 |
|
if (ep != NULL && !strcmp(ep, "1")) |
923 |
|
ep = "+0"; |
924 |
|
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL || |
1051 |
|
} |
1052 |
|
|
1053 |
|
|
1054 |
< |
VIEW * |
1055 |
< |
getview(n) /* get view number n */ |
1023 |
< |
int n; |
1054 |
> |
static VIEW * |
1055 |
> |
getview(int n) /* get view number n */ |
1056 |
|
{ |
1057 |
|
static FILE *viewfp = NULL; /* view file pointer */ |
1058 |
|
static int viewnum = 0; /* current view number */ |
1064 |
|
fclose(viewfp); |
1065 |
|
viewfp = NULL; |
1066 |
|
viewnum = 0; |
1067 |
< |
copystruct(&curview, &stdview); |
1067 |
> |
curview = stdview; |
1068 |
|
} |
1069 |
|
return(NULL); |
1070 |
|
} |
1080 |
|
perror(vval(VIEWFILE)); |
1081 |
|
quit(1); |
1082 |
|
} |
1083 |
< |
copystruct(&curview, &stdview); |
1083 |
> |
curview = stdview; |
1084 |
|
viewnum = 0; |
1085 |
|
} |
1086 |
|
if (n < 0) { /* get next view */ |
1100 |
|
} |
1101 |
|
|
1102 |
|
|
1103 |
< |
int |
1104 |
< |
countviews() /* count views in view file */ |
1103 |
> |
static int |
1104 |
> |
countviews(void) /* count views in view file */ |
1105 |
|
{ |
1106 |
|
int n; |
1107 |
|
|
1113 |
|
} |
1114 |
|
|
1115 |
|
|
1116 |
< |
char * |
1117 |
< |
getexp(n) /* get exposure for nth frame */ |
1086 |
< |
int n; |
1116 |
> |
static char * |
1117 |
> |
getexp(int n) /* get exposure for nth frame */ |
1118 |
|
{ |
1119 |
|
extern char *fskip(); |
1120 |
|
static char expval[32]; |
1183 |
|
} |
1184 |
|
|
1185 |
|
|
1186 |
< |
struct pslot * |
1187 |
< |
findpslot(pid) /* find or allocate a process slot */ |
1157 |
< |
int pid; |
1186 |
> |
static struct pslot * |
1187 |
> |
findpslot(int pid) /* find or allocate a process slot */ |
1188 |
|
{ |
1189 |
|
register struct pslot *psempty = NULL; |
1190 |
|
register int i; |
1199 |
|
} |
1200 |
|
|
1201 |
|
|
1202 |
< |
int |
1203 |
< |
donecom(ps, pn, status) /* clean up after finished process */ |
1204 |
< |
PSERVER *ps; |
1205 |
< |
int pn; |
1206 |
< |
int status; |
1202 |
> |
static int |
1203 |
> |
donecom( /* clean up after finished process */ |
1204 |
> |
PSERVER *ps, |
1205 |
> |
int pn, |
1206 |
> |
int status |
1207 |
> |
) |
1208 |
|
{ |
1209 |
< |
register PROC *pp; |
1209 |
> |
register NETPROC *pp; |
1210 |
|
register struct pslot *psl; |
1211 |
|
|
1212 |
|
pp = ps->proc + pn; |
1241 |
|
} |
1242 |
|
|
1243 |
|
|
1244 |
< |
int |
1245 |
< |
serverdown() /* check status of last process server */ |
1244 |
> |
static int |
1245 |
> |
serverdown(void) /* check status of last process server */ |
1246 |
|
{ |
1247 |
|
if (lastpserver == NULL || !lastpserver->hostname[0]) |
1248 |
|
return(0); |
1258 |
|
} |
1259 |
|
|
1260 |
|
|
1261 |
< |
int |
1262 |
< |
bruncom(com, fout, rf) /* run a command in the background */ |
1263 |
< |
char *com; |
1264 |
< |
int fout; |
1265 |
< |
int (*rf)(); |
1261 |
> |
static int |
1262 |
> |
bruncom( /* run a command in the background */ |
1263 |
> |
char *com, |
1264 |
> |
int fout, |
1265 |
> |
int (*rf)() |
1266 |
> |
) |
1267 |
|
{ |
1268 |
|
int pid; |
1269 |
|
register struct pslot *psl; |
1292 |
|
} |
1293 |
|
|
1294 |
|
|
1295 |
< |
bwait(ncoms) /* wait for batch job(s) to finish */ |
1296 |
< |
int ncoms; |
1295 |
> |
static void |
1296 |
> |
bwait(int ncoms) /* wait for batch job(s) to finish */ |
1297 |
|
{ |
1298 |
|
int status; |
1299 |
|
|
1307 |
|
} |
1308 |
|
|
1309 |
|
|
1310 |
< |
int |
1311 |
< |
pruncom(com, ppins, maxcopies) /* run a command in parallel over network */ |
1312 |
< |
char *com, *ppins; |
1313 |
< |
int maxcopies; |
1310 |
> |
static int |
1311 |
> |
pruncom( /* run a command in parallel over network */ |
1312 |
> |
char *com, |
1313 |
> |
char *ppins, |
1314 |
> |
int maxcopies |
1315 |
> |
) |
1316 |
|
{ |
1317 |
|
int retstatus = 0; |
1318 |
|
int hostcopies; |
1334 |
|
strcpy(com1=buf, com); /* build -PP command */ |
1335 |
|
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1336 |
|
vval(DIRECTORY), phostname(ps)); |
1337 |
+ |
unlink(com1+(ppins-com)+5); |
1338 |
|
strcat(com1, ppins); |
1339 |
|
} else |
1340 |
|
com1 = com; |
1379 |
|
} |
1380 |
|
|
1381 |
|
|
1382 |
< |
runcom(cs) /* run a command locally and wait for it */ |
1383 |
< |
char *cs; |
1382 |
> |
static int |
1383 |
> |
runcom(char *cs) /* run a command locally and wait for it */ |
1384 |
|
{ |
1385 |
|
if (!silent) /* echo it */ |
1386 |
|
printf("\t%s\n", cs); |
1391 |
|
} |
1392 |
|
|
1393 |
|
|
1394 |
< |
rmfile(fn) /* remove a file */ |
1395 |
< |
char *fn; |
1394 |
> |
static int |
1395 |
> |
rmfile(char *fn) /* remove a file */ |
1396 |
|
{ |
1397 |
|
if (!silent) |
1398 |
< |
#ifdef MSDOS |
1398 |
> |
#ifdef _WIN32 |
1399 |
|
printf("\tdel %s\n", fn); |
1400 |
|
#else |
1401 |
|
printf("\trm -f %s\n", fn); |
1406 |
|
} |
1407 |
|
|
1408 |
|
|
1409 |
< |
badvalue(vc) /* report bad variable value and exit */ |
1410 |
< |
int vc; |
1409 |
> |
static void |
1410 |
> |
badvalue(int vc) /* report bad variable value and exit */ |
1411 |
|
{ |
1412 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
1413 |
|
progname, vnam(vc)); |
1415 |
|
} |
1416 |
|
|
1417 |
|
|
1418 |
< |
char * |
1419 |
< |
dirfile(df, path) /* separate path into directory and file */ |
1420 |
< |
char *df; |
1421 |
< |
register char *path; |
1418 |
> |
static char * |
1419 |
> |
dirfile( /* separate path into directory and file */ |
1420 |
> |
char *df, |
1421 |
> |
register char *path |
1422 |
> |
) |
1423 |
|
{ |
1424 |
|
register int i; |
1425 |
|
int psep; |
1427 |
|
for (i = 0, psep = -1; path[i]; i++) |
1428 |
|
if (path[i] == '/') |
1429 |
|
psep = i; |
1430 |
< |
if (df != NULL) |
1430 |
> |
if (df != NULL) { |
1431 |
|
if (psep == 0) { |
1432 |
|
df[0] = '/'; |
1433 |
|
df[1] = '\0'; |
1436 |
|
df[psep] = '\0'; |
1437 |
|
} else |
1438 |
|
df[0] = '\0'; |
1439 |
+ |
} |
1440 |
|
return(path+psep+1); |
1441 |
|
} |
1442 |
|
|
1443 |
|
|
1444 |
< |
int |
1444 |
> |
static int |
1445 |
|
getblur(double *bf) /* get # blur samples (and fraction) */ |
1446 |
|
{ |
1447 |
|
double blurf; |