| 1 |
< |
/* Copyright (c) 1995 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1996 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 118 |
|
VIEW *getview(); |
| 119 |
|
char *getexp(); |
| 120 |
|
|
| 121 |
+ |
extern time_t fdate(), time(); |
| 122 |
|
|
| 123 |
+ |
|
| 124 |
|
main(argc, argv) |
| 125 |
|
int argc; |
| 126 |
|
char *argv[]; |
| 177 |
|
argv[i] = vval(NEXTANIM); /* just change input file */ |
| 178 |
|
if (!silent) |
| 179 |
|
printargs(argc, argv, stdout); |
| 180 |
< |
execvp(progname, argv); /* pass to next */ |
| 181 |
< |
quit(1); /* shouldn't return */ |
| 180 |
> |
if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL) |
| 181 |
> |
fprintf(stderr, "%s: command not found\n", progname); |
| 182 |
> |
else |
| 183 |
> |
execv(progname, argv); |
| 184 |
> |
quit(1); |
| 185 |
|
} |
| 186 |
|
quit(0); |
| 187 |
|
userr: |
| 192 |
|
|
| 193 |
|
getastat() /* check/set animation status */ |
| 194 |
|
{ |
| 195 |
< |
char buf[256]; |
| 195 |
> |
char sfname[256]; |
| 196 |
|
FILE *fp; |
| 197 |
|
|
| 198 |
< |
sprintf(buf, "%s/%s", vval(DIRECTORY), SFNAME); |
| 199 |
< |
if ((fp = fopen(buf, "r")) == NULL) { |
| 198 |
> |
sprintf(sfname, "%s/%s", vval(DIRECTORY), SFNAME); |
| 199 |
> |
if ((fp = fopen(sfname, "r")) == NULL) { |
| 200 |
|
if (errno != ENOENT) { |
| 201 |
< |
perror(buf); |
| 201 |
> |
perror(sfname); |
| 202 |
|
return(-1); |
| 203 |
|
} |
| 204 |
|
astat.rnext = astat.fnext = astat.tnext = 0; |
| 236 |
|
progname, astat.cfname); |
| 237 |
|
return(-1); |
| 238 |
|
} |
| 239 |
+ |
/* check control file mods. */ |
| 240 |
+ |
if (!nowarn && fdate(cfname) > fdate(sfname)) |
| 241 |
+ |
fprintf(stderr, |
| 242 |
+ |
"%s: warning - control file modified since last run\n", |
| 243 |
+ |
progname); |
| 244 |
|
setours: /* set our values */ |
| 245 |
|
strcpy(astat.host, myhostname()); |
| 246 |
|
astat.pid = getpid(); |
| 248 |
|
return(0); |
| 249 |
|
fmterr: |
| 250 |
|
fprintf(stderr, "%s: format error in status file \"%s\"\n", |
| 251 |
< |
progname, buf); |
| 251 |
> |
progname, sfname); |
| 252 |
|
fclose(fp); |
| 253 |
|
return(-1); |
| 254 |
|
} |
| 482 |
|
i = sscanf(vval(RESOLUTION), "%d %d %f", &xres, &yres, &pa); |
| 483 |
|
mult = vflt(OVERSAMP); |
| 484 |
|
if (i == 3) { |
| 485 |
< |
sprintf(rresopt, "-x %d -y %d -pa %f", (int)(mult*xres), |
| 485 |
> |
sprintf(rresopt, "-x %d -y %d -pa %.3f", (int)(mult*xres), |
| 486 |
|
(int)(mult*yres), pa); |
| 487 |
< |
sprintf(fresopt, "-x %d -y %d -pa %f", xres, yres, pa); |
| 487 |
> |
sprintf(fresopt, "-x %d -y %d -pa %.3f", xres, yres, pa); |
| 488 |
|
} else if (i) { |
| 489 |
|
if (i == 1) yres = xres; |
| 490 |
|
sprintf(rresopt, "-x %d -y %d", (int)(mult*xres), |
| 512 |
|
/* figure # frames per batch */ |
| 513 |
|
d1 = mult*xres*mult*yres*4; /* space for orig. picture */ |
| 514 |
|
if ((i=vint(INTERP)) || atoi(vval(MBLUR))) |
| 515 |
< |
d1 += mult*xres*mult*yres*4; /* space for z-buffer */ |
| 515 |
> |
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ |
| 516 |
|
d2 = xres*yres*4; /* space for final picture */ |
| 517 |
|
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); |
| 518 |
|
if (frames_batch < i+2) { |
| 841 |
|
while (*arcnext) arcnext++; |
| 842 |
|
strcpy(arcnext, ".unf"); |
| 843 |
|
arcnext += 4; |
| 844 |
< |
if (usepinterp || vint(INTERP)) { /* and z-buf */ |
| 844 |
> |
if (usepinterp || vint(INTERP)) { /* and Z-buf */ |
| 845 |
|
*arcnext++ = ' '; |
| 846 |
|
sprintf(arcnext, vval(BASENAME), |
| 847 |
|
frame-vint(INTERP)-1); |
| 987 |
|
} |
| 988 |
|
while (n > viewnum) { /* scan to desired view */ |
| 989 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
| 990 |
< |
return(viewnum==1 ? &curview : NULL); |
| 990 |
> |
return(viewnum==1 ? &curview : (VIEW *)NULL); |
| 991 |
|
if (isview(linebuf) && sscanview(&curview, linebuf) > 0) |
| 992 |
|
viewnum++; |
| 993 |
|
} |
| 1020 |
|
if (n == 0) { /* signal to close file */ |
| 1021 |
|
if (expfp != NULL) { |
| 1022 |
|
fclose(expfp); |
| 1023 |
+ |
free((char *)exppos); |
| 1024 |
|
expfp = NULL; |
| 1025 |
|
} |
| 1026 |
|
return(NULL); |
| 1027 |
< |
} |
| 1027 |
> |
} else if (n > vint(END)) /* request past end (error?) */ |
| 1028 |
> |
return(NULL); |
| 1029 |
|
if (!vdef(EXPOSURE)) /* no setting (auto) */ |
| 1030 |
|
return(NULL); |
| 1031 |
|
if (isflt(vval(EXPOSURE))) /* always the same */ |
| 1063 |
|
} |
| 1064 |
|
curfrm++; |
| 1065 |
|
cp = fskip(expval); /* check format */ |
| 1066 |
< |
if (cp == NULL || *cp != '\n') { |
| 1066 |
> |
if (cp != NULL) |
| 1067 |
> |
while (isspace(*cp)) |
| 1068 |
> |
*cp++ = '\0'; |
| 1069 |
> |
if (cp == NULL || *cp) { |
| 1070 |
|
fprintf(stderr, |
| 1071 |
|
"%s: exposure format error on line %d\n", |
| 1072 |
|
vval(EXPOSURE), curfrm); |
| 1073 |
|
quit(1); |
| 1074 |
|
} |
| 1060 |
– |
*cp = '\0'; |
| 1075 |
|
} |
| 1076 |
|
return(expval); /* return value */ |
| 1077 |
|
} |
| 1200 |
|
{ |
| 1201 |
|
int retstatus = 0; |
| 1202 |
|
int hostcopies; |
| 1203 |
< |
char com1buf[10240], *com1, *endcom1; |
| 1203 |
> |
char buf[10240], *com1; |
| 1204 |
> |
PSERVER *mps[64]; |
| 1205 |
> |
int nmps = 0; |
| 1206 |
|
int status; |
| 1207 |
+ |
int pfd; |
| 1208 |
+ |
register int n; |
| 1209 |
|
register PSERVER *ps; |
| 1210 |
|
|
| 1211 |
|
if (!silent) |
| 1217 |
|
for (ps = pslist; ps != NULL; ps = ps->next) { |
| 1218 |
|
hostcopies = 0; |
| 1219 |
|
if (maxcopies > 1 && ps->nprocs > 1 && ppins != NULL) { |
| 1220 |
< |
strcpy(com1=com1buf, com); /* build -PP command */ |
| 1220 |
> |
strcpy(com1=buf, com); /* build -PP command */ |
| 1221 |
|
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
| 1222 |
|
vval(DIRECTORY), phostname(ps)); |
| 1223 |
|
strcat(com1, ppins); |
| 1224 |
< |
endcom1 = com1 + strlen(com1); |
| 1225 |
< |
sprintf(endcom1, "; kill `sed -n '1s/^[^ ]* //p' %s/%s.persist`", |
| 1208 |
< |
vval(DIRECTORY), phostname(ps)); |
| 1209 |
< |
} else { |
| 1224 |
> |
mps[nmps++] = ps; |
| 1225 |
> |
} else |
| 1226 |
|
com1 = com; |
| 1211 |
– |
endcom1 = NULL; |
| 1212 |
– |
} |
| 1227 |
|
while (maxcopies > 0 && |
| 1228 |
|
startjob(ps, savestr(com1), donecom) != -1) { |
| 1229 |
< |
sleep(10); |
| 1229 |
> |
sleep(60); |
| 1230 |
|
hostcopies++; |
| 1231 |
|
maxcopies--; |
| 1218 |
– |
if (endcom1 != NULL) |
| 1219 |
– |
*endcom1 = '\0'; |
| 1232 |
|
} |
| 1233 |
|
if (!silent && hostcopies) { |
| 1234 |
|
if (hostcopies > 1) |
| 1243 |
|
while ((status = wait4job(NULL, -1)) != -1) |
| 1244 |
|
if (status) |
| 1245 |
|
retstatus += !serverdown(); /* check server */ |
| 1246 |
+ |
/* terminate parallel rpict's */ |
| 1247 |
+ |
while (nmps--) { |
| 1248 |
+ |
sprintf(buf, "%s/%s.persist", |
| 1249 |
+ |
vval(DIRECTORY), phostname(mps[nmps])); |
| 1250 |
+ |
if ((pfd = open(buf, O_RDONLY)) >= 0) { |
| 1251 |
+ |
n = read(pfd, buf, sizeof(buf)-1); /* get PID */ |
| 1252 |
+ |
buf[n] = '\0'; |
| 1253 |
+ |
close(pfd); |
| 1254 |
+ |
for (n = 0; buf[n] && !isspace(buf[n]); n++) |
| 1255 |
+ |
; |
| 1256 |
+ |
/* terminate */ |
| 1257 |
+ |
sprintf(buf, "kill -ALRM %d", atoi(buf+n)); |
| 1258 |
+ |
wait4job(mps[nmps], startjob(mps[nmps], buf, NULL)); |
| 1259 |
+ |
} |
| 1260 |
+ |
} |
| 1261 |
|
return(retstatus); |
| 1262 |
|
} |
| 1263 |
|
|