--- ray/src/rt/rpmain.c 2003/06/05 19:29:34 2.3 +++ ray/src/rt/rpmain.c 2005/06/21 00:26:44 2.11 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rpmain.c,v 2.3 2003/06/05 19:29:34 schorsch Exp $"; +static const char RCSid[] = "$Id: rpmain.c,v 2.11 2005/06/21 00:26:44 greg Exp $"; #endif /* * rpmain.c - main for rpict batch rendering program @@ -7,10 +7,11 @@ static const char RCSid[] = "$Id: rpmain.c,v 2.3 2003/ #include "copyright.h" -#include +#include #include #include "platform.h" +#include "rtprocess.h" /* getpid() */ #include "ray.h" #include "source.h" #include "ambient.h" @@ -26,13 +27,9 @@ static const char RCSid[] = "$Id: rpmain.c,v 2.3 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(); @@ -52,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)) \ @@ -157,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; } @@ -225,13 +226,20 @@ char *argv[]; /* initialize object types */ initotypes(); /* initialize urand */ + srandom(rand_samp ? (long)time(0) : 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"); @@ -283,7 +291,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 */ @@ -312,11 +319,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); @@ -347,6 +355,7 @@ runagain: badopt: sprintf(errmsg, "command line error at '%s'", argv[i]); error(USER, errmsg); + return 1; /* pro forma return */ #undef check #undef bool @@ -354,8 +363,9 @@ badopt: void -wputs(s) /* warning output function */ -char *s; +wputs( /* warning output function */ + char *s +) { int lasterrno = errno; eputs(s); @@ -364,8 +374,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; @@ -383,17 +394,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"); @@ -401,10 +415,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); @@ -412,11 +427,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" : @@ -441,6 +454,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);