7 |
|
|
8 |
|
#include "copyright.h" |
9 |
|
|
10 |
< |
#include "ray.h" |
10 |
> |
#include <sys/types.h> |
11 |
> |
#include <signal.h> |
12 |
|
|
13 |
+ |
#include "platform.h" |
14 |
+ |
#include "rtprocess.h" /* getpid() */ |
15 |
+ |
#include "resolu.h" |
16 |
+ |
#include "ray.h" |
17 |
|
#include "source.h" |
13 |
– |
|
18 |
|
#include "ambient.h" |
15 |
– |
|
19 |
|
#include "random.h" |
17 |
– |
|
20 |
|
#include "paths.h" |
21 |
|
|
20 |
– |
#include <sys/types.h> |
21 |
– |
|
22 |
– |
#include <signal.h> |
22 |
|
/* persistent processes define */ |
23 |
|
#ifdef F_SETLKW |
24 |
|
#define PERSIST 1 /* normal persist */ |
27 |
|
#endif |
28 |
|
|
29 |
|
char *progname; /* argv[0] */ |
31 |
– |
|
30 |
|
char *octname; /* octree name */ |
33 |
– |
|
31 |
|
char *sigerr[NSIG]; /* signal error messages */ |
35 |
– |
|
32 |
|
char *shm_boundary = NULL; /* boundary of shared memory */ |
37 |
– |
|
33 |
|
char *errfile = NULL; /* error output file */ |
34 |
|
|
35 |
|
extern char *formstr(); /* string from format */ |
46 |
|
extern char *tralist[]; /* list of modifers to trace (or no) */ |
47 |
|
extern int traincl; /* include == 1, exclude == 0 */ |
48 |
|
|
49 |
< |
void onsig(); |
50 |
< |
void sigdie(); |
51 |
< |
void printdefaults(); |
49 |
> |
static void onsig(int signo); |
50 |
> |
static void sigdie(int signo, char *msg); |
51 |
> |
static void printdefaults(void); |
52 |
|
|
53 |
|
|
54 |
|
int |
55 |
< |
main(argc, argv) |
61 |
< |
int argc; |
62 |
< |
char *argv[]; |
55 |
> |
main(int argc, char *argv[]) |
56 |
|
{ |
57 |
|
#define check(ol,al) if (argv[i][ol] || \ |
58 |
|
badarg(argc-i-1,argv+i+1,al)) \ |
230 |
|
initurand(2048); |
231 |
|
/* set up signal handling */ |
232 |
|
sigdie(SIGINT, "Interrupt"); |
233 |
+ |
#ifdef SIGHUP |
234 |
|
sigdie(SIGHUP, "Hangup"); |
235 |
+ |
#endif |
236 |
|
sigdie(SIGTERM, "Terminate"); |
237 |
+ |
#ifdef SIGPIPE |
238 |
|
sigdie(SIGPIPE, "Broken pipe"); |
239 |
+ |
#endif |
240 |
+ |
#ifdef SIGALRM |
241 |
|
sigdie(SIGALRM, "Alarm clock"); |
242 |
+ |
#endif |
243 |
|
#ifdef SIGXCPU |
244 |
|
sigdie(SIGXCPU, "CPU limit exceeded"); |
245 |
|
sigdie(SIGXFSZ, "File size exceeded"); |
273 |
|
openheader(); |
274 |
|
} |
275 |
|
#endif |
276 |
< |
#ifdef MSDOS |
276 |
> |
#ifdef _WIN32 |
277 |
|
if (outform != 'a') |
278 |
< |
setmode(fileno(stdout), O_BINARY); |
278 |
> |
SET_FILE_BINARY(stdout); |
279 |
|
if (octname == NULL) |
280 |
< |
setmode(fileno(stdin), O_BINARY); |
280 |
> |
SET_FILE_BINARY(stdin); |
281 |
|
#endif |
282 |
|
readoct(octname, loadflags, &thescene, NULL); |
283 |
|
nsceneobjs = nobjects; |
344 |
|
badopt: |
345 |
|
sprintf(errmsg, "command line error at '%s'", argv[i]); |
346 |
|
error(USER, errmsg); |
347 |
+ |
return 1; /* pro forma return */ |
348 |
|
|
349 |
|
#undef check |
350 |
|
#undef bool |
352 |
|
|
353 |
|
|
354 |
|
void |
355 |
< |
wputs(s) /* warning output function */ |
356 |
< |
char *s; |
355 |
> |
wputs( /* warning output function */ |
356 |
> |
char *s |
357 |
> |
) |
358 |
|
{ |
359 |
|
int lasterrno = errno; |
360 |
|
eputs(s); |
363 |
|
|
364 |
|
|
365 |
|
void |
366 |
< |
eputs(s) /* put string to stderr */ |
367 |
< |
register char *s; |
366 |
> |
eputs( /* put string to stderr */ |
367 |
> |
register char *s |
368 |
> |
) |
369 |
|
{ |
370 |
|
static int midline = 0; |
371 |
|
|
383 |
|
} |
384 |
|
|
385 |
|
|
386 |
< |
void |
387 |
< |
onsig(signo) /* fatal signal */ |
388 |
< |
int signo; |
386 |
> |
static void |
387 |
> |
onsig( /* fatal signal */ |
388 |
> |
int signo |
389 |
> |
) |
390 |
|
{ |
391 |
|
static int gotsig = 0; |
392 |
|
|
393 |
|
if (gotsig++) /* two signals and we're gone! */ |
394 |
|
_exit(signo); |
395 |
|
|
396 |
+ |
#ifdef SIGALRM |
397 |
|
alarm(15); /* allow 15 seconds to clean up */ |
398 |
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
399 |
+ |
#endif |
400 |
|
eputs("signal - "); |
401 |
|
eputs(sigerr[signo]); |
402 |
|
eputs("\n"); |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
< |
void |
408 |
< |
sigdie(signo, msg) /* set fatal signal */ |
409 |
< |
int signo; |
410 |
< |
char *msg; |
407 |
> |
static void |
408 |
> |
sigdie( /* set fatal signal */ |
409 |
> |
int signo, |
410 |
> |
char *msg |
411 |
> |
) |
412 |
|
{ |
413 |
|
if (signal(signo, onsig) == SIG_IGN) |
414 |
|
signal(signo, SIG_IGN); |
416 |
|
} |
417 |
|
|
418 |
|
|
419 |
< |
void |
420 |
< |
printdefaults() /* print default values to stdout */ |
419 |
> |
static void |
420 |
> |
printdefaults(void) /* print default values to stdout */ |
421 |
|
{ |
422 |
|
register char *cp; |
423 |
|
|