--- ray/src/util/rad.c 1993/03/11 11:39:48 2.2 +++ ray/src/util/rad.c 1993/04/06 17:21:04 2.7 @@ -76,11 +76,13 @@ VARIABLE *matchvar(); char *nvalue(); int vscale(); +#define UPPER(c) ((c)&~0x20) /* ASCII trick */ + #define vnam(vc) (vv[vc].name) #define vdef(vc) (vv[vc].nass) #define vval(vc) (vv[vc].value) #define vint(vc) atoi(vval(vc)) -#define vlet(vc) (vval(vc)[0]&~0x20) +#define vlet(vc) UPPER(vval(vc)[0]) #define vbool(vc) (vlet(vc)=='T') #define HIGH 2 @@ -92,6 +94,13 @@ int (*setqopts[3])() = {lowqopts, medqopts, hiqopts}; #define renderopts (*setqopts[vscale(QUALITY)]) + /* overture calculation file */ +#ifdef NIX +char overfile[] = "overture.raw"; +#else +char overfile[] = "/dev/null"; +#endif + extern long fdate(), time(); long scenedate; /* date of latest scene or object file */ @@ -157,8 +166,11 @@ char *argv[]; /* print all values if requested */ if (explicate) printvals(); - /* run simulation */ + /* build octree */ oconv(); + /* check date on ambient file */ + checkambfile(); + /* run simulation */ renderopts(ropts); xferopts(ropts); if (rvdevice != NULL) @@ -168,7 +180,7 @@ char *argv[]; exit(0); userr: fprintf(stderr, - "Usage: %s [-s][-n][-v view][-o dev] rfile [VAR=value ..]\n", + "Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n", progname); exit(1); } @@ -193,15 +205,13 @@ load(rfname) /* load Radiance simulation file */ char *rfname; { FILE *fp; - char buf[256]; + char buf[512]; register char *cp; if (rfname == NULL) fp = stdin; - else if ((fp = fopen(rfname, "r")) == NULL) { - perror(rfname); - exit(1); - } + else if ((fp = fopen(rfname, "r")) == NULL) + syserr(rfname); while (fgetline(buf, sizeof(buf), fp) != NULL) { for (cp = buf; *cp; cp++) { switch (*cp) { @@ -212,6 +222,8 @@ char *rfname; case '#': *cp = '\0'; break; + default: + continue; } break; } @@ -260,16 +272,17 @@ register char *ass; exit(1); } /* assign new value */ - cp = vp->value; i = vp->nass; - while (i--) - while (*cp++) - ; - i = cp - vp->value; - vp->value = realloc(vp->value, i+n+1); - if (vp->value == NULL) { - perror(progname); - exit(1); - } + if (i = vp->nass) { + cp = vp->value; + while (i--) + while (*cp++) + ; + i = cp - vp->value; + vp->value = realloc(vp->value, i+n+1); + } else + vp->value = malloc(n+1); + if (vp->value == NULL) + syserr(progname); strcpy(vp->value+i, ass); vp->nass++; } @@ -318,9 +331,7 @@ int vc; case 'L': return(LOW); } - fprintf(stderr, "%s: illegal value for variable '%s' (%s)\n", - progname, vnam(vc), vval(vc)); - exit(1); + badvalue(vc); } @@ -373,12 +384,11 @@ register char *fnames; while (*fnames) { while (isspace(*fnames)) fnames++; cp = thisfile; - while (*fnames && !isspace(*fnames)) *cp++ = *fnames++; + while (*fnames && !isspace(*fnames)) + *cp++ = *fnames++; *cp = '\0'; - if ((thisdate = fdate(thisfile)) < 0) { - perror(thisfile); - exit(1); - } + if ((thisdate = fdate(thisfile)) < 0) + syserr(thisfile); if (thisdate > lastdate) lastdate = thisdate; } @@ -392,10 +402,8 @@ checkfiles() /* check for existence and modified tim long objdate; if (!vdef(OCTREE)) { - if ((cp = bmalloc(strlen(radname)+5)) == NULL) { - perror(progname); - exit(1); - } + if ((cp = bmalloc(strlen(radname)+5)) == NULL) + syserr(progname); sprintf(cp, "%s.oct", radname); vval(OCTREE) = cp; vdef(OCTREE)++; @@ -429,10 +437,8 @@ double org[3], *sizp; if (osiz <= FTINY) { oconv(); /* does nothing if done already */ sprintf(buf, "getinfo -d < %s", vval(OCTREE)); - if ((fp = popen(buf, "r")) == NULL) { - perror("getinfo"); - exit(1); - } + if ((fp = popen(buf, "r")) == NULL) + syserr("getinfo"); if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1], &oorg[2], &osiz) != 4) { fprintf(stderr, @@ -458,10 +464,6 @@ setdefaults() /* set default values for unassigned v vval(ZONE) = savqstr(buf); vdef(ZONE)++; } - if (!vdef(UP)) { - vval(UP) = "Z"; - vdef(UP)++; - } if (!vdef(INDIRECT)) { vval(INDIRECT) = "0"; vdef(INDIRECT)++; @@ -502,8 +504,8 @@ printvals() /* print variable values */ register int i, j; for (i = 0; i < NVARS; i++) - for (j = 0; j < vv[i].nass; j++) - printf("%s= %s\n", vv[i].name, nvalue(vv+i, j)); + for (j = 0; j < vdef(i); j++) + printf("%s= %s\n", vnam(i), nvalue(vv+i, j)); fflush(stdout); } @@ -516,16 +518,14 @@ oconv() /* run oconv if necessary */ return; /* build command */ oconvopts(ocopts); - sprintf(combuf, "oconv%s %s %s > %s", ocopts, - vdef(MATERIAL) ? vval(MATERIAL) : "", - vval(SCENE), vval(OCTREE)); - if (!silent) { /* echo it */ - printf("\t%s\n", combuf); - fflush(stdout); - } - if (noaction) - return; - if (system(combuf)) { /* run it */ + if (vdef(MATERIAL)) + sprintf(combuf, "oconv%s %s %s > %s", ocopts, + vval(MATERIAL), vval(SCENE), vval(OCTREE)); + else + sprintf(combuf, "oconv%s %s > %s", ocopts, + vval(SCENE), vval(OCTREE)); + + if (runcom(combuf)) { /* run it */ fprintf(stderr, "%s: error generating octree\n\t%s removed\n", progname, vval(OCTREE)); unlink(vval(OCTREE)); @@ -557,18 +557,33 @@ register char *oo; } +checkambfile() /* check date on ambient file */ +{ + long afdate; + + if (vdef(AMBFILE)) { + afdate = fdate(vval(AMBFILE)); + if (afdate >= 0 & octreedate > afdate) + rmfile(vval(AMBFILE)); + } +} + + double ambval() /* compute ambient value */ { - if (vdef(EXPOSURE)) + if (vdef(EXPOSURE)) { if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') return(.5/pow(2.,atof(vval(EXPOSURE)))); - else + if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.') return(.5/atof(vval(EXPOSURE))); + badvalue(EXPOSURE); + } if (vlet(ZONE) == 'E') return(10.); - else + if (vlet(ZONE) == 'I') return(.01); + badvalue(ZONE); } @@ -579,30 +594,24 @@ register char *op; *op = '\0'; if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], - &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) { - fprintf(stderr, "%s: bad value for variable '%s'\n", - progname, vnam(ZONE)); - exit(1); - } + &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) + badvalue(ZONE); siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; getoctcube(org, &d); d *= 3./(siz[0]+siz[1]+siz[2]); switch (vscale(DETAIL)) { case LOW: - op = addarg(op, "-ps 16"); - op = addarg(op, "-dp 16"); + op = addarg(op, "-ps 16 -dp 16"); sprintf(op, " -ar %d", (int)(4*d)); op += strlen(op); break; case MEDIUM: - op = addarg(op, "-ps 8"); - op = addarg(op, "-dp 32"); + op = addarg(op, "-ps 8 -dp 32"); sprintf(op, " -ar %d", (int)(8*d)); op += strlen(op); break; case HIGH: - op = addarg(op, "-ps 4"); - op = addarg(op, "-dp 64"); + op = addarg(op, "-ps 4 -dp 64"); sprintf(op, " -ar %d", (int)(16*d)); op += strlen(op); break; @@ -610,12 +619,9 @@ register char *op; op = addarg(op, "-pt .16"); if (vbool(PENUMBRAS)) op = addarg(op, "-ds .4"); - op = addarg(op, "-dt .2"); - op = addarg(op, "-dc .25"); - op = addarg(op, "-dr 0"); - op = addarg(op, "-sj 0"); - op = addarg(op, "-st .7"); - op = addarg(op, "-ab 0"); + else + op = addarg(op, "-ds 0"); + op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .7"); if (vdef(AMBFILE)) { sprintf(op, " -af %s", vval(AMBFILE)); op += strlen(op); @@ -623,24 +629,20 @@ register char *op; overture = 0; switch (vscale(VARIABILITY)) { case LOW: - op = addarg(op, "-aa .4"); - op = addarg(op, "-ad 32"); + op = addarg(op, "-aa .4 -ad 32"); break; case MEDIUM: - op = addarg(op, "-aa .3"); - op = addarg(op, "-ad 64"); + op = addarg(op, "-aa .3 -ad 64"); break; case HIGH: - op = addarg(op, "-aa .25"); - op = addarg(op, "-ad 128"); + op = addarg(op, "-aa .25 -ad 128"); break; } op = addarg(op, "-as 0"); d = ambval(); sprintf(op, " -av %.2g %.2g %.2g", d, d, d); op += strlen(op); - op = addarg(op, "-lr 3"); - op = addarg(op, "-lw .02"); + op = addarg(op, "-lr 3 -lw .02"); if (vdef(RENDER)) op = addarg(op, vval(RENDER)); } @@ -653,11 +655,8 @@ register char *op; *op = '\0'; if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], - &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) { - fprintf(stderr, "%s: bad value for variable '%s'\n", - progname, vnam(ZONE)); - exit(1); - } + &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) + badvalue(ZONE); siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; getoctcube(org, &d); d *= 3./(siz[0]+siz[1]+siz[2]); @@ -682,18 +681,15 @@ register char *op; break; } op = addarg(op, "-pt .08"); - if (vbool(PENUMBRAS)) { - op = addarg(op, "-ds .2"); - op = addarg(op, "-dj .35"); - } else + if (vbool(PENUMBRAS)) + op = addarg(op, "-ds .2 -dj .35"); + else op = addarg(op, "-ds .3"); - op = addarg(op, "-dt .1"); - op = addarg(op, "-dc .5"); - op = addarg(op, "-dr 1"); - op = addarg(op, "-sj .7"); - op = addarg(op, "-st .15"); - sprintf(op, " -ab %d", overture=vint(INDIRECT)); - op += strlen(op); + op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .15"); + if (overture = vint(INDIRECT)) { + sprintf(op, " -ab %d", overture); + op += strlen(op); + } if (vdef(AMBFILE)) { sprintf(op, " -af %s", vval(AMBFILE)); op += strlen(op); @@ -701,26 +697,19 @@ register char *op; overture = 0; switch (vscale(VARIABILITY)) { case LOW: - op = addarg(op, "-aa .25"); - op = addarg(op, "-ad 128"); - op = addarg(op, "-as 0"); + op = addarg(op, "-aa .25 -ad 128 -as 0"); break; case MEDIUM: - op = addarg(op, "-aa .2"); - op = addarg(op, "-ad 300"); - op = addarg(op, "-as 64"); + op = addarg(op, "-aa .2 -ad 300 -as 64"); break; case HIGH: - op = addarg(op, "-aa .15"); - op = addarg(op, "-ad 500"); - op = addarg(op, "-as 128"); + op = addarg(op, "-aa .15 -ad 500 -as 128"); break; } d = ambval(); sprintf(op, " -av %.2g %.2g %.2g", d, d, d); op += strlen(op); - op = addarg(op, "-lr 6"); - op = addarg(op, "-lw .002"); + op = addarg(op, "-lr 6 -lw .002"); if (vdef(RENDER)) op = addarg(op, vval(RENDER)); } @@ -733,11 +722,8 @@ register char *op; *op = '\0'; if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], - &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) { - fprintf(stderr, "%s: bad value for variable '%s'\n", - progname, vnam(ZONE)); - exit(1); - } + &siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) + badvalue(ZONE); siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; getoctcube(org, &d); d *= 3./(siz[0]+siz[1]+siz[2]); @@ -762,16 +748,11 @@ register char *op; break; } op = addarg(op, "-pt .04"); - if (vbool(PENUMBRAS)) { - op = addarg(op, "-ds .1"); - op = addarg(op, "-dj .7"); - } else + if (vbool(PENUMBRAS)) + op = addarg(op, "-ds .1 -dj .7"); + else op = addarg(op, "-ds .2"); - op = addarg(op, "-dt .05"); - op = addarg(op, "-dc .75"); - op = addarg(op, "-dr 3"); - op = addarg(op, "-sj 1"); - op = addarg(op, "-st .03"); + op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .03"); sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); op += strlen(op); if (vdef(AMBFILE)) { @@ -781,26 +762,19 @@ register char *op; overture = 0; switch (vscale(VARIABILITY)) { case LOW: - op = addarg(op, "-aa .15"); - op = addarg(op, "-ad 200"); - op = addarg(op, "-as 0"); + op = addarg(op, "-aa .15 -ad 200 -as 0"); break; case MEDIUM: - op = addarg(op, "-aa .125"); - op = addarg(op, "-ad 512"); - op = addarg(op, "-as 128"); + op = addarg(op, "-aa .125 -ad 512 -as 128"); break; case HIGH: - op = addarg(op, "-aa .08"); - op = addarg(op, "-ad 850"); - op = addarg(op, "-as 256"); + op = addarg(op, "-aa .08 -ad 850 -as 256"); break; } d = ambval(); sprintf(op, " -av %.2g %.2g %.2g", d, d, d); op += strlen(op); - op = addarg(op, "-lr 12"); - op = addarg(op, "-lw .0005"); + op = addarg(op, "-lr 12 -lw .0005"); if (vdef(RENDER)) op = addarg(op, vval(RENDER)); } @@ -815,27 +789,19 @@ char *ro; if (n < 2) return; if (vdef(OPTFILE)) { - if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) { - perror(vval(OPTFILE)); - exit(1); - } - if (write(fd, ro+1, n-1) != n-1) { - perror(vval(OPTFILE)); - exit(1); - } + if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) + syserr(vval(OPTFILE)); + if (write(fd, ro+1, n-1) != n-1) + syserr(vval(OPTFILE)); write(fd, "\n", 1); close(fd); - ro[0] = ' '; - ro[1] = '^'; - strcpy(ro+2, vval(OPTFILE)); + sprintf(ro, " \"^%s\"", vval(OPTFILE)); } #ifdef MSDOS else if (n > 50) { register char *evp = bmalloc(n+6); - if (evp == NULL) { - perror(progname); - exit(1); - } + if (evp == NULL) + syserr(progname); strcpy(evp, "ROPT="); strcat(evp, ro); if (putenv(evp) != 0) { @@ -880,17 +846,29 @@ char * specview(vs) /* get proper view spec from vs */ register char *vs; { + static char vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0", + "-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"}; static char viewopts[128]; register char *cp; - int xpos, ypos, zpos, viewtype; - int exterior; + int xpos, ypos, zpos, viewtype, upax; + register int i; double cent[3], dim[3], mult, d; if (vs == NULL || *vs == '-') return(vs); + upax = 0; /* get the up vector */ + if (vdef(UP)) { + if (vval(UP)[0] == '-' || vval(UP)[0] == '+') + upax = 1-'X'+UPPER(vval(UP)[1]); + else + upax = 1-'X'+vlet(UP); + if (upax < 1 | upax > 3) + badvalue(UP); + if (vval(UP)[0] == '-') + upax = -upax; + } /* check standard view names */ xpos = ypos = zpos = 0; - viewtype = 0; if (*vs == 'X') { xpos = 1; vs++; } else if (*vs == 'x') { @@ -906,55 +884,47 @@ register char *vs; } else if (*vs == 'z') { zpos = -1; vs++; } + viewtype = 'v'; if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h') viewtype = *vs++; - else if (!*vs || isspace(*vs)) - viewtype = 'v'; cp = viewopts; - if (viewtype && (xpos|ypos|zpos)) { /* got standard view */ + if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */ *cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype; if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", ¢[0], &dim[0], ¢[1], &dim[1], - ¢[2], &dim[2]) != 6) { - fprintf(stderr, "%s: bad zone specification\n", - progname); - exit(1); + ¢[2], &dim[2]) != 6) + badvalue(ZONE); + for (i = 0; i < 3; i++) { + dim[i] -= cent[i]; + cent[i] += .5*dim[i]; } - dim[0] -= cent[0]; cent[0] += .5*dim[0]; - dim[1] -= cent[1]; cent[1] += .5*dim[1]; - dim[2] -= cent[2]; cent[2] += .5*dim[2]; - exterior = vlet(ZONE) == 'E'; - mult = exterior ? 2. : .45 ; + mult = vlet(ZONE)=='E' ? 2. : .45 ; sprintf(cp, " -vp %.2g %.2g %.2g -vd %.2g %.2g %.2g", cent[0]+xpos*mult*dim[0], cent[1]+ypos*mult*dim[1], cent[2]+zpos*mult*dim[2], -xpos*dim[0], -ypos*dim[1], -zpos*dim[2]); cp += strlen(cp); - switch (vlet(UP)) { - case 'Z': - if (xpos|ypos) { - cp = addarg(cp, "-vu 0 0 1"); - break; - } - /* fall through */ - case 'Y': - if (xpos|zpos) { - cp = addarg(cp, "-vu 0 1 0"); - break; - } - /* fall through */ - case 'X': - if (ypos|zpos) - cp = addarg(cp, "-vu 1 0 0"); - else - cp = addarg(cp, "-vu 0 0 1"); + /* redirect up axis if necessary */ + switch (upax) { + case 3: /* plus or minus Z axis */ + case -3: + case 0: + if (!(xpos|ypos)) + upax = 2; break; - default: - fprintf(stderr, "%s: illegal value for variable '%s'\n", - progname, vnam(UP)); - exit(1); + case 2: /* plus or minus Y axis */ + case -2: + if (!(xpos|zpos)) + upax = 1; + break; + case 1: /* plus or minus X axis */ + case -1: + if (!(ypos|zpos)) + upax = 3; + break; } + cp = addarg(cp, vup[upax+3]); switch (viewtype) { case 'v': cp = addarg(cp, "-vh 45 -vv 45"); @@ -969,11 +939,16 @@ register char *vs; cp = addarg(cp, "-vh 180 -vv 180"); break; } - } else - while (*vs && !isspace(*vs)) /* else skip id */ - vs++; + } else { + while (!isspace(*vs)) /* else skip id */ + if (!*vs++) + return(NULL); + if (upax) { /* specify up vector */ + strcpy(cp, vup[upax+3]); + cp += strlen(cp); + } + } /* append any additional options */ - while (isspace(*vs)) vs++; strcpy(cp, vs); return(viewopts); } @@ -1024,13 +999,7 @@ char *opts; if (rvdevice != NULL) sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); strcat(combuf, vval(OCTREE)); - if (!silent) { /* echo it */ - printf("\t%s\n", combuf); - fflush(stdout); - } - if (noaction) - return; - if (system(combuf)) { /* run it */ + if (runcom(combuf)) { /* run it */ fprintf(stderr, "%s: error running rview\n", progname); exit(1); } @@ -1041,8 +1010,8 @@ rpict(opts) /* run rpict and pfilt for each view */ char *opts; { char combuf[1024]; - char rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH], res[32]; - char pfopts[64]; + char rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32]; + char pfopts[128]; char vs[32], *vw; int vn, mult; /* get pfilt options */ @@ -1060,11 +1029,8 @@ char *opts; else if (n) { if (n == 1) yres = xres; sprintf(res, "-x %d -y %d", mult*xres, mult*yres); - } else { - fprintf(stderr, "%s: bad value for variable '%s'\n", - progname, vnam(RESOLUTION)); - exit(1); - } + } else + badvalue(RESOLUTION); } rep[0] = '\0'; if (vdef(REPORT)) { @@ -1075,11 +1041,8 @@ char *opts; sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile); else if (n == 1) sprintf(rep, " -t %d", (int)(minutes*60)); - else { - fprintf(stderr, "%s: bad value for variable '%s'\n", - progname, vnam(REPORT)); - exit(1); - } + else + badvalue(REPORT); } /* do each view */ vn = 0; @@ -1100,28 +1063,22 @@ char *opts; sprintf(combuf, "rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", rep, vw, opts, - vval(OCTREE), rawfile); - if (!silent) { - printf("\t%s\n", combuf); - fflush(stdout); - } - if (!noaction && system(combuf)) { + vval(OCTREE), overfile); + if (runcom(combuf)) { fprintf(stderr, - "%s: error in overture for view %s\n\t%s removed\n", - progname, vs, rawfile); - unlink(rawfile); + "%s: error in overture for view %s\n", + progname, vs); exit(1); } +#ifdef NIX + rmfile(overfile); +#endif } sprintf(combuf, "rpict%s %s %s%s %s > %s", rep, vw, res, opts, vval(OCTREE), rawfile); } - if (!silent) { /* echo rpict command */ - printf("\t%s\n", combuf); - fflush(stdout); - } - if (!noaction && system(combuf)) { /* run rpict */ + if (runcom(combuf)) { /* run rpict */ fprintf(stderr, "%s: error rendering view %s\n", progname, vs); exit(1); @@ -1133,11 +1090,7 @@ char *opts; else sprintf(combuf, "pfilt%s %s > %s", pfopts, rawfile, picfile); - if (!silent) { /* echo pfilt command */ - printf("\t%s\n", combuf); - fflush(stdout); - } - if (!noaction && system(combuf)) { /* run pfilt */ + if (runcom(combuf)) { /* run pfilt */ fprintf(stderr, "%s: error filtering view %s\n\t%s removed\n", progname, vs, picfile); @@ -1145,13 +1098,50 @@ char *opts; exit(1); } /* remove raw file */ - if (!silent) + rmfile(rawfile); + } +} + + +runcom(cs) /* run command */ +char *cs; +{ + if (!silent) /* echo it */ + printf("\t%s\n", cs); + if (noaction) + return(0); + fflush(stdout); /* flush output and pass to shell */ + return(system(cs)); +} + + +rmfile(fn) /* remove a file */ +char *fn; +{ + if (!silent) #ifdef MSDOS - printf("\tdel %s\n", rawfile); + printf("\tdel %s\n", fn); #else - printf("\trm %s\n", rawfile); + printf("\trm -f %s\n", fn); #endif - if (!noaction) - unlink(rawfile); - } + if (noaction) + return(0); + return(unlink(fn)); +} + + +badvalue(vc) /* report bad variable value and exit */ +int vc; +{ + fprintf(stderr, "%s: bad value for variable '%s'\n", + progname, vnam(vc)); + exit(1); +} + + +syserr(s) /* report a system error and exit */ +char *s; +{ + perror(s); + exit(1); }