1 |
greg |
1.1 |
#ifndef lint |
2 |
greg |
1.4 |
static const char RCSid[] = "$Id: cv.c,v 1.3 2003/11/15 02:13:36 schorsch Exp $"; |
3 |
greg |
1.1 |
#endif |
4 |
|
|
/* |
5 |
|
|
* Human-readable file I/O conversion program |
6 |
|
|
* |
7 |
|
|
* cc -o ../cv cv.c mfio.o cvhfio.o syscalls.o misc.o |
8 |
|
|
*/ |
9 |
|
|
|
10 |
|
|
|
11 |
|
|
#include "meta.h" |
12 |
|
|
|
13 |
greg |
1.4 |
extern int scanp(PRIMITIVE *p, FILE *fp); |
14 |
|
|
extern void printp(PRIMITIVE *p, FILE *fp); |
15 |
|
|
extern void printeof(FILE *fp); |
16 |
greg |
1.1 |
|
17 |
|
|
char *progname; |
18 |
|
|
|
19 |
|
|
|
20 |
schorsch |
1.3 |
int |
21 |
|
|
main( |
22 |
|
|
int argc, |
23 |
|
|
char **argv |
24 |
|
|
) |
25 |
greg |
1.1 |
|
26 |
|
|
{ |
27 |
|
|
FILE *fp; |
28 |
|
|
PRIMITIVE curp; |
29 |
|
|
short htom = TRUE; |
30 |
|
|
|
31 |
|
|
progname = *argv++; |
32 |
|
|
argc--; |
33 |
|
|
|
34 |
|
|
if (argc && **argv == '-') { |
35 |
|
|
htom = FALSE; |
36 |
|
|
argv++; |
37 |
|
|
argc--; |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
if (argc) |
41 |
|
|
for (; argc; argc--, argv++) { |
42 |
|
|
fp = efopen(*argv, "r"); |
43 |
|
|
if (htom) |
44 |
|
|
while (scanp(&curp, fp)) { |
45 |
|
|
writep(&curp, stdout); |
46 |
|
|
fargs(&curp); |
47 |
|
|
} |
48 |
|
|
else |
49 |
|
|
while (readp(&curp, fp)) { |
50 |
|
|
printp(&curp, stdout); |
51 |
|
|
fargs(&curp); |
52 |
|
|
} |
53 |
|
|
fclose(fp); |
54 |
|
|
} |
55 |
|
|
else |
56 |
|
|
if (htom) |
57 |
|
|
while (scanp(&curp, stdin)) { |
58 |
|
|
writep(&curp, stdout); |
59 |
|
|
fargs(&curp); |
60 |
|
|
} |
61 |
|
|
else |
62 |
|
|
while (readp(&curp, stdin)) { |
63 |
|
|
printp(&curp, stdout); |
64 |
|
|
fargs(&curp); |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
if (htom) |
68 |
|
|
writeof(stdout); |
69 |
|
|
|
70 |
|
|
return(0); |
71 |
|
|
} |