| 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"; |
| 15 |
|
#include "view.h" |
| 16 |
|
#include "vars.h" |
| 17 |
|
#include "netproc.h" |
| 18 |
+ |
/* default remote shell */ |
| 19 |
+ |
#ifdef _AUX_SOURCE |
| 20 |
+ |
#define REMSH "remsh" |
| 21 |
+ |
#else |
| 22 |
+ |
#define REMSH "rsh" |
| 23 |
+ |
#endif |
| 24 |
|
/* input variables */ |
| 25 |
|
#define HOST 0 /* rendering host machine */ |
| 26 |
|
#define RENDER 1 /* rendering options */ |
| 44 |
|
#define DISKSPACE 19 /* how much disk space to use */ |
| 45 |
|
#define RESOLUTION 20 /* desired final resolution */ |
| 46 |
|
#define EXPOSURE 21 /* how to compute exposure */ |
| 47 |
+ |
#define RSH 22 /* remote shell script or program */ |
| 48 |
|
|
| 49 |
< |
int NVARS = 22; /* total number of variables */ |
| 49 |
> |
int NVARS = 23; /* total number of variables */ |
| 50 |
|
|
| 51 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
| 52 |
|
{"host", 4, 0, NULL, NULL}, |
| 71 |
|
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
| 72 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
| 73 |
|
{"EXPOSURE", 3, 0, NULL, onevalue}, |
| 74 |
+ |
{"RSH", 3, 0, NULL, onevalue}, |
| 75 |
|
}; |
| 76 |
|
|
| 77 |
|
#define SFNAME "STATUS" /* status file name */ |
| 92 |
|
int silent = 0; /* silent mode? */ |
| 93 |
|
int noaction = 0; /* take no action? */ |
| 94 |
|
|
| 95 |
+ |
char *remsh; /* remote shell program/script */ |
| 96 |
|
char rendopt[2048] = ""; /* rendering options */ |
| 97 |
|
char rresopt[32]; /* rendering resolution options */ |
| 98 |
|
char fresopt[32]; /* filter resolution options */ |
| 175 |
|
argv[i] = vval(NEXTANIM); /* just change input file */ |
| 176 |
|
if (!silent) |
| 177 |
|
printargs(argc, argv, stdout); |
| 178 |
< |
execvp(progname, argv); /* pass to next */ |
| 179 |
< |
quit(1); /* shouldn't return */ |
| 178 |
> |
if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL) |
| 179 |
> |
fprintf(stderr, "%s: command not found\n", progname); |
| 180 |
> |
else |
| 181 |
> |
execv(progname, argv); |
| 182 |
> |
quit(1); |
| 183 |
|
} |
| 184 |
|
quit(0); |
| 185 |
|
userr: |
| 216 |
|
goto fmterr; |
| 217 |
|
fclose(fp); |
| 218 |
|
if (astat.pid != 0) { /* thinks it's still running */ |
| 219 |
< |
gethostname(buf, sizeof(buf)); |
| 208 |
< |
if (strcmp(buf, astat.host)) { |
| 219 |
> |
if (strcmp(myhostname(), astat.host)) { |
| 220 |
|
fprintf(stderr, |
| 221 |
|
"%s: process %d may still be running on host %s\n", |
| 222 |
|
progname, astat.pid, astat.host); |
| 235 |
|
return(-1); |
| 236 |
|
} |
| 237 |
|
setours: /* set our values */ |
| 238 |
< |
gethostname(astat.host, sizeof(astat.host)); |
| 238 |
> |
strcpy(astat.host, myhostname()); |
| 239 |
|
astat.pid = getpid(); |
| 240 |
|
strcpy(astat.cfname, cfname); |
| 241 |
|
return(0); |
| 293 |
|
|
| 294 |
|
setdefaults() /* set default values */ |
| 295 |
|
{ |
| 296 |
+ |
extern char *atos(); |
| 297 |
|
char buf[256]; |
| 298 |
|
|
| 299 |
|
if (vdef(ANIMATE)) { |
| 359 |
|
vval(DISKSPACE) = "100"; |
| 360 |
|
vdef(DISKSPACE)++; |
| 361 |
|
} |
| 362 |
+ |
if (!vdef(RSH)) { |
| 363 |
+ |
vval(RSH) = REMSH; |
| 364 |
+ |
vdef(RSH)++; |
| 365 |
+ |
} |
| 366 |
+ |
/* locate remote shell program */ |
| 367 |
+ |
atos(buf, sizeof(buf), vval(RSH)); |
| 368 |
+ |
if ((remsh = getpath(buf, getenv("PATH"), X_OK)) != NULL) |
| 369 |
+ |
remsh = savqstr(remsh); |
| 370 |
+ |
else |
| 371 |
+ |
remsh = vval(RSH); /* will generate error if used */ |
| 372 |
+ |
|
| 373 |
|
/* append rendering options */ |
| 374 |
|
if (vdef(RENDER)) |
| 375 |
|
sprintf(rendopt+strlen(rendopt), " %s", vval(RENDER)); |
| 969 |
|
quit(1); |
| 970 |
|
} |
| 971 |
|
} else if (n < viewnum) { /* rewind file */ |
| 972 |
+ |
if (viewnum == 1 && feof(viewfp)) |
| 973 |
+ |
return(&curview); /* just one view */ |
| 974 |
|
if (fseek(viewfp, 0L, 0) == EOF) { |
| 975 |
|
perror(vval(VIEWFILE)); |
| 976 |
|
quit(1); |
| 980 |
|
} |
| 981 |
|
while (n > viewnum) { /* scan to desired view */ |
| 982 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
| 983 |
< |
return(NULL); |
| 983 |
> |
return(viewnum==1 ? &curview : NULL); |
| 984 |
|
if (isview(linebuf) && sscanview(&curview, linebuf) > 0) |
| 985 |
|
viewnum++; |
| 986 |
|
} |