1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
12 |
|
|
13 |
|
#include <stdio.h> |
14 |
|
|
15 |
+ |
#ifdef MSDOS |
16 |
+ |
#include <fcntl.h> |
17 |
+ |
#endif |
18 |
+ |
|
19 |
+ |
#include <math.h> |
20 |
+ |
|
21 |
|
#include <errno.h> |
22 |
|
|
23 |
|
#include "color.h" |
24 |
|
|
25 |
< |
#include "resolu.h" |
25 |
> |
#include "resolu.h" |
26 |
|
|
27 |
|
#include "calcomp.h" |
28 |
|
|
40 |
|
|
41 |
|
int nfiles; /* number of input files */ |
42 |
|
|
43 |
+ |
char Command[] = "<Command>"; |
44 |
|
char vcolin[3][4] = {"ri", "gi", "bi"}; |
45 |
|
char vcolout[3][4] = {"ro", "go", "bo"}; |
46 |
|
char vbrtin[] = "li"; |
70 |
|
|
71 |
|
FILE *popen(); |
72 |
|
|
73 |
+ |
extern char *emalloc(); |
74 |
|
|
75 |
+ |
|
76 |
|
main(argc, argv) |
77 |
|
int argc; |
78 |
|
char *argv[]; |
80 |
|
int original; |
81 |
|
double f; |
82 |
|
int a, i; |
83 |
+ |
#ifdef MSDOS |
84 |
+ |
extern int _fmode; |
85 |
+ |
_fmode = O_BINARY; |
86 |
+ |
setmode(fileno(stdin), O_BINARY); |
87 |
+ |
setmode(fileno(stdout), O_BINARY); |
88 |
+ |
#endif |
89 |
|
/* scan options */ |
90 |
|
for (a = 1; a < argc; a++) { |
91 |
|
if (argv[a][0] == '-') |
140 |
|
} |
141 |
|
else { |
142 |
|
if (argv[a][0] == '!') { |
143 |
< |
input[nfiles].name = "<Command>"; |
143 |
> |
input[nfiles].name = Command; |
144 |
|
input[nfiles].fp = popen(argv[a]+1, "r"); |
145 |
|
} else { |
146 |
|
input[nfiles].name = argv[a]; |
209 |
|
eputs("Usage: "); |
210 |
|
eputs(argv[0]); |
211 |
|
eputs( |
212 |
< |
" [-w][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n"); |
212 |
> |
" [-w][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n"); |
213 |
|
quit(1); |
214 |
|
} |
215 |
|
|
349 |
|
|
350 |
|
advance() /* read in data for next scanline */ |
351 |
|
{ |
337 |
– |
extern double fabs(); |
352 |
|
int ytarget; |
353 |
|
register COLOR *st; |
354 |
|
register int i, j; |
467 |
|
} |
468 |
|
|
469 |
|
|
456 |
– |
#ifdef NIX |
457 |
– |
|
458 |
– |
quit(code) |
459 |
– |
int code; |
460 |
– |
{ |
461 |
– |
exit(code); |
462 |
– |
} |
463 |
– |
|
464 |
– |
#else |
465 |
– |
|
466 |
– |
#include <signal.h> |
467 |
– |
|
470 |
|
quit(code) /* exit gracefully */ |
471 |
|
int code; |
472 |
|
{ |
473 |
< |
int status; |
474 |
< |
|
475 |
< |
if (code) { /* abnormal exit -- kill children */ |
476 |
< |
signal(SIGPIPE, SIG_IGN); |
477 |
< |
kill(0, SIGPIPE); |
478 |
< |
} |
479 |
< |
/* reap any children */ |
478 |
< |
while (wait(&status) != -1) |
479 |
< |
if (code == 0) |
480 |
< |
code = status>>8 & 0xff; |
473 |
> |
register int i; |
474 |
> |
/* close input files */ |
475 |
> |
for (i = 0; i < nfiles; i++) |
476 |
> |
if (input[i].name == Command) |
477 |
> |
pclose(input[i].fp); |
478 |
> |
else |
479 |
> |
fclose(input[i].fp); |
480 |
|
exit(code); |
481 |
|
} |
483 |
– |
|
484 |
– |
#endif |