--- ray/src/util/ranimate.c 2003/02/24 16:44:40 2.30
+++ ray/src/util/ranimate.c 2006/04/18 04:30:35 2.52
@@ -1,5 +1,5 @@
#ifndef lint
-static const char RCSid[] = "$Id: ranimate.c,v 2.30 2003/02/24 16:44:40 greg Exp $";
+static const char RCSid[] = "$Id: ranimate.c,v 2.52 2006/04/18 04:30:35 greg Exp $";
#endif
/*
* Radiance animation control program
@@ -13,66 +13,18 @@ static const char RCSid[] = "$Id: ranimate.c,v 2.30 20
* See the ranimate(1) man page for further details.
*/
-/* ====================================================================
- * The Radiance Software License, Version 1.0
- *
- * Copyright (c) 1990 - 2002 The Regents of the University of California,
- * through Lawrence Berkeley National Laboratory. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes Radiance software
- * (http://radsite.lbl.gov/)
- * developed by the Lawrence Berkeley National Laboratory
- * (http://www.lbl.gov/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
- * and "The Regents of the University of California" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact radiance@radsite.lbl.gov.
- *
- * 5. Products derived from this software may not be called "Radiance",
- * nor may "Radiance" appear in their name, without prior written
- * permission of Lawrence Berkeley National Laboratory.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of Lawrence Berkeley National Laboratory. For more
- * information on Lawrence Berkeley National Laboratory, please see
- * .
- */
+#include "copyright.h"
-#include "standard.h"
+#include
#include
#include
+#include
+#include
+
+#include "platform.h"
+#include "rtprocess.h"
+#include "paths.h"
+#include "standard.h"
#include "view.h"
#include "vars.h"
#include "netproc.h"
@@ -81,42 +33,42 @@ static const char RCSid[] = "$Id: ranimate.c,v 2.30 20
#define DEF_NBLUR 5
#endif
/* default remote shell */
-#ifdef _AUX_SOURCE
-#define REMSH "remsh"
-#else
-#define REMSH "rsh"
+#ifndef REMSH
+#define REMSH "ssh"
#endif
/* input variables (alphabetical by name) */
#define ANIMATE 0 /* animation command */
#define ARCHIVE 1 /* archiving command */
#define BASENAME 2 /* output image base name */
-#define DIRECTORY 3 /* working (sub)directory */
-#define DISKSPACE 4 /* how much disk space to use */
-#define END 5 /* ending frame number */
-#define EXPOSURE 6 /* how to compute exposure */
-#define HOST 7 /* rendering host machine */
-#define INTERP 8 /* # frames to interpolate */
-#define MBLUR 9 /* motion blur parameters */
-#define NEXTANIM 10 /* next animation file */
-#define OCTREE 11 /* octree file name */
-#define OVERSAMP 12 /* # times to oversample image */
-#define PFILT 13 /* pfilt options */
-#define PINTERP 14 /* pinterp options */
-#define RENDER 15 /* rendering options */
-#define RESOLUTION 16 /* desired final resolution */
-#define RIF 17 /* rad input file */
-#define RSH 18 /* remote shell script or program */
-#define RTRACE 19 /* use rtrace with pinterp? */
-#define START 20 /* starting frame number */
-#define TRANSFER 21 /* frame transfer command */
-#define VIEWFILE 22 /* animation frame views */
+#define DBLUR 3 /* depth of field blur */
+#define DIRECTORY 4 /* working (sub)directory */
+#define DISKSPACE 5 /* how much disk space to use */
+#define END 6 /* ending frame number */
+#define EXPOSURE 7 /* how to compute exposure */
+#define HOST 8 /* rendering host machine */
+#define INTERP 9 /* # frames to interpolate */
+#define MBLUR 10 /* motion blur parameters */
+#define NEXTANIM 11 /* next animation file */
+#define OCTREE 12 /* octree file name */
+#define OVERSAMP 13 /* # times to oversample image */
+#define PFILT 14 /* pfilt options */
+#define PINTERP 15 /* pinterp options */
+#define RENDER 16 /* rendering options */
+#define RESOLUTION 17 /* desired final resolution */
+#define RIF 18 /* rad input file */
+#define RSH 19 /* remote shell script or program */
+#define RTRACE 20 /* use rtrace with pinterp? */
+#define START 21 /* starting frame number */
+#define TRANSFER 22 /* frame transfer command */
+#define VIEWFILE 23 /* animation frame views */
-int NVARS = 23; /* total number of variables */
+int NVARS = 24; /* total number of variables */
VARIABLE vv[] = { /* variable-value pairs */
{"ANIMATE", 2, 0, NULL, onevalue},
{"ARCHIVE", 2, 0, NULL, onevalue},
{"BASENAME", 3, 0, NULL, onevalue},
+ {"DBLUR", 2, 0, NULL, onevalue},
{"DIRECTORY", 3, 0, NULL, onevalue},
{"DISKSPACE", 3, 0, NULL, fltvalue},
{"END", 2, 0, NULL, intvalue},
@@ -143,7 +95,7 @@ VARIABLE vv[] = { /* variable-value pairs */
struct {
char host[64]; /* control host name */
- int pid; /* control process id */
+ RT_PID pid; /* control process id */
char cfname[128]; /* control file name */
int rnext; /* next frame to render */
int fnext; /* next frame to filter */
@@ -167,28 +119,53 @@ char arcargs[10240]; /* files to archive */
char *arcfirst, *arcnext; /* pointers to first and next argument */
struct pslot {
- int pid; /* process ID (0 if empty) */
+ RT_PID pid; /* process ID (0 if empty) */
int fout; /* output frame number */
int (*rcvf)(); /* recover function */
} *pslot; /* process slots */
int npslots; /* number of process slots */
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host)
-
-struct pslot *findpslot();
-
PSERVER *lastpserver; /* last process server with error */
-VIEW *getview();
-char *getexp(), *dirfile();
-int getblur();
+static struct pslot * findpslot(RT_PID pid);
+static void checkdir(void);
+static VIEW * getview(int n);
-extern time_t time();
+static char * dirfile(char *df, register char *path);
+static char * getexp(int n);
+static int getblur(double *mbf, double *dbf);
+static int getastat(void);
+static void getradfile(char *rfargs);
+static void badvalue(int vc);
+static int rmfile(char *fn);
+static int runcom(char *cs);
+static int pruncom(char *com, char *ppins, int maxcopies);
+static void bwait(int ncoms);
+static RT_PID bruncom(char *com, int fout, int (*rf)());
+static int serverdown(void);
+static pscompfunc donecom;
+static int countviews(void);
+static int dofilt(int frame, int rvr);
+static void archive(void);
+static int frecover(int frame);
+static int recover(int frame);
+static void sethosts(void);
+static void walkwait(int first, int last, char *vfn);
+static void animrend(int frame, VIEW *vp);
+static void transferframes(void);
+static void filterframes(void);
+static void renderframes(int nframes);
+static void animate(void);
+static void setdefaults(void);
+static void putastat(void);
-main(argc, argv)
-int argc;
-char *argv[];
+int
+main(
+ int argc,
+ char *argv[]
+)
{
int explicate = 0;
int i;
@@ -241,23 +218,28 @@ char *argv[];
animate();
/* all done */
if (vdef(NEXTANIM)) {
+ char *fullp;
argv[i] = vval(NEXTANIM); /* just change input file */
if (!silent)
printargs(argc, argv, stdout);
- if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL)
- fprintf(stderr, "%s: command not found\n", progname);
+ fflush(stdout);
+ if ((fullp = getpath(argv[0],getenv("PATH"),X_OK)) == NULL)
+ fprintf(stderr, "%s: command not found\n", argv[0]);
else
- execv(progname, argv);
+ execv(fullp, argv);
quit(1);
}
quit(0);
+ return(0); /* pro forma return */
userr:
fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname);
quit(1);
+ return 1; /* pro forma return */
}
-getastat() /* check/set animation status */
+static int
+getastat(void) /* check/set animation status */
{
char sfname[256];
FILE *fp;
@@ -321,7 +303,8 @@ fmterr:
}
-putastat() /* put out current status */
+static void
+putastat(void) /* put out current status */
{
char buf[256];
FILE *fp;
@@ -343,7 +326,8 @@ putastat() /* put out current status */
}
-checkdir() /* make sure we have our directory */
+static void
+checkdir(void) /* make sure we have our directory */
{
struct stat stb;
@@ -365,7 +349,8 @@ checkdir() /* make sure we have our directory */
}
-setdefaults() /* set default values */
+static void
+setdefaults(void) /* set default values */
{
extern char *atos();
int decades;
@@ -453,7 +438,8 @@ setdefaults() /* set default values */
}
-sethosts() /* set up process servers */
+static void
+sethosts(void) /* set up process servers */
{
extern char *iskip();
char buf[256], *dir, *uname;
@@ -508,15 +494,14 @@ sethosts() /* set up process servers */
}
}
-
-getradfile(rfargs) /* run rad and get needed variables */
-char *rfargs;
+static void
+getradfile(char *rfargs) /* run rad and get needed variables */
{
static short mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1};
char combuf[256];
register int i;
register char *cp;
- char *pippt;
+ char *pippt = NULL;
/* create rad command */
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
sprintf(combuf,
@@ -535,7 +520,7 @@ char *rfargs;
pippt = NULL;
}
if (pippt != NULL)
- strcpy(pippt, "> /dev/null"); /* nothing to match */
+ strcpy(pippt, "> " NULL_DEVICE); /* nothing to match */
else {
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
cp += 11; /* point to file name */
@@ -548,7 +533,8 @@ char *rfargs;
}
-animate() /* run animation */
+static void
+animate(void) /* run animation */
{
int xres, yres;
float pa, mult;
@@ -588,7 +574,7 @@ animate() /* run animation */
}
/* figure # frames per batch */
d1 = mult*xres*mult*yres*4; /* space for orig. picture */
- if ((i=vint(INTERP)) || getblur(NULL) > 1)
+ if ((i=vint(INTERP)) || getblur(NULL, NULL) > 1)
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */
d2 = xres*yres*4; /* space for final picture */
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2);
@@ -619,8 +605,8 @@ animate() /* run animation */
}
-renderframes(nframes) /* render next nframes frames */
-int nframes;
+static void
+renderframes(int nframes) /* render next nframes frames */
{
static char vendbuf[16];
VIEW *vp;
@@ -676,23 +662,17 @@ int nframes;
}
-filterframes() /* catch up with filtering */
+static void
+filterframes(void) /* catch up with filtering */
{
- VIEW *vp;
register int i;
if (astat.tnext < astat.fnext) /* other work to do first */
return;
/* filter each view */
- for (i = astat.fnext; i < astat.rnext; i++) {
- if ((vp = getview(i)) == NULL) { /* get view i */
- fprintf(stderr,
- "%s: unexpected error reading view for frame %d\n",
- progname, i);
- quit(1);
- }
- dofilt(i, vp, getexp(i), 0); /* filter frame */
- }
+ for (i = astat.fnext; i < astat.rnext; i++)
+ dofilt(i, 0);
+
bwait(0); /* wait for filter processes */
archive(); /* archive originals */
astat.fnext = i; /* update status */
@@ -700,7 +680,8 @@ filterframes() /* catch up with filtering */
}
-transferframes() /* catch up with picture transfers */
+static void
+transferframes(void) /* catch up with picture transfers */
{
char combuf[10240], *fbase;
register char *cp;
@@ -740,11 +721,12 @@ transferframes() /* catch up with picture transfers
}
-animrend(frame, vp) /* start animation frame */
-int frame;
-VIEW *vp;
+static void
+animrend( /* start animation frame */
+int frame,
+VIEW *vp
+)
{
- extern int recover();
char combuf[2048];
char fname[128];
@@ -758,12 +740,15 @@ VIEW *vp;
}
-walkwait(first, last, vfn) /* walk-through frames */
-int first, last;
-char *vfn;
+static void
+walkwait( /* walk-through frames */
+int first,
+int last,
+char *vfn
+)
{
- double blurf;
- int nblur = getblur(&blurf);
+ double mblurf, dblurf;
+ int nblur = getblur(&mblurf, &dblurf);
char combuf[2048];
register char *inspoint;
register int i;
@@ -781,8 +766,10 @@ char *vfn;
inspoint = combuf;
while (*inspoint) inspoint++;
if (nblur) {
- sprintf(inspoint, " -pm %.3f", blurf/nblur);
+ sprintf(inspoint, " -pm %.3f", mblurf/nblur);
while (*inspoint) inspoint++;
+ sprintf(inspoint, " -pd %.3f", dblurf/nblur);
+ while (*inspoint) inspoint++;
}
if (nblur > 1 || vint(INTERP)) {
sprintf(inspoint, " -z %s.zbf", vval(BASENAME));
@@ -810,14 +797,13 @@ char *vfn;
}
-int
-recover(frame) /* recover the specified frame */
-int frame;
+static int
+recover(int frame) /* recover the specified frame */
{
static int *rfrm; /* list of recovered frames */
static int nrfrms = 0;
- double blurf;
- int nblur = getblur(&blurf);
+ double mblurf, dblurf;
+ int nblur = getblur(&mblurf, &dblurf);
char combuf[2048];
char fname[128];
register char *cp;
@@ -836,8 +822,10 @@ int frame;
cp = combuf;
while (*cp) cp++;
if (nblur) {
- sprintf(cp, " -pm %.3f", blurf/nblur);
+ sprintf(cp, " -pm %.3f", mblurf/nblur);
while (*cp) cp++;
+ sprintf(cp, " -pd %.3f", dblurf/nblur);
+ while (*cp) cp++;
}
if (nblur > 1 || vint(INTERP)) {
sprintf(cp, " -z %s.zbf", fname);
@@ -853,7 +841,7 @@ int frame;
return(1);
/* add frame to recovered list */
if (nrfrms)
- rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int));
+ rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int));
else
rfrm = (int *)malloc(sizeof(int));
if (rfrm == NULL) {
@@ -865,22 +853,17 @@ int frame;
}
-int
-frecover(frame) /* recover filtered frame */
-int frame;
+static int
+frecover(int frame) /* recover filtered frame */
{
- VIEW *vp;
- char *ex;
-
- vp = getview(frame);
- ex = getexp(frame);
- if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1))
+ if (dofilt(frame, 2) && dofilt(frame, 1))
return(1);
return(0);
}
-archive() /* archive and remove renderings */
+static void
+archive(void) /* archive and remove renderings */
{
#define RMCOML (sizeof(rmcom)-1)
static char rmcom[] = "rm -f";
@@ -923,24 +906,30 @@ archive() /* archive and remove renderings */
}
-int
-dofilt(frame, vp, ep, rvr) /* filter frame */
-int frame;
-VIEW *vp;
-char *ep;
-int rvr;
+static int
+dofilt( /* filter frame */
+int frame,
+int rvr
+)
{
- extern int frecover();
static int iter = 0;
- double blurf;
- int nblur = getblur(&blurf);
+ double mblurf, dblurf;
+ int nblur = getblur(&mblurf, &dblurf);
+ VIEW *vp = getview(frame);
+ char *ep = getexp(frame);
char fnbefore[128], fnafter[128], *fbase;
char combuf[1024], fname0[128], fname1[128];
int usepinterp, usepfilt, nora_rgbe;
int frseq[2];
/* check what is needed */
+ if (vp == NULL) {
+ fprintf(stderr,
+ "%s: unexpected error reading view for frame %d\n",
+ progname, frame);
+ quit(1);
+ }
usepinterp = (nblur > 1);
- usepfilt = pfiltalways | ep==NULL;
+ usepfilt = pfiltalways | (ep==NULL);
if (ep != NULL && !strcmp(ep, "1"))
ep = "+0";
nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL ||
@@ -957,6 +946,13 @@ int rvr;
usepfilt |= nora_rgbe;
} else if (frseq[0] == frame) { /* no interpolation needed */
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */
+ if (arcnext - arcargs +
+ strlen(fbase) >= sizeof(arcargs)-8) {
+ fprintf(stderr,
+"%s: too many filenames in archive command -- reduce %s variable\n",
+ progname, vnam(DISKSPACE));
+ quit(1);
+ }
*arcnext++ = ' ';
sprintf(arcnext, fbase, frame-vint(INTERP)-1);
while (*arcnext) arcnext++;
@@ -984,7 +980,7 @@ int rvr;
if (usepinterp) { /* using pinterp */
if (rvr == 2 && recover(frseq[1])) /* recover after? */
return(1);
- if (nblur > 1) { /* with pmblur */
+ if (nblur > 1) { /* with pdmblur */
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
'a'+(iter%26));
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
@@ -1011,8 +1007,8 @@ int rvr;
putc('\n', fp); fclose(fp);
}
sprintf(combuf,
- "(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
- blurf, nblur,
+ "(pmdblur %.3f %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
+ mblurf, dblurf, nblur,
fname0, fname1, fname0, fname1);
iter++;
} else /* no blurring */
@@ -1026,7 +1022,7 @@ int rvr;
if (usepfilt)
sprintf(combuf+strlen(combuf), " %s", rresopt);
else
- sprintf(combuf+strlen(combuf), "-a %s -e %s",
+ sprintf(combuf+strlen(combuf), " -a %s -e %s",
fresopt, ep);
sprintf(combuf+strlen(combuf), " %s.unf %s.zbf",
fnbefore, fnbefore);
@@ -1073,9 +1069,8 @@ int rvr;
}
-VIEW *
-getview(n) /* get view number n */
-int n;
+static VIEW *
+getview(int n) /* get view number n */
{
static FILE *viewfp = NULL; /* view file pointer */
static int viewnum = 0; /* current view number */
@@ -1087,7 +1082,7 @@ int n;
fclose(viewfp);
viewfp = NULL;
viewnum = 0;
- copystruct(&curview, &stdview);
+ curview = stdview;
}
return(NULL);
}
@@ -1103,7 +1098,7 @@ int n;
perror(vval(VIEWFILE));
quit(1);
}
- copystruct(&curview, &stdview);
+ curview = stdview;
viewnum = 0;
}
if (n < 0) { /* get next view */
@@ -1123,8 +1118,8 @@ int n;
}
-int
-countviews() /* count views in view file */
+static int
+countviews(void) /* count views in view file */
{
int n;
@@ -1136,9 +1131,8 @@ countviews() /* count views in view file */
}
-char *
-getexp(n) /* get exposure for nth frame */
-int n;
+static char *
+getexp(int n) /* get exposure for nth frame */
{
extern char *fskip();
static char expval[32];
@@ -1207,9 +1201,8 @@ int n;
}
-struct pslot *
-findpslot(pid) /* find or allocate a process slot */
-int pid;
+static struct pslot *
+findpslot(RT_PID pid) /* find or allocate a process slot */
{
register struct pslot *psempty = NULL;
register int i;
@@ -1224,13 +1217,14 @@ int pid;
}
-int
-donecom(ps, pn, status) /* clean up after finished process */
-PSERVER *ps;
-int pn;
-int status;
+static int
+donecom( /* clean up after finished process */
+ PSERVER *ps,
+ int pn,
+ int status
+)
{
- register PROC *pp;
+ register NETPROC *pp;
register struct pslot *psl;
pp = ps->proc + pn;
@@ -1265,8 +1259,8 @@ int status;
}
-int
-serverdown() /* check status of last process server */
+static int
+serverdown(void) /* check status of last process server */
{
if (lastpserver == NULL || !lastpserver->hostname[0])
return(0);
@@ -1282,13 +1276,14 @@ serverdown() /* check status of last process server
}
-int
-bruncom(com, fout, rf) /* run a command in the background */
-char *com;
-int fout;
-int (*rf)();
+static RT_PID
+bruncom( /* run a command in the background */
+char *com,
+int fout,
+int (*rf)()
+)
{
- int pid;
+ RT_PID pid;
register struct pslot *psl;
if (noaction) {
@@ -1301,7 +1296,7 @@ int (*rf)();
bwait(1);
if (!silent) { /* echo command */
PSERVER *ps;
- int psn = pid;
+ RT_PID psn = pid;
ps = findjob(&psn);
printf("\t%s\n", com);
printf("\tProcess started on %s\n", phostname(ps));
@@ -1315,8 +1310,8 @@ int (*rf)();
}
-bwait(ncoms) /* wait for batch job(s) to finish */
-int ncoms;
+static void
+bwait(int ncoms) /* wait for batch job(s) to finish */
{
int status;
@@ -1330,10 +1325,12 @@ int ncoms;
}
-int
-pruncom(com, ppins, maxcopies) /* run a command in parallel over network */
-char *com, *ppins;
-int maxcopies;
+static int
+pruncom( /* run a command in parallel over network */
+char *com,
+char *ppins,
+int maxcopies
+)
{
int retstatus = 0;
int hostcopies;
@@ -1355,6 +1352,7 @@ int maxcopies;
strcpy(com1=buf, com); /* build -PP command */
sprintf(com1+(ppins-com), " -PP %s/%s.persist",
vval(DIRECTORY), phostname(ps));
+ unlink(com1+(ppins-com)+5);
strcat(com1, ppins);
} else
com1 = com;
@@ -1399,8 +1397,8 @@ int maxcopies;
}
-runcom(cs) /* run a command locally and wait for it */
-char *cs;
+static int
+runcom(char *cs) /* run a command locally and wait for it */
{
if (!silent) /* echo it */
printf("\t%s\n", cs);
@@ -1411,11 +1409,11 @@ char *cs;
}
-rmfile(fn) /* remove a file */
-char *fn;
+static int
+rmfile(char *fn) /* remove a file */
{
if (!silent)
-#ifdef MSDOS
+#ifdef _WIN32
printf("\tdel %s\n", fn);
#else
printf("\trm -f %s\n", fn);
@@ -1426,8 +1424,8 @@ char *fn;
}
-badvalue(vc) /* report bad variable value and exit */
-int vc;
+static void
+badvalue(int vc) /* report bad variable value and exit */
{
fprintf(stderr, "%s: bad value for variable '%s'\n",
progname, vnam(vc));
@@ -1435,10 +1433,11 @@ int vc;
}
-char *
-dirfile(df, path) /* separate path into directory and file */
-char *df;
-register char *path;
+static char *
+dirfile( /* separate path into directory and file */
+char *df,
+register char *path
+)
{
register int i;
int psep;
@@ -1446,7 +1445,7 @@ register char *path;
for (i = 0, psep = -1; path[i]; i++)
if (path[i] == '/')
psep = i;
- if (df != NULL)
+ if (df != NULL) {
if (psep == 0) {
df[0] = '/';
df[1] = '\0';
@@ -1455,34 +1454,41 @@ register char *path;
df[psep] = '\0';
} else
df[0] = '\0';
+ }
return(path+psep+1);
}
-int
-getblur(double *bf) /* get # blur samples (and fraction) */
+static int
+getblur(double *mbf, double *dbf) /* get # blur samples (and fraction) */
{
- double blurf;
- int nblur;
+ double mblurf, dblurf;
+ int nmblur, ndblur;
char *s;
-
- if (!vdef(MBLUR)) {
- if (bf != NULL)
- *bf = 0.0;
- return(0);
- }
- blurf = atof(vval(MBLUR));
- if (blurf < 0.0)
- blurf = 0.0;
- if (bf != NULL)
- *bf = blurf;
- if (blurf <= FTINY)
- return(0);
- s = sskip(vval(MBLUR));
- if (!*s)
- return(DEF_NBLUR);
- nblur = atoi(s);
- if (nblur <= 0)
+ /* get motion blur */
+ if (!vdef(MBLUR) || (mblurf = atof(vval(MBLUR))) < 0.0)
+ mblurf = 0.0;
+ if (mbf != NULL)
+ *mbf = mblurf;
+ if (mblurf <= FTINY)
+ nmblur = 0;
+ else if (!*(s = sskip(vval(MBLUR))))
+ nmblur = DEF_NBLUR;
+ else if ((nmblur = atoi(s)) <= 0)
+ nmblur = 1;
+ /* get depth-of-field blur */
+ if (!vdef(DBLUR) || (dblurf = atof(vval(DBLUR))) < 0.0)
+ dblurf = 0.0;
+ if (dbf != NULL)
+ *dbf = dblurf;
+ if (dblurf <= FTINY)
+ ndblur = 0;
+ else if (!*(s = sskip(vval(DBLUR))))
+ ndblur = DEF_NBLUR;
+ else if ((ndblur = atoi(s)) <= 0)
+ ndblur = 1;
+ if ((nmblur == 1) & (ndblur == 1))
return(1);
- return(nblur);
+ /* return combined samples */
+ return(nmblur + ndblur);
}