--- ray/src/util/rad.c 1999/02/02 08:57:56 2.60 +++ ray/src/util/rad.c 2003/06/30 14:59:13 2.65 @@ -1,19 +1,18 @@ -/* Copyright (c) 1999 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rad.c,v 2.65 2003/06/30 14:59:13 schorsch Exp $"; #endif - /* * Executive program for oconv, rpict and pfilt */ #include "standard.h" + +#include + +#include "platform.h" #include "view.h" #include "paths.h" #include "vars.h" -#include -#include /* variables (alphabetical by name) */ #define AMBFILE 0 /* ambient file name */ @@ -75,13 +74,13 @@ VARIABLE vv[] = { /* variable-value pairs */ }; /* overture calculation file */ -#ifdef NIX -char overfile[] = "overture.unf"; +#ifdef NULL_DEVICE +char overfile[] = NULL_DEVICE; #else -char overfile[] = "/dev/null"; +char overfile[] = "overture.unf"; #endif -extern time_t fdate(), time(); +extern time_t time(); time_t scenedate; /* date of latest scene or object file */ time_t octreedate; /* date of octree */ @@ -107,7 +106,7 @@ int overture = 0; /* overture calculation needed */ char *progname; /* global argv[0] */ char *rifname; /* global rad input file name */ -char radname[MAXPATH]; /* root Radiance file name */ +char radname[PATH_MAX]; /* root Radiance file name */ main(argc, argv) @@ -211,12 +210,12 @@ time_t checklast(fnames) /* check files and find most recent */ register char *fnames; { - char thisfile[MAXPATH]; + char thisfile[PATH_MAX]; time_t thisdate, lastdate = 0; if (fnames == NULL) return(0); - while ((fnames = nextword(thisfile, MAXPATH, fnames)) != NULL) { + while ((fnames = nextword(thisfile, PATH_MAX, fnames)) != NULL) { if (thisfile[0] == '!' || (thisfile[0] == '\\' && thisfile[1] == '!')) continue; @@ -234,7 +233,6 @@ newfname(orig, pred) /* create modified file name */ char *orig; int pred; { - extern char *rindex(); register char *cp; register int n; int suffix; @@ -264,6 +262,10 @@ checkfiles() /* check for existence and modified tim syserr(progname); sprintf(vval(OCTREE), "%s.oct", radname); vdef(OCTREE)++; + } else if (vval(OCTREE)[0] == '!') { + fprintf(stderr, "%s: illegal '%s' specification\n", + progname, vnam(OCTREE)); + quit(1); } octreedate = fdate(vval(OCTREE)); if (vdef(ILLUM)) { /* illum requires secondary octrees */ @@ -396,7 +398,7 @@ setdefaults() /* set default values for unassigned v oconv() /* run oconv and mkillum if necessary */ { static char illumtmp[] = "ilXXXXXX"; - char combuf[1024], ocopts[64], mkopts[64]; + char combuf[PATH_MAX], ocopts[64], mkopts[64]; oconvopts(ocopts); /* get options */ if (octreedate < scenedate) { /* check date on original octree */ @@ -821,7 +823,7 @@ char *ro; syserr(vval(OPTFILE)); sprintf(ro, " @%s", vval(OPTFILE)); } -#ifdef MSDOS +#ifdef _WIN32 else if (n > 50) { setenv("ROPT", ro+1); strcpy(ro, " $ROPT"); @@ -840,7 +842,7 @@ register char *po; } switch (vscale(QUALITY)) { case MEDIUM: - po = addarg(po, "-r 1"); + po = addarg(po, "-r .6"); break; case HIGH: po = addarg(po, "-m .25"); @@ -977,7 +979,7 @@ register char *vs; if (cp == viewopts) /* append any additional options */ vs++; /* skip prefixed space if unneeded */ strcpy(cp, vs); -#ifdef MSDOS +#ifdef _WIN32 if (strlen(viewopts) > 40) { setenv("VIEW", viewopts); return("$VIEW"); @@ -1031,14 +1033,13 @@ char *vn; /* returned view name */ printview(vopts) /* print out selected view */ register char *vopts; { - extern char *strstr(), *atos(), *getenv(); VIEW vwr; char buf[128]; register char *cp; again: if (vopts == NULL) return(-1); -#ifdef MSDOS +#ifdef _WIN32 if (vopts[0] == '$') { vopts = getenv(vopts+1); goto again; @@ -1062,7 +1063,7 @@ rview(opts, po) /* run rview with first view */ char *opts, *po; { char *vw; - char combuf[512]; + char combuf[PATH_MAX]; /* build command */ if (touchonly || (vw = getview(0, NULL)) == NULL) return; @@ -1084,9 +1085,9 @@ char *opts, *po; rpict(opts, po) /* run rpict and pfilt for each view */ char *opts, *po; { - char combuf[1024]; - char rawfile[MAXPATH], picfile[MAXPATH]; - char zopt[MAXPATH+4], rep[MAXPATH+16], res[32]; + char combuf[PATH_MAX]; + char rawfile[PATH_MAX], picfile[PATH_MAX]; + char zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32]; char pfopts[128]; char vs[32], *vw; int vn, mult; @@ -1175,7 +1176,7 @@ char *opts, *po; progname, vs); quit(1); } -#ifdef NIX +#ifndef NULL_DEVICE rmfile(overfile); #endif } @@ -1246,7 +1247,7 @@ rmfile(fn) /* remove a file */ char *fn; { if (!silent) -#ifdef MSDOS +#ifdef _WIN32 printf("\tdel %s\n", fn); #else printf("\trm -f %s\n", fn); @@ -1261,7 +1262,7 @@ mvfile(fold, fnew) /* move a file */ char *fold, *fnew; { if (!silent) -#ifdef MSDOS +#ifdef _WIN32 printf("\trename %s %s\n", fold, fnew); #else printf("\tmv %s %s\n", fold, fnew); @@ -1272,7 +1273,7 @@ char *fold, *fnew; } -#ifdef MSDOS +#ifdef _WIN32 setenv(vname, value) /* set an environment variable */ char *vname, *value; { @@ -1309,6 +1310,7 @@ char *s; } +void quit(ec) /* exit program */ int ec; {