--- ray/src/px/pcomb.c 1991/05/27 09:01:05 1.18 +++ ray/src/px/pcomb.c 1992/08/10 12:10:26 2.3 @@ -16,16 +16,16 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" +#include "resolu.h" + #include "calcomp.h" #define MAXINP 32 /* maximum number of input files */ #define WINSIZ 9 /* scanline window size */ #define MIDSCN 4 /* current scan position */ -#define BRT (-1) /* special index for brightness */ - struct { - char *name; /* file name */ + char *name; /* file or command name */ FILE *fp; /* stream pointer */ COLOR *scan[WINSIZ]; /* input scanline window */ COLOR coef; /* coefficient */ @@ -34,11 +34,11 @@ struct { int nfiles; /* number of input files */ -char *vcolin[3] = {"ri", "gi", "bi"}; -char *vcolout[3] = {"ro", "go", "bo"}; +char vcolin[3][4] = {"ri", "gi", "bi"}; +char vcolout[3][4] = {"ro", "go", "bo"}; char vbrtin[] = "li"; char vbrtout[] = "lo"; -char *vcolexp[3] = {"re", "ge", "be"}; +char vcolexp[3][4] = {"re", "ge", "be"}; char vbrtexp[] = "le"; char vnfiles[] = "nfiles"; @@ -61,12 +61,13 @@ int xpos, ypos; /* output position */ int wrongformat = 0; +FILE *popen(); + main(argc, argv) int argc; char *argv[]; { - char buf[128]; int original; double f; int a, i; @@ -109,7 +110,7 @@ char *argv[]; break; case 'o': original++; - break; + continue; case 's': f = atof(argv[++a]); scalecolor(input[nfiles].coef, f); @@ -123,8 +124,13 @@ char *argv[]; goto usage; } else { - input[nfiles].name = argv[a]; - input[nfiles].fp = fopen(argv[a], "r"); + if (argv[a][0] == '!') { + input[nfiles].name = ""; + input[nfiles].fp = popen(argv[a]+1, "r"); + } else { + input[nfiles].name = argv[a]; + input[nfiles].fp = fopen(argv[a], "r"); + } if (input[nfiles].fp == NULL) { perror(argv[a]); quit(1); @@ -148,16 +154,10 @@ char *argv[]; if (argv[a][0] == '-') switch (argv[a][1]) { case 'x': - strcpy(buf, vxres); - strcat(buf, ":"); - strcat(buf, argv[++a]); - scompile(buf, NULL, 0); + varset(vxres, ':', eval(argv[++a])); continue; case 'y': - strcpy(buf, vyres); - strcat(buf, ":"); - strcat(buf, argv[++a]); - scompile(buf, NULL, 0); + varset(vyres, ':', eval(argv[++a])); continue; case 'w': continue; @@ -186,7 +186,7 @@ char *argv[]; printargs(argc, argv, stdout); fputformat(COLRFMT, stdout); putchar('\n'); - fputresolu(YMAJOR|YDECR, xres, yres, stdout); + fprtresolu(xres, yres, stdout); /* combine pictures */ combine(); quit(0); @@ -194,7 +194,7 @@ usage: eputs("Usage: "); eputs(argv[0]); eputs( -" [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n"); +" [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n"); quit(1); } @@ -237,7 +237,7 @@ checkfile() /* ready a file */ eputs(": not in Radiance picture format\n"); quit(1); } - if (fgetresolu(&xinp, &yinp, input[nfiles].fp) != (YMAJOR|YDECR)) { + if (fgetresolu(&xinp, &yinp, input[nfiles].fp) < 0) { eputs(input[nfiles].name); eputs(": bad picture size\n"); quit(1); @@ -452,5 +452,11 @@ char *msg; quit(code) int code; { + int status; + + if (code == 0) /* reap any children */ + while (wait(&status) != -1) + if (code == 0) + code = status>>8 & 0xff; exit(code); }