22 |
|
#include <signal.h> |
23 |
|
|
24 |
|
#include "platform.h" |
25 |
< |
#include "paths.h" |
25 |
> |
#include "rtprocess.h" |
26 |
|
#include "standard.h" |
27 |
|
#include "view.h" |
28 |
|
#include "vars.h" |
66 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
67 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
68 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
69 |
< |
{"BASENAME", 3, 0, NULL, onevalue}, |
69 |
> |
{"BASENAME", 3, 0, NULL, strvalue}, |
70 |
|
{"DBLUR", 2, 0, NULL, onevalue}, |
71 |
< |
{"DIRECTORY", 3, 0, NULL, onevalue}, |
71 |
> |
{"DIRECTORY", 3, 0, NULL, strvalue}, |
72 |
|
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
73 |
|
{"END", 2, 0, NULL, intvalue}, |
74 |
|
{"EXPOSURE", 3, 0, NULL, onevalue}, |
75 |
|
{"host", 4, 0, NULL, NULL}, |
76 |
|
{"INTERPOLATE", 3, 0, NULL, intvalue}, |
77 |
|
{"MBLUR", 2, 0, NULL, onevalue}, |
78 |
< |
{"NEXTANIM", 3, 0, NULL, onevalue}, |
79 |
< |
{"OCTREE", 3, 0, NULL, onevalue}, |
78 |
> |
{"NEXTANIM", 3, 0, NULL, strvalue}, |
79 |
> |
{"OCTREE", 3, 0, NULL, strvalue}, |
80 |
|
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
81 |
|
{"pfilt", 2, 0, NULL, catvalues}, |
82 |
|
{"pinterp", 2, 0, NULL, catvalues}, |
83 |
|
{"render", 3, 0, NULL, catvalues}, |
84 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
85 |
< |
{"RIF", 3, 0, NULL, onevalue}, |
85 |
> |
{"RIF", 3, 0, NULL, strvalue}, |
86 |
|
{"RSH", 3, 0, NULL, onevalue}, |
87 |
|
{"RTRACE", 2, 0, NULL, boolvalue}, |
88 |
|
{"START", 2, 0, NULL, intvalue}, |
89 |
|
{"TRANSFER", 2, 0, NULL, onevalue}, |
90 |
< |
{"VIEWFILE", 2, 0, NULL, onevalue}, |
90 |
> |
{"VIEWFILE", 2, 0, NULL, strvalue}, |
91 |
|
}; |
92 |
|
|
93 |
|
#define SFNAME "STATUS" /* status file name */ |
94 |
|
|
95 |
|
struct { |
96 |
|
char host[64]; /* control host name */ |
97 |
< |
int pid; /* control process id */ |
97 |
> |
RT_PID pid; /* control process id */ |
98 |
|
char cfname[128]; /* control file name */ |
99 |
|
int rnext; /* next frame to render */ |
100 |
|
int fnext; /* next frame to filter */ |
101 |
|
int tnext; /* next frame to transfer */ |
102 |
|
} astat; /* animation status */ |
103 |
|
|
104 |
– |
char *progname; /* our program name */ |
104 |
|
char *cfname; /* our control file name */ |
105 |
|
|
106 |
|
int nowarn = 0; /* turn warnings off? */ |
117 |
|
char *arcfirst, *arcnext; /* pointers to first and next argument */ |
118 |
|
|
119 |
|
struct pslot { |
120 |
< |
int pid; /* process ID (0 if empty) */ |
120 |
> |
RT_PID pid; /* process ID (0 if empty) */ |
121 |
|
int fout; /* output frame number */ |
122 |
|
int (*rcvf)(); /* recover function */ |
123 |
|
} *pslot; /* process slots */ |
126 |
|
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
127 |
|
PSERVER *lastpserver; /* last process server with error */ |
128 |
|
|
129 |
< |
static struct pslot * findpslot(int pid); |
129 |
> |
static struct pslot * findpslot(RT_PID pid); |
130 |
|
static void checkdir(void); |
131 |
|
static VIEW * getview(int n); |
132 |
|
|
140 |
|
static int runcom(char *cs); |
141 |
|
static int pruncom(char *com, char *ppins, int maxcopies); |
142 |
|
static void bwait(int ncoms); |
143 |
< |
static int bruncom(char *com, int fout, int (*rf)()); |
143 |
> |
static RT_PID bruncom(char *com, int fout, int (*rf)()); |
144 |
|
static int serverdown(void); |
145 |
|
static pscompfunc donecom; |
146 |
|
static int countviews(void); |
167 |
|
{ |
168 |
|
int explicate = 0; |
169 |
|
int i; |
170 |
< |
|
171 |
< |
progname = argv[0]; /* get arguments */ |
170 |
> |
/* set global progname */ |
171 |
> |
fixargv0(argv[0]); |
172 |
> |
/* get arguments */ |
173 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) |
174 |
|
switch (argv[i][1]) { |
175 |
|
case 'e': /* print variables */ |
217 |
|
animate(); |
218 |
|
/* all done */ |
219 |
|
if (vdef(NEXTANIM)) { |
220 |
+ |
char *fullp; |
221 |
|
argv[i] = vval(NEXTANIM); /* just change input file */ |
222 |
|
if (!silent) |
223 |
|
printargs(argc, argv, stdout); |
224 |
< |
if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL) |
225 |
< |
fprintf(stderr, "%s: command not found\n", progname); |
224 |
> |
fflush(stdout); |
225 |
> |
if ((fullp = getpath(argv[0],getenv("PATH"),X_OK)) == NULL) |
226 |
> |
fprintf(stderr, "%s: command not found\n", argv[0]); |
227 |
|
else |
228 |
< |
execv(progname, argv); |
228 |
> |
execv(fullp, argv); |
229 |
|
quit(1); |
230 |
|
} |
231 |
|
quit(0); |
232 |
< |
return 0; /* pro forma return */ |
232 |
> |
return(0); /* pro forma return */ |
233 |
|
userr: |
234 |
|
fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname); |
235 |
|
quit(1); |
415 |
|
if (!vdef(DISKSPACE)) { |
416 |
|
if (!nowarn) |
417 |
|
fprintf(stderr, |
418 |
< |
"%s: warning - no %s setting, assuming 100 Mbytes available\n", |
418 |
> |
"%s: warning - no %s setting, assuming 1000 Mbytes available\n", |
419 |
|
progname, vnam(DISKSPACE)); |
420 |
< |
vval(DISKSPACE) = "100"; |
420 |
> |
vval(DISKSPACE) = "1000"; |
421 |
|
vdef(DISKSPACE)++; |
422 |
|
} |
423 |
|
if (!vdef(RSH)) { |
707 |
|
*cp++ = ' '; |
708 |
|
sprintf(cp, fbase, i); |
709 |
|
while (*cp) cp++; |
710 |
< |
strcpy(cp, ".pic"); |
710 |
> |
strcpy(cp, ".hdr"); |
711 |
|
cp += 4; |
712 |
|
} |
713 |
|
if (runcom(combuf)) { /* transfer frames */ |
945 |
|
usepfilt |= nora_rgbe; |
946 |
|
} else if (frseq[0] == frame) { /* no interpolation needed */ |
947 |
|
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
948 |
+ |
if (arcnext - arcargs + |
949 |
+ |
strlen(fbase) >= sizeof(arcargs)-8) { |
950 |
+ |
fprintf(stderr, |
951 |
+ |
"%s: too many filenames in archive command -- reduce %s variable\n", |
952 |
+ |
progname, vnam(DISKSPACE)); |
953 |
+ |
quit(1); |
954 |
+ |
} |
955 |
|
*arcnext++ = ' '; |
956 |
|
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
957 |
|
while (*arcnext) arcnext++; |
1060 |
|
} |
1061 |
|
/* output file name */ |
1062 |
|
sprintf(fname0, vval(BASENAME), frame); |
1063 |
< |
sprintf(combuf+strlen(combuf), " > %s.pic", fname0); |
1063 |
> |
sprintf(combuf+strlen(combuf), " > %s.hdr", fname0); |
1064 |
|
if (rvr) /* in recovery */ |
1065 |
|
return(runcom(combuf)); |
1066 |
|
bruncom(combuf, frame, frecover); /* else run in background */ |
1133 |
|
static char * |
1134 |
|
getexp(int n) /* get exposure for nth frame */ |
1135 |
|
{ |
1127 |
– |
extern char *fskip(); |
1136 |
|
static char expval[32]; |
1137 |
|
static FILE *expfp = NULL; |
1138 |
|
static long *exppos; |
1200 |
|
|
1201 |
|
|
1202 |
|
static struct pslot * |
1203 |
< |
findpslot(int pid) /* find or allocate a process slot */ |
1203 |
> |
findpslot(RT_PID pid) /* find or allocate a process slot */ |
1204 |
|
{ |
1205 |
|
register struct pslot *psempty = NULL; |
1206 |
|
register int i; |
1274 |
|
} |
1275 |
|
|
1276 |
|
|
1277 |
< |
static int |
1277 |
> |
static RT_PID |
1278 |
|
bruncom( /* run a command in the background */ |
1279 |
|
char *com, |
1280 |
|
int fout, |
1281 |
|
int (*rf)() |
1282 |
|
) |
1283 |
|
{ |
1284 |
< |
int pid; |
1284 |
> |
RT_PID pid; |
1285 |
|
register struct pslot *psl; |
1286 |
|
|
1287 |
|
if (noaction) { |
1294 |
|
bwait(1); |
1295 |
|
if (!silent) { /* echo command */ |
1296 |
|
PSERVER *ps; |
1297 |
< |
int psn = pid; |
1297 |
> |
RT_PID psn = pid; |
1298 |
|
ps = findjob(&psn); |
1299 |
|
printf("\t%s\n", com); |
1300 |
|
printf("\tProcess started on %s\n", phostname(ps)); |
1411 |
|
rmfile(char *fn) /* remove a file */ |
1412 |
|
{ |
1413 |
|
if (!silent) |
1414 |
< |
#ifdef _WIN32 |
1414 |
> |
#if defined(_WIN32) || defined(_WIN64) |
1415 |
|
printf("\tdel %s\n", fn); |
1416 |
|
#else |
1417 |
|
printf("\trm -f %s\n", fn); |
1464 |
|
int nmblur, ndblur; |
1465 |
|
char *s; |
1466 |
|
/* get motion blur */ |
1467 |
< |
if (!vdef(MBLUR) || (mblurf = atof(vval(MBLUR))) < 0.0) |
1467 |
> |
if (vdef(ANIMATE) || !vdef(MBLUR) || (mblurf = atof(vval(MBLUR))) < 0.0) |
1468 |
|
mblurf = 0.0; |
1469 |
|
if (mbf != NULL) |
1470 |
|
*mbf = mblurf; |