115 |
|
PSERVER *lastpserver; /* last process server with error */ |
116 |
|
|
117 |
|
VIEW *getview(); |
118 |
< |
char *getexp(); |
118 |
> |
char *getexp(), *dirfile(); |
119 |
|
|
120 |
|
extern time_t fdate(), time(); |
121 |
|
|
536 |
|
quit(1); |
537 |
|
} |
538 |
|
/* initialize archive argument list */ |
539 |
< |
i = 16; |
540 |
< |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i) |
541 |
< |
i = strlen(vval(ARCHIVE)); |
539 |
> |
i = vdef(ARCHIVE) ? strlen(vval(ARCHIVE))+132 : 132; |
540 |
|
arcnext = arcfirst = arcargs + i; |
541 |
|
/* initialize status file */ |
542 |
|
if (astat.rnext == 0) |
640 |
|
|
641 |
|
transferframes() /* catch up with picture transfers */ |
642 |
|
{ |
643 |
< |
char combuf[10240]; |
643 |
> |
char combuf[10240], *fbase; |
644 |
|
register char *cp; |
645 |
|
register int i; |
646 |
|
|
651 |
|
putastat(); /* update status */ |
652 |
|
return; |
653 |
|
} |
654 |
< |
strcpy(combuf, vval(TRANSFER)); /* start transfer command */ |
655 |
< |
cp = combuf + strlen(combuf); |
654 |
> |
strcpy(combuf, "cd "); /* start transfer command */ |
655 |
> |
fbase = dirfile(cp = combuf+3, vval(BASENAME)); |
656 |
> |
if (*cp) { |
657 |
> |
while (*++cp) ; |
658 |
> |
*cp++ = ';'; *cp++ = ' '; |
659 |
> |
} else |
660 |
> |
cp = combuf; |
661 |
> |
strcpy(cp, vval(TRANSFER)); |
662 |
> |
while (*cp) cp++; |
663 |
|
/* make argument list */ |
664 |
|
for (i = astat.tnext; i < astat.fnext; i++) { |
665 |
|
*cp++ = ' '; |
666 |
< |
sprintf(cp, vval(BASENAME), i); |
666 |
> |
sprintf(cp, fbase, i); |
667 |
|
while (*cp) cp++; |
668 |
|
strcpy(cp, ".pic"); |
669 |
|
cp += 4; |
712 |
|
close(open(combuf, O_RDONLY|O_CREAT, 0666)); |
713 |
|
} |
714 |
|
/* create command */ |
715 |
< |
sprintf(combuf, "rpict%s -w0", rendopt); |
715 |
> |
sprintf(combuf, "rpict%s%s -w0", rendopt, |
716 |
> |
viewopt(getview(first>1 ? first-1 : 1))); |
717 |
|
if (vint(INTERP) || atoi(vval(MBLUR))) |
718 |
|
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
719 |
|
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
805 |
|
{ |
806 |
|
#define RMCOML (sizeof(rmcom)-1) |
807 |
|
static char rmcom[] = "rm -f"; |
808 |
< |
register int i; |
808 |
> |
char basedir[128]; |
809 |
> |
int dlen, alen; |
810 |
> |
register int j; |
811 |
|
|
812 |
|
if (arcnext == arcfirst) |
813 |
|
return; /* nothing to do */ |
814 |
+ |
dirfile(basedir, vval(BASENAME)); |
815 |
+ |
dlen = strlen(basedir); |
816 |
|
if (vdef(ARCHIVE)) { /* run archive command */ |
817 |
< |
i = strlen(vval(ARCHIVE)); |
818 |
< |
strncpy(arcfirst-i, vval(ARCHIVE), i); |
819 |
< |
if (runcom(arcfirst-i)) { |
817 |
> |
alen = strlen(vval(ARCHIVE)); |
818 |
> |
if (dlen) { |
819 |
> |
j = alen + dlen + 5; |
820 |
> |
strncpy(arcfirst-j, "cd ", 3); |
821 |
> |
strncpy(arcfirst-j+3, basedir, dlen); |
822 |
> |
(arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' '; |
823 |
> |
} else |
824 |
> |
j = alen; |
825 |
> |
strncpy(arcfirst-alen, vval(ARCHIVE), alen); |
826 |
> |
if (runcom(arcfirst-j)) { |
827 |
|
fprintf(stderr, "%s: error running archive command\n", |
828 |
|
progname); |
829 |
|
quit(1); |
830 |
|
} |
831 |
|
} |
832 |
+ |
if (dlen) { |
833 |
+ |
j = RMCOML + dlen + 5; |
834 |
+ |
strncpy(arcfirst-j, "cd ", 3); |
835 |
+ |
strncpy(arcfirst-j+3, basedir, dlen); |
836 |
+ |
(arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' '; |
837 |
+ |
} else |
838 |
+ |
j = RMCOML; |
839 |
|
/* run remove command */ |
840 |
|
strncpy(arcfirst-RMCOML, rmcom, RMCOML); |
841 |
< |
runcom(arcfirst-RMCOML); |
841 |
> |
runcom(arcfirst-j); |
842 |
|
arcnext = arcfirst; /* reset argument list */ |
843 |
|
#undef RMCOML |
844 |
|
} |
853 |
|
{ |
854 |
|
extern int frecover(); |
855 |
|
static int iter = 0; |
856 |
< |
char fnbefore[128], fnafter[128]; |
856 |
> |
char fnbefore[128], fnafter[128], *fbase; |
857 |
|
char combuf[1024], fname0[128], fname1[128]; |
858 |
|
int usepinterp, usepfilt, nora_rgbe; |
859 |
|
int frseq[2]; |
867 |
|
/* compute rendered views */ |
868 |
|
frseq[0] = frame - ((frame-1) % (vint(INTERP)+1)); |
869 |
|
frseq[1] = frseq[0] + vint(INTERP) + 1; |
870 |
+ |
fbase = dirfile(NULL, vval(BASENAME)); |
871 |
|
if (frseq[1] > vint(END)) |
872 |
|
frseq[1] = vint(END); |
873 |
|
if (frseq[1] == frame) { /* pfilt only */ |
877 |
|
} else if (frseq[0] == frame) { /* no interpolation needed */ |
878 |
|
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
879 |
|
*arcnext++ = ' '; |
880 |
< |
sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); |
880 |
> |
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
881 |
|
while (*arcnext) arcnext++; |
882 |
|
strcpy(arcnext, ".unf"); |
883 |
|
arcnext += 4; |
884 |
|
if (usepinterp || vint(INTERP)) { /* and Z-buf */ |
885 |
|
*arcnext++ = ' '; |
886 |
< |
sprintf(arcnext, vval(BASENAME), |
862 |
< |
frame-vint(INTERP)-1); |
886 |
> |
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
887 |
|
while (*arcnext) arcnext++; |
888 |
|
strcpy(arcnext, ".zbf"); |
889 |
|
arcnext += 4; |
904 |
|
if (rvr == 2 && recover(frseq[1])) /* recover after? */ |
905 |
|
return(1); |
906 |
|
if (atoi(vval(MBLUR))) { |
883 |
– |
FILE *fp; /* motion blurring */ |
907 |
|
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
908 |
|
'a'+(iter%26)); |
886 |
– |
if ((fp = fopen(fname0, "w")) == NULL) { |
887 |
– |
perror(fname0); quit(1); |
888 |
– |
} |
889 |
– |
fputs(VIEWSTR, fp); |
890 |
– |
fprintview(vp, fp); |
891 |
– |
putc('\n', fp); fclose(fp); |
892 |
– |
if ((vp = getview(frame+1)) == NULL) { |
893 |
– |
fprintf(stderr, |
894 |
– |
"%s: unexpected error reading view for frame %d\n", |
895 |
– |
progname, frame+1); |
896 |
– |
quit(1); |
897 |
– |
} |
909 |
|
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
910 |
|
'a'+(iter%26)); |
911 |
< |
if ((fp = fopen(fname1, "w")) == NULL) { |
912 |
< |
perror(fname1); quit(1); |
911 |
> |
if (!noaction) { |
912 |
> |
FILE *fp; /* motion blurring */ |
913 |
> |
if ((fp = fopen(fname0, "w")) == NULL) { |
914 |
> |
perror(fname0); quit(1); |
915 |
> |
} |
916 |
> |
fputs(VIEWSTR, fp); |
917 |
> |
fprintview(vp, fp); |
918 |
> |
putc('\n', fp); fclose(fp); |
919 |
> |
if ((vp = getview(frame+1)) == NULL) { |
920 |
> |
fprintf(stderr, |
921 |
> |
"%s: unexpected error reading view for frame %d\n", |
922 |
> |
progname, frame+1); |
923 |
> |
quit(1); |
924 |
> |
} |
925 |
> |
if ((fp = fopen(fname1, "w")) == NULL) { |
926 |
> |
perror(fname1); quit(1); |
927 |
> |
} |
928 |
> |
fputs(VIEWSTR, fp); |
929 |
> |
fprintview(vp, fp); |
930 |
> |
putc('\n', fp); fclose(fp); |
931 |
|
} |
903 |
– |
fputs(VIEWSTR, fp); |
904 |
– |
fprintview(vp, fp); |
905 |
– |
putc('\n', fp); fclose(fp); |
932 |
|
sprintf(combuf, |
933 |
|
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
934 |
|
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
1011 |
|
} |
1012 |
|
return(NULL); |
1013 |
|
} |
1014 |
< |
if (viewfp == NULL) { /* open file */ |
1014 |
> |
if (viewfp == NULL) { /* open file */ |
1015 |
|
if ((viewfp = fopen(vval(VIEWFILE), "r")) == NULL) { |
1016 |
|
perror(vval(VIEWFILE)); |
1017 |
|
quit(1); |
1018 |
|
} |
1019 |
< |
} else if (n < viewnum) { /* rewind file */ |
1019 |
> |
} else if (n > 0 && n < viewnum) { /* rewind file */ |
1020 |
|
if (viewnum == 1 && feof(viewfp)) |
1021 |
|
return(&curview); /* just one view */ |
1022 |
|
if (fseek(viewfp, 0L, 0) == EOF) { |
1026 |
|
copystruct(&curview, &stdview); |
1027 |
|
viewnum = 0; |
1028 |
|
} |
1029 |
+ |
if (n < 0) { /* get next view */ |
1030 |
+ |
register int c = getc(viewfp); |
1031 |
+ |
if (c == EOF) |
1032 |
+ |
return((VIEW *)NULL); /* that's it */ |
1033 |
+ |
ungetc(c, viewfp); |
1034 |
+ |
n = viewnum + 1; |
1035 |
+ |
} |
1036 |
|
while (n > viewnum) { /* scan to desired view */ |
1037 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
1038 |
|
return(viewnum==1 ? &curview : (VIEW *)NULL); |
1046 |
|
int |
1047 |
|
countviews() /* count views in view file */ |
1048 |
|
{ |
1049 |
< |
register int n = 0; |
1049 |
> |
int n; |
1050 |
|
|
1051 |
< |
while (getview(n+1) != NULL) |
1051 |
> |
if (getview(n=1) == NULL) |
1052 |
> |
return(0); |
1053 |
> |
while (getview(-1) != NULL) |
1054 |
|
n++; |
1055 |
|
return(n); |
1056 |
|
} |
1352 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
1353 |
|
progname, vnam(vc)); |
1354 |
|
quit(1); |
1355 |
+ |
} |
1356 |
+ |
|
1357 |
+ |
|
1358 |
+ |
char * |
1359 |
+ |
dirfile(df, path) /* separate path into directory and file */ |
1360 |
+ |
char *df; |
1361 |
+ |
register char *path; |
1362 |
+ |
{ |
1363 |
+ |
register int i; |
1364 |
+ |
int psep; |
1365 |
+ |
|
1366 |
+ |
for (i = 0, psep = -1; path[i]; i++) |
1367 |
+ |
if (path[i] == '/') |
1368 |
+ |
psep = i; |
1369 |
+ |
if (df != NULL) |
1370 |
+ |
if (psep == 0) { |
1371 |
+ |
df[0] = '/'; |
1372 |
+ |
df[1] = '\0'; |
1373 |
+ |
} else if (psep > 0) { |
1374 |
+ |
strncpy(df, path, psep); |
1375 |
+ |
df[psep] = '\0'; |
1376 |
+ |
} else |
1377 |
+ |
df[0] = '\0'; |
1378 |
+ |
return(path+psep+1); |
1379 |
|
} |