--- ray/src/rt/rpmain.c 2003/02/25 02:47:23 2.2 +++ ray/src/rt/rpmain.c 2006/04/05 06:22:57 2.12 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rpmain.c,v 2.2 2003/02/25 02:47:23 greg Exp $"; +static const char RCSid[] = "$Id: rpmain.c,v 2.12 2006/04/05 06:22:57 greg Exp $"; #endif /* * rpmain.c - main for rpict batch rendering program @@ -7,23 +7,18 @@ static const char RCSid[] = "$Id: rpmain.c,v 2.2 2003/ #include "copyright.h" -#include "ray.h" +#include +#include +#include "platform.h" +#include "rtprocess.h" /* getpid() */ +#include "ray.h" #include "source.h" - #include "ambient.h" - #include "random.h" - #include "paths.h" - -#include - -#include - #include "view.h" -#include "paths.h" /* persistent processes define */ #ifdef F_SETLKW #define PERSIST 1 /* normal persist */ @@ -32,13 +27,9 @@ static const char RCSid[] = "$Id: rpmain.c,v 2.2 2003/ #endif char *progname; /* argv[0] */ - char *octname; /* octree name */ - char *sigerr[NSIG]; /* signal error messages */ - char *shm_boundary = NULL; /* boundary of shared memory */ - char *errfile = NULL; /* error output file */ extern time_t time(); @@ -58,15 +49,15 @@ extern double dstrpix; /* square pixel distribution extern double mblur; /* motion blur parameter */ -void onsig(); -void sigdie(); -void printdefaults(); +extern double dblur; /* depth-of-field blur parameter */ +static void onsig(int signo); +static void sigdie(int signo, char *msg); +static void printdefaults(void); + int -main(argc, argv) -int argc; -char *argv[]; +main(int argc, char *argv[]) { #define check(ol,al) if (argv[i][ol] || \ badarg(argc-i-1,argv+i+1,al)) \ @@ -163,6 +154,10 @@ char *argv[]; check(3,"f"); mblur = atof(argv[++i]); break; + case 'd': /* aperture */ + check(3,"f"); + dblur = atof(argv[++i]); + break; default: goto badopt; } @@ -231,13 +226,25 @@ char *argv[]; /* initialize object types */ initotypes(); /* initialize urand */ - initurand(2048); + if (rand_samp) { + srandom((long)time(0)); + initurand(0); + } else { + srandom(0L); + initurand(2048); + } /* set up signal handling */ sigdie(SIGINT, "Interrupt"); +#ifdef SIGHUP sigdie(SIGHUP, "Hangup"); +#endif sigdie(SIGTERM, "Terminate"); +#ifdef SIGPIPE sigdie(SIGPIPE, "Broken pipe"); +#endif +#ifdef SIGALRM sigdie(SIGALRM, "Alarm clock"); +#endif #ifdef SIGXCPU sigdie(SIGXCPU, "CPU limit exceeded"); sigdie(SIGXFSZ, "File size exceeded"); @@ -278,10 +285,10 @@ char *argv[]; #endif if (outfile != NULL) openheader(); -#ifdef MSDOS - setmode(fileno(stdout), O_BINARY); +#ifdef _WIN32 + SET_FILE_BINARY(stdout); if (octname == NULL) - setmode(fileno(stdin), O_BINARY); + SET_FILE_BINARY(stdin); #endif readoct(octname, loadflags, &thescene, NULL); nsceneobjs = nobjects; @@ -289,7 +296,6 @@ char *argv[]; if (loadflags & IO_INFO) { /* print header */ printargs(i, argv, stdout); printf("SOFTWARE= %s\n", VersionID); - fputnow(stdout); } marksources(); /* find and mark sources */ @@ -318,11 +324,12 @@ char *argv[]; } } runagain: - if (persist) + if (persist) { if (outfile == NULL) /* if out to stdout */ dupheader(); /* send header */ else /* if out to file */ duped1 = dup(fileno(stdout)); /* hang onto pipe */ + } #endif /* batch render picture(s) */ rpict(seqstart, outfile, zfile, recover); @@ -353,6 +360,7 @@ runagain: badopt: sprintf(errmsg, "command line error at '%s'", argv[i]); error(USER, errmsg); + return 1; /* pro forma return */ #undef check #undef bool @@ -360,8 +368,9 @@ badopt: void -wputs(s) /* warning output function */ -char *s; +wputs( /* warning output function */ + char *s +) { int lasterrno = errno; eputs(s); @@ -370,8 +379,9 @@ char *s; void -eputs(s) /* put string to stderr */ -register char *s; +eputs( /* put string to stderr */ + register char *s +) { static int midline = 0; @@ -389,17 +399,20 @@ register char *s; } -void -onsig(signo) /* fatal signal */ -int signo; +static void +onsig( /* fatal signal */ + int signo +) { static int gotsig = 0; if (gotsig++) /* two signals and we're gone! */ _exit(signo); +#ifdef SIGALRM /* XXX how critical is this? */ alarm(15); /* allow 15 seconds to clean up */ signal(SIGALRM, SIG_DFL); /* make certain we do die */ +#endif eputs("signal - "); eputs(sigerr[signo]); eputs("\n"); @@ -407,10 +420,11 @@ int signo; } -void -sigdie(signo, msg) /* set fatal signal */ -int signo; -char *msg; +static void +sigdie( /* set fatal signal */ + int signo, + char *msg +) { if (signal(signo, onsig) == SIG_IGN) signal(signo, SIG_IGN); @@ -418,11 +432,9 @@ char *msg; } -void -printdefaults() /* print default values to stdout */ +static void +printdefaults(void) /* print default values to stdout */ { - register char *cp; - printf("-vt%c\t\t\t\t# view type %s\n", ourview.type, ourview.type==VT_PER ? "perspective" : ourview.type==VT_PAR ? "parallel" : @@ -447,6 +459,7 @@ printdefaults() /* print default values to stdout */ printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect); printf("-pj %f\t\t\t# pixel jitter\n", dstrpix); printf("-pm %f\t\t\t# pixel motion\n", mblur); + printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur); printf("-ps %-9d\t\t\t# pixel sample\n", psample); printf("-pt %f\t\t\t# pixel threshold\n", maxdiff); printf("-t %-9d\t\t\t# time between reports\n", ralrm);