| 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 <errno.h> |
| 20 |
|
|
| 21 |
|
#include "color.h" |
| 38 |
|
|
| 39 |
|
int nfiles; /* number of input files */ |
| 40 |
|
|
| 41 |
+ |
char Command[] = "<Command>"; |
| 42 |
|
char vcolin[3][4] = {"ri", "gi", "bi"}; |
| 43 |
|
char vcolout[3][4] = {"ro", "go", "bo"}; |
| 44 |
|
char vbrtin[] = "li"; |
| 68 |
|
|
| 69 |
|
FILE *popen(); |
| 70 |
|
|
| 71 |
+ |
extern char *emalloc(); |
| 72 |
|
|
| 73 |
+ |
|
| 74 |
|
main(argc, argv) |
| 75 |
|
int argc; |
| 76 |
|
char *argv[]; |
| 78 |
|
int original; |
| 79 |
|
double f; |
| 80 |
|
int a, i; |
| 81 |
+ |
#ifdef MSDOS |
| 82 |
+ |
extern int _fmode; |
| 83 |
+ |
_fmode = O_BINARY; |
| 84 |
+ |
setmode(fileno(stdin), O_BINARY); |
| 85 |
+ |
setmode(fileno(stdout), O_BINARY); |
| 86 |
+ |
#endif |
| 87 |
|
/* scan options */ |
| 88 |
|
for (a = 1; a < argc; a++) { |
| 89 |
|
if (argv[a][0] == '-') |
| 138 |
|
} |
| 139 |
|
else { |
| 140 |
|
if (argv[a][0] == '!') { |
| 141 |
< |
input[nfiles].name = "<Command>"; |
| 141 |
> |
input[nfiles].name = Command; |
| 142 |
|
input[nfiles].fp = popen(argv[a]+1, "r"); |
| 143 |
|
} else { |
| 144 |
|
input[nfiles].name = argv[a]; |
| 466 |
|
} |
| 467 |
|
|
| 468 |
|
|
| 456 |
– |
#ifdef NIX |
| 457 |
– |
|
| 458 |
– |
quit(code) |
| 459 |
– |
int code; |
| 460 |
– |
{ |
| 461 |
– |
exit(code); |
| 462 |
– |
} |
| 463 |
– |
|
| 464 |
– |
#else |
| 465 |
– |
|
| 469 |
|
quit(code) /* exit gracefully */ |
| 470 |
|
int code; |
| 471 |
|
{ |
| 469 |
– |
int status; |
| 472 |
|
register int i; |
| 473 |
|
/* close input files */ |
| 474 |
|
for (i = 0; i < nfiles; i++) |
| 475 |
< |
fclose(input[i].fp); |
| 476 |
< |
/* reap children */ |
| 477 |
< |
while (wait(&status) != -1) |
| 478 |
< |
if (code == 0) |
| 477 |
< |
code = status>>8 & 0xff; |
| 475 |
> |
if (input[i].name == Command) |
| 476 |
> |
pclose(input[i].fp); |
| 477 |
> |
else |
| 478 |
> |
fclose(input[i].fp); |
| 479 |
|
exit(code); |
| 480 |
|
} |
| 480 |
– |
|
| 481 |
– |
#endif |