1 |
greg |
2.1 |
#ifndef lint |
2 |
greg |
2.38 |
static const char RCSid[] = "$Id: rpmain.c,v 2.37 2025/01/18 03:49:00 greg Exp $"; |
3 |
greg |
2.1 |
#endif |
4 |
|
|
/* |
5 |
|
|
* rpmain.c - main for rpict batch rendering program |
6 |
|
|
*/ |
7 |
|
|
|
8 |
greg |
2.2 |
#include "copyright.h" |
9 |
greg |
2.1 |
|
10 |
greg |
2.10 |
#include <time.h> |
11 |
schorsch |
2.3 |
#include <signal.h> |
12 |
|
|
|
13 |
|
|
#include "platform.h" |
14 |
schorsch |
2.6 |
#include "rtprocess.h" /* getpid() */ |
15 |
greg |
2.1 |
#include "ray.h" |
16 |
greg |
2.38 |
#include "func.h" |
17 |
greg |
2.1 |
#include "source.h" |
18 |
|
|
#include "ambient.h" |
19 |
|
|
#include "random.h" |
20 |
|
|
#include "paths.h" |
21 |
|
|
#include "view.h" |
22 |
greg |
2.16 |
#include "pmapray.h" |
23 |
greg |
2.1 |
|
24 |
|
|
/* persistent processes define */ |
25 |
|
|
#ifdef F_SETLKW |
26 |
|
|
#define PERSIST 1 /* normal persist */ |
27 |
|
|
#define PARALLEL 2 /* parallel persist */ |
28 |
|
|
#define PCHILD 3 /* child of normal persist */ |
29 |
|
|
#endif |
30 |
|
|
|
31 |
|
|
char *progname; /* argv[0] */ |
32 |
|
|
char *octname; /* octree name */ |
33 |
|
|
char *sigerr[NSIG]; /* signal error messages */ |
34 |
|
|
char *errfile = NULL; /* error output file */ |
35 |
greg |
2.37 |
|
36 |
greg |
2.1 |
extern time_t time(); |
37 |
|
|
extern time_t tstart; /* start time */ |
38 |
|
|
|
39 |
|
|
extern int ralrm; /* seconds between reports */ |
40 |
|
|
|
41 |
|
|
extern VIEW ourview; /* viewing parameters */ |
42 |
|
|
|
43 |
|
|
extern int hresolu; /* horizontal resolution */ |
44 |
|
|
extern int vresolu; /* vertical resolution */ |
45 |
|
|
extern double pixaspect; /* pixel aspect ratio */ |
46 |
|
|
|
47 |
|
|
extern int psample; /* pixel sample size */ |
48 |
|
|
extern double maxdiff; /* max. sample difference */ |
49 |
|
|
extern double dstrpix; /* square pixel distribution */ |
50 |
|
|
|
51 |
|
|
extern double mblur; /* motion blur parameter */ |
52 |
|
|
|
53 |
greg |
2.9 |
extern double dblur; /* depth-of-field blur parameter */ |
54 |
|
|
|
55 |
greg |
2.28 |
RGBPRIMP out_prims = stdprims; /* output color primitives */ |
56 |
|
|
static RGBPRIMS our_prims; /* private output color primitives */ |
57 |
|
|
|
58 |
schorsch |
2.8 |
static void onsig(int signo); |
59 |
|
|
static void sigdie(int signo, char *msg); |
60 |
|
|
static void printdefaults(void); |
61 |
greg |
2.21 |
/* rpict additional features */ |
62 |
|
|
#ifdef PERSIST |
63 |
|
|
#define RPICT_FEATURES "Persist\nParallelPersist\n" \ |
64 |
greg |
2.29 |
"ParticipatingMedia=Mist\n" \ |
65 |
greg |
2.22 |
"Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
66 |
|
|
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
67 |
|
|
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
68 |
|
|
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
69 |
greg |
2.32 |
"AdaptiveShadowTesting\nOutputs=v,l\n" \ |
70 |
greg |
2.33 |
"OutputCS=RGB,XYZ,prims\n" |
71 |
greg |
2.21 |
#else |
72 |
|
|
#define RPICT_FEATURES "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
73 |
greg |
2.29 |
"ParticipatingMedia=Mist\n" \ |
74 |
greg |
2.22 |
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
75 |
|
|
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
76 |
|
|
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
77 |
greg |
2.32 |
"AdaptiveShadowTesting\nOutputs=v,l\n" \ |
78 |
greg |
2.33 |
"OutputCS=RGB,XYZ,prims\n" |
79 |
greg |
2.21 |
#endif |
80 |
greg |
2.1 |
|
81 |
|
|
|
82 |
|
|
int |
83 |
schorsch |
2.8 |
main(int argc, char *argv[]) |
84 |
greg |
2.1 |
{ |
85 |
|
|
#define check(ol,al) if (argv[i][ol] || \ |
86 |
|
|
badarg(argc-i-1,argv+i+1,al)) \ |
87 |
|
|
goto badopt |
88 |
schorsch |
2.18 |
#define check_bool(olen,var) switch (argv[i][olen]) { \ |
89 |
greg |
2.1 |
case '\0': var = !var; break; \ |
90 |
|
|
case 'y': case 'Y': case 't': case 'T': \ |
91 |
|
|
case '+': case '1': var = 1; break; \ |
92 |
|
|
case 'n': case 'N': case 'f': case 'F': \ |
93 |
|
|
case '-': case '0': var = 0; break; \ |
94 |
|
|
default: goto badopt; } |
95 |
|
|
char *err; |
96 |
|
|
char *recover = NULL; |
97 |
|
|
char *outfile = NULL; |
98 |
|
|
char *zfile = NULL; |
99 |
|
|
int loadflags = ~IO_FILES; |
100 |
|
|
int seqstart = 0; |
101 |
|
|
int persist = 0; |
102 |
greg |
2.15 |
int duped1 = -1; |
103 |
greg |
2.1 |
int rval; |
104 |
|
|
int i; |
105 |
|
|
/* record start time */ |
106 |
|
|
tstart = time((time_t *)NULL); |
107 |
|
|
/* global program name */ |
108 |
|
|
progname = argv[0] = fixargv0(argv[0]); |
109 |
greg |
2.21 |
/* feature check only? */ |
110 |
|
|
strcat(RFeatureList, RPICT_FEATURES); |
111 |
greg |
2.25 |
if (argc > 1 && !strcmp(argv[1], "-features")) |
112 |
greg |
2.21 |
return feature_status(argc-2, argv+2); |
113 |
greg |
2.38 |
/* initialize calcomp routines */ |
114 |
|
|
initfunc(); |
115 |
greg |
2.1 |
/* option city */ |
116 |
|
|
for (i = 1; i < argc; i++) { |
117 |
|
|
/* expand arguments */ |
118 |
|
|
while ((rval = expandarg(&argc, &argv, i)) > 0) |
119 |
|
|
; |
120 |
|
|
if (rval < 0) { |
121 |
|
|
sprintf(errmsg, "cannot expand '%s'", argv[i]); |
122 |
|
|
error(SYSTEM, errmsg); |
123 |
|
|
} |
124 |
|
|
if (argv[i] == NULL || argv[i][0] != '-') |
125 |
|
|
break; /* break from options */ |
126 |
|
|
if (!strcmp(argv[i], "-version")) { |
127 |
|
|
puts(VersionID); |
128 |
|
|
quit(0); |
129 |
|
|
} |
130 |
|
|
if (!strcmp(argv[i], "-defaults") || |
131 |
|
|
!strcmp(argv[i], "-help")) { |
132 |
|
|
printdefaults(); |
133 |
|
|
quit(0); |
134 |
|
|
} |
135 |
|
|
rval = getrenderopt(argc-i, argv+i); |
136 |
|
|
if (rval >= 0) { |
137 |
|
|
i += rval; |
138 |
|
|
continue; |
139 |
|
|
} |
140 |
|
|
rval = getviewopt(&ourview, argc-i, argv+i); |
141 |
|
|
if (rval >= 0) { |
142 |
|
|
i += rval; |
143 |
|
|
continue; |
144 |
|
|
} |
145 |
|
|
/* rpict options */ |
146 |
|
|
switch (argv[i][1]) { |
147 |
|
|
case 'v': /* view file */ |
148 |
|
|
if (argv[i][2] != 'f') |
149 |
|
|
goto badopt; |
150 |
|
|
check(3,"s"); |
151 |
|
|
rval = viewfile(argv[++i], &ourview, NULL); |
152 |
|
|
if (rval < 0) { |
153 |
|
|
sprintf(errmsg, |
154 |
|
|
"cannot open view file \"%s\"", |
155 |
|
|
argv[i]); |
156 |
|
|
error(SYSTEM, errmsg); |
157 |
|
|
} else if (rval == 0) { |
158 |
|
|
sprintf(errmsg, |
159 |
|
|
"bad view file \"%s\"", |
160 |
|
|
argv[i]); |
161 |
|
|
error(USER, errmsg); |
162 |
|
|
} |
163 |
|
|
break; |
164 |
|
|
case 'p': /* pixel */ |
165 |
|
|
switch (argv[i][2]) { |
166 |
|
|
case 's': /* sample */ |
167 |
|
|
check(3,"i"); |
168 |
|
|
psample = atoi(argv[++i]); |
169 |
|
|
break; |
170 |
|
|
case 't': /* threshold */ |
171 |
|
|
check(3,"f"); |
172 |
|
|
maxdiff = atof(argv[++i]); |
173 |
|
|
break; |
174 |
|
|
case 'j': /* jitter */ |
175 |
|
|
check(3,"f"); |
176 |
|
|
dstrpix = atof(argv[++i]); |
177 |
|
|
break; |
178 |
|
|
case 'a': /* aspect */ |
179 |
|
|
check(3,"f"); |
180 |
|
|
pixaspect = atof(argv[++i]); |
181 |
|
|
break; |
182 |
|
|
case 'm': /* motion */ |
183 |
|
|
check(3,"f"); |
184 |
|
|
mblur = atof(argv[++i]); |
185 |
|
|
break; |
186 |
greg |
2.9 |
case 'd': /* aperture */ |
187 |
|
|
check(3,"f"); |
188 |
|
|
dblur = atof(argv[++i]); |
189 |
|
|
break; |
190 |
greg |
2.28 |
case 'R': /* standard RGB output */ |
191 |
|
|
if (strcmp(argv[i]+2, "RGB")) |
192 |
|
|
goto badopt; |
193 |
|
|
out_prims = stdprims; |
194 |
|
|
break; |
195 |
|
|
case 'X': /* XYZ output */ |
196 |
|
|
if (strcmp(argv[i]+2, "XYZ")) |
197 |
|
|
goto badopt; |
198 |
|
|
out_prims = xyzprims; |
199 |
|
|
break; |
200 |
|
|
case 'c': { /* chromaticities */ |
201 |
|
|
int j; |
202 |
|
|
check(3,"ffffffff"); |
203 |
|
|
rval = 0; |
204 |
|
|
for (j = 0; j < 8; j++) { |
205 |
|
|
our_prims[0][j] = atof(argv[++i]); |
206 |
|
|
rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001; |
207 |
|
|
} |
208 |
|
|
if (rval) { |
209 |
|
|
if (!colorprimsOK(our_prims)) |
210 |
|
|
error(USER, "illegal primary chromaticities"); |
211 |
|
|
out_prims = our_prims; |
212 |
|
|
} else |
213 |
|
|
out_prims = stdprims; |
214 |
|
|
} break; |
215 |
greg |
2.1 |
default: |
216 |
|
|
goto badopt; |
217 |
|
|
} |
218 |
|
|
break; |
219 |
|
|
case 'x': /* x resolution */ |
220 |
|
|
check(2,"i"); |
221 |
|
|
hresolu = atoi(argv[++i]); |
222 |
|
|
break; |
223 |
|
|
case 'y': /* y resolution */ |
224 |
|
|
check(2,"i"); |
225 |
|
|
vresolu = atoi(argv[++i]); |
226 |
|
|
break; |
227 |
|
|
case 'S': /* slave index */ |
228 |
|
|
check(2,"i"); |
229 |
|
|
seqstart = atoi(argv[++i]); |
230 |
|
|
break; |
231 |
|
|
case 'o': /* output file */ |
232 |
|
|
check(2,"s"); |
233 |
|
|
outfile = argv[++i]; |
234 |
|
|
break; |
235 |
|
|
case 'z': /* z file */ |
236 |
|
|
check(2,"s"); |
237 |
|
|
zfile = argv[++i]; |
238 |
|
|
break; |
239 |
|
|
case 'r': /* recover file */ |
240 |
|
|
if (argv[i][2] == 'o') { /* +output */ |
241 |
|
|
check(3,"s"); |
242 |
|
|
outfile = argv[i+1]; |
243 |
|
|
} else |
244 |
|
|
check(2,"s"); |
245 |
|
|
recover = argv[++i]; |
246 |
|
|
break; |
247 |
|
|
#ifdef PERSIST |
248 |
|
|
case 'P': /* persist file */ |
249 |
|
|
if (argv[i][2] == 'P') { |
250 |
|
|
check(3,"s"); |
251 |
|
|
persist = PARALLEL; |
252 |
|
|
} else { |
253 |
|
|
check(2,"s"); |
254 |
|
|
persist = PERSIST; |
255 |
|
|
} |
256 |
|
|
persistfile(argv[++i]); |
257 |
|
|
break; |
258 |
|
|
#endif |
259 |
greg |
2.36 |
case 't': /* timer */ |
260 |
|
|
check(2,"i"); |
261 |
|
|
ralrm = atoi(argv[++i]); |
262 |
|
|
break; |
263 |
greg |
2.1 |
case 'w': /* warnings */ |
264 |
|
|
rval = erract[WARNING].pf != NULL; |
265 |
schorsch |
2.18 |
check_bool(2,rval); |
266 |
greg |
2.1 |
if (rval) erract[WARNING].pf = wputs; |
267 |
|
|
else erract[WARNING].pf = NULL; |
268 |
|
|
break; |
269 |
|
|
case 'e': /* error file */ |
270 |
|
|
check(2,"s"); |
271 |
|
|
errfile = argv[++i]; |
272 |
|
|
break; |
273 |
|
|
default: |
274 |
|
|
goto badopt; |
275 |
|
|
} |
276 |
|
|
} |
277 |
greg |
2.30 |
/* set/check spectral sampling */ |
278 |
greg |
2.31 |
if (setspectrsamp(CNDX, WLPART) <= 0) |
279 |
greg |
2.30 |
error(USER, "unsupported spectral sampling"); |
280 |
|
|
|
281 |
greg |
2.1 |
err = setview(&ourview); /* set viewing parameters */ |
282 |
|
|
if (err != NULL) |
283 |
|
|
error(USER, err); |
284 |
|
|
/* initialize object types */ |
285 |
|
|
initotypes(); |
286 |
|
|
/* initialize urand */ |
287 |
greg |
2.12 |
if (rand_samp) { |
288 |
|
|
srandom((long)time(0)); |
289 |
|
|
initurand(0); |
290 |
|
|
} else { |
291 |
|
|
srandom(0L); |
292 |
|
|
initurand(2048); |
293 |
|
|
} |
294 |
greg |
2.1 |
/* set up signal handling */ |
295 |
|
|
sigdie(SIGINT, "Interrupt"); |
296 |
schorsch |
2.4 |
#ifdef SIGHUP |
297 |
greg |
2.1 |
sigdie(SIGHUP, "Hangup"); |
298 |
schorsch |
2.4 |
#endif |
299 |
greg |
2.1 |
sigdie(SIGTERM, "Terminate"); |
300 |
schorsch |
2.4 |
#ifdef SIGPIPE |
301 |
greg |
2.1 |
sigdie(SIGPIPE, "Broken pipe"); |
302 |
schorsch |
2.4 |
#endif |
303 |
|
|
#ifdef SIGALRM |
304 |
greg |
2.1 |
sigdie(SIGALRM, "Alarm clock"); |
305 |
schorsch |
2.4 |
#endif |
306 |
greg |
2.1 |
#ifdef SIGXCPU |
307 |
|
|
sigdie(SIGXCPU, "CPU limit exceeded"); |
308 |
|
|
sigdie(SIGXFSZ, "File size exceeded"); |
309 |
|
|
#endif |
310 |
|
|
/* open error file */ |
311 |
|
|
if (errfile != NULL) { |
312 |
|
|
if (freopen(errfile, "a", stderr) == NULL) |
313 |
|
|
quit(2); |
314 |
|
|
fprintf(stderr, "**************\n*** PID %5d: ", |
315 |
|
|
getpid()); |
316 |
|
|
printargs(argc, argv, stderr); |
317 |
|
|
putc('\n', stderr); |
318 |
|
|
fflush(stderr); |
319 |
|
|
} |
320 |
|
|
#ifdef NICE |
321 |
|
|
nice(NICE); /* lower priority */ |
322 |
|
|
#endif |
323 |
|
|
/* get octree */ |
324 |
|
|
if (i == argc) |
325 |
|
|
octname = NULL; |
326 |
|
|
else if (i == argc-1) |
327 |
|
|
octname = argv[i]; |
328 |
|
|
else |
329 |
|
|
goto badopt; |
330 |
|
|
if (seqstart > 0 && octname == NULL) |
331 |
|
|
error(USER, "missing octree argument"); |
332 |
|
|
/* set up output */ |
333 |
|
|
#ifdef PERSIST |
334 |
|
|
if (persist) { |
335 |
|
|
if (recover != NULL) |
336 |
|
|
error(USER, "persist option used with recover file"); |
337 |
|
|
if (seqstart <= 0) |
338 |
|
|
error(USER, "persist option only for sequences"); |
339 |
|
|
if (outfile == NULL) |
340 |
|
|
duped1 = dup(fileno(stdout)); /* don't lose our output */ |
341 |
|
|
openheader(); |
342 |
|
|
} else |
343 |
|
|
#endif |
344 |
|
|
if (outfile != NULL) |
345 |
|
|
openheader(); |
346 |
schorsch |
2.3 |
SET_FILE_BINARY(stdout); |
347 |
greg |
2.1 |
if (octname == NULL) |
348 |
schorsch |
2.3 |
SET_FILE_BINARY(stdin); |
349 |
greg |
2.1 |
readoct(octname, loadflags, &thescene, NULL); |
350 |
|
|
nsceneobjs = nobjects; |
351 |
|
|
|
352 |
|
|
if (loadflags & IO_INFO) { /* print header */ |
353 |
|
|
printargs(i, argv, stdout); |
354 |
|
|
printf("SOFTWARE= %s\n", VersionID); |
355 |
|
|
} |
356 |
greg |
2.16 |
|
357 |
|
|
ray_init_pmap(); /* PMAP: set up & load photon maps */ |
358 |
greg |
2.1 |
|
359 |
|
|
marksources(); /* find and mark sources */ |
360 |
|
|
setambient(); /* initialize ambient calculation */ |
361 |
greg |
2.16 |
|
362 |
greg |
2.20 |
fflush(stdout); /* in case we're duplicating header */ |
363 |
|
|
|
364 |
greg |
2.1 |
#ifdef PERSIST |
365 |
|
|
if (persist) { |
366 |
|
|
if (outfile == NULL) { /* reconnect stdout */ |
367 |
|
|
dup2(duped1, fileno(stdout)); |
368 |
|
|
close(duped1); |
369 |
|
|
} |
370 |
|
|
if (persist == PARALLEL) { /* multiprocessing */ |
371 |
greg |
2.34 |
cow_memshare(); /* preloads scene */ |
372 |
greg |
2.1 |
while ((rval=fork()) == 0) { /* keep on forkin' */ |
373 |
|
|
pflock(1); |
374 |
|
|
pfhold(); |
375 |
|
|
tstart = time((time_t *)NULL); |
376 |
greg |
2.13 |
ambsync(); /* load new values */ |
377 |
greg |
2.1 |
} |
378 |
|
|
if (rval < 0) |
379 |
|
|
error(SYSTEM, "cannot fork child for persist function"); |
380 |
greg |
2.13 |
pfdetach(); /* parent will run then exit */ |
381 |
greg |
2.1 |
} |
382 |
|
|
} |
383 |
|
|
runagain: |
384 |
schorsch |
2.7 |
if (persist) { |
385 |
greg |
2.1 |
if (outfile == NULL) /* if out to stdout */ |
386 |
|
|
dupheader(); /* send header */ |
387 |
|
|
else /* if out to file */ |
388 |
|
|
duped1 = dup(fileno(stdout)); /* hang onto pipe */ |
389 |
schorsch |
2.7 |
} |
390 |
greg |
2.1 |
#endif |
391 |
|
|
/* batch render picture(s) */ |
392 |
|
|
rpict(seqstart, outfile, zfile, recover); |
393 |
|
|
/* flush ambient file */ |
394 |
|
|
ambsync(); |
395 |
|
|
#ifdef PERSIST |
396 |
|
|
if (persist == PERSIST) { /* first run-through */ |
397 |
|
|
if ((rval=fork()) == 0) { /* child loops until killed */ |
398 |
|
|
pflock(1); |
399 |
|
|
persist = PCHILD; |
400 |
|
|
} else { /* original process exits */ |
401 |
|
|
if (rval < 0) |
402 |
|
|
error(SYSTEM, "cannot fork child for persist function"); |
403 |
|
|
pfdetach(); /* parent exits */ |
404 |
|
|
} |
405 |
|
|
} |
406 |
|
|
if (persist == PCHILD) { /* wait for a signal then go again */ |
407 |
|
|
if (outfile != NULL) |
408 |
|
|
close(duped1); /* release output handle */ |
409 |
|
|
pfhold(); |
410 |
|
|
tstart = time((time_t *)NULL); /* reinitialize */ |
411 |
|
|
raynum = nrays = 0; |
412 |
|
|
goto runagain; |
413 |
|
|
} |
414 |
|
|
#endif |
415 |
greg |
2.16 |
|
416 |
|
|
|
417 |
|
|
ray_done_pmap(); /* PMAP: free photon maps */ |
418 |
|
|
|
419 |
greg |
2.1 |
quit(0); |
420 |
|
|
|
421 |
|
|
badopt: |
422 |
|
|
sprintf(errmsg, "command line error at '%s'", argv[i]); |
423 |
|
|
error(USER, errmsg); |
424 |
schorsch |
2.8 |
return 1; /* pro forma return */ |
425 |
greg |
2.1 |
|
426 |
|
|
#undef check |
427 |
schorsch |
2.18 |
#undef check_bool |
428 |
greg |
2.1 |
} |
429 |
|
|
|
430 |
|
|
|
431 |
|
|
void |
432 |
schorsch |
2.8 |
wputs( /* warning output function */ |
433 |
greg |
2.26 |
const char *s |
434 |
schorsch |
2.8 |
) |
435 |
greg |
2.1 |
{ |
436 |
|
|
int lasterrno = errno; |
437 |
greg |
2.35 |
if (erract[WARNING].pf == NULL) |
438 |
|
|
return; /* called by calcomp or someone */ |
439 |
greg |
2.1 |
eputs(s); |
440 |
|
|
errno = lasterrno; |
441 |
|
|
} |
442 |
|
|
|
443 |
|
|
|
444 |
|
|
void |
445 |
schorsch |
2.8 |
eputs( /* put string to stderr */ |
446 |
greg |
2.26 |
const char *s |
447 |
schorsch |
2.8 |
) |
448 |
greg |
2.1 |
{ |
449 |
|
|
static int midline = 0; |
450 |
|
|
|
451 |
|
|
if (!*s) |
452 |
|
|
return; |
453 |
|
|
if (!midline++) { |
454 |
|
|
fputs(progname, stderr); |
455 |
|
|
fputs(": ", stderr); |
456 |
|
|
} |
457 |
|
|
fputs(s, stderr); |
458 |
|
|
if (s[strlen(s)-1] == '\n') { |
459 |
|
|
fflush(stderr); |
460 |
|
|
midline = 0; |
461 |
|
|
} |
462 |
|
|
} |
463 |
|
|
|
464 |
|
|
|
465 |
schorsch |
2.8 |
static void |
466 |
|
|
onsig( /* fatal signal */ |
467 |
|
|
int signo |
468 |
|
|
) |
469 |
greg |
2.1 |
{ |
470 |
|
|
static int gotsig = 0; |
471 |
|
|
|
472 |
|
|
if (gotsig++) /* two signals and we're gone! */ |
473 |
|
|
_exit(signo); |
474 |
|
|
|
475 |
schorsch |
2.4 |
#ifdef SIGALRM /* XXX how critical is this? */ |
476 |
greg |
2.1 |
alarm(15); /* allow 15 seconds to clean up */ |
477 |
|
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
478 |
schorsch |
2.4 |
#endif |
479 |
greg |
2.1 |
eputs("signal - "); |
480 |
|
|
eputs(sigerr[signo]); |
481 |
|
|
eputs("\n"); |
482 |
|
|
quit(3); |
483 |
|
|
} |
484 |
|
|
|
485 |
|
|
|
486 |
schorsch |
2.8 |
static void |
487 |
|
|
sigdie( /* set fatal signal */ |
488 |
|
|
int signo, |
489 |
|
|
char *msg |
490 |
|
|
) |
491 |
greg |
2.1 |
{ |
492 |
|
|
if (signal(signo, onsig) == SIG_IGN) |
493 |
|
|
signal(signo, SIG_IGN); |
494 |
|
|
sigerr[signo] = msg; |
495 |
|
|
} |
496 |
|
|
|
497 |
|
|
|
498 |
schorsch |
2.8 |
static void |
499 |
|
|
printdefaults(void) /* print default values to stdout */ |
500 |
greg |
2.1 |
{ |
501 |
|
|
printf("-vt%c\t\t\t\t# view type %s\n", ourview.type, |
502 |
|
|
ourview.type==VT_PER ? "perspective" : |
503 |
|
|
ourview.type==VT_PAR ? "parallel" : |
504 |
|
|
ourview.type==VT_HEM ? "hemispherical" : |
505 |
|
|
ourview.type==VT_ANG ? "angular" : |
506 |
|
|
ourview.type==VT_CYL ? "cylindrical" : |
507 |
greg |
2.14 |
ourview.type==VT_PLS ? "planisphere" : |
508 |
greg |
2.1 |
"unknown"); |
509 |
|
|
printf("-vp %f %f %f\t# view point\n", |
510 |
|
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
511 |
|
|
printf("-vd %f %f %f\t# view direction\n", |
512 |
|
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
513 |
|
|
printf("-vu %f %f %f\t# view up\n", |
514 |
|
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
515 |
|
|
printf("-vh %f\t\t\t# view horizontal size\n", ourview.horiz); |
516 |
|
|
printf("-vv %f\t\t\t# view vertical size\n", ourview.vert); |
517 |
|
|
printf("-vo %f\t\t\t# view fore clipping plane\n", ourview.vfore); |
518 |
|
|
printf("-va %f\t\t\t# view aft clipping plane\n", ourview.vaft); |
519 |
|
|
printf("-vs %f\t\t\t# view shift\n", ourview.hoff); |
520 |
|
|
printf("-vl %f\t\t\t# view lift\n", ourview.voff); |
521 |
|
|
printf("-x %-9d\t\t\t# x resolution\n", hresolu); |
522 |
|
|
printf("-y %-9d\t\t\t# y resolution\n", vresolu); |
523 |
greg |
2.28 |
if (out_prims == stdprims) |
524 |
|
|
printf("-pRGB\t\t\t\t# standard RGB color output\n"); |
525 |
|
|
else if (out_prims == xyzprims) |
526 |
|
|
printf("-pXYZ\t\t\t\t# CIE XYZ color output\n"); |
527 |
|
|
else if (out_prims != NULL) |
528 |
|
|
printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n", |
529 |
|
|
out_prims[RED][0], out_prims[RED][1], |
530 |
|
|
out_prims[GRN][0], out_prims[GRN][1], |
531 |
|
|
out_prims[BLU][0], out_prims[BLU][1], |
532 |
|
|
out_prims[WHT][0], out_prims[WHT][1]); |
533 |
greg |
2.1 |
printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect); |
534 |
|
|
printf("-pj %f\t\t\t# pixel jitter\n", dstrpix); |
535 |
|
|
printf("-pm %f\t\t\t# pixel motion\n", mblur); |
536 |
greg |
2.9 |
printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur); |
537 |
greg |
2.1 |
printf("-ps %-9d\t\t\t# pixel sample\n", psample); |
538 |
|
|
printf("-pt %f\t\t\t# pixel threshold\n", maxdiff); |
539 |
|
|
printf("-t %-9d\t\t\t# time between reports\n", ralrm); |
540 |
|
|
printf(erract[WARNING].pf != NULL ? |
541 |
|
|
"-w+\t\t\t\t# warning messages on\n" : |
542 |
|
|
"-w-\t\t\t\t# warning messages off\n"); |
543 |
|
|
print_rdefaults(); |
544 |
|
|
} |