8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdio.h> |
11 |
+ |
#include <string.h> |
12 |
|
|
13 |
< |
#ifdef MSDOS |
14 |
< |
#include <fcntl.h> |
15 |
< |
extern int _fmode; |
13 |
> |
#include "platform.h" |
14 |
> |
#include "resolu.h" |
15 |
> |
|
16 |
> |
#ifdef getc_unlocked /* avoid nasty file-locking overhead */ |
17 |
> |
#undef getchar |
18 |
> |
#undef putchar |
19 |
> |
#define getchar getchar_unlocked |
20 |
> |
#define putchar putchar_unlocked |
21 |
|
#endif |
22 |
|
|
17 |
– |
extern int fputs(); |
23 |
|
|
24 |
+ |
static gethfunc tabstr; |
25 |
+ |
static void getdim(register FILE *fp); |
26 |
+ |
static void copycat(void); |
27 |
|
|
28 |
< |
int |
29 |
< |
tabstr(s) /* put out line followed by tab */ |
30 |
< |
register char *s; |
28 |
> |
|
29 |
> |
static int |
30 |
> |
tabstr( /* put out line followed by tab */ |
31 |
> |
register char *s, |
32 |
> |
void *p |
33 |
> |
) |
34 |
|
{ |
35 |
|
while (*s) { |
36 |
|
putchar(*s); |
42 |
|
} |
43 |
|
|
44 |
|
|
45 |
< |
main(argc, argv) |
46 |
< |
int argc; |
47 |
< |
char **argv; |
45 |
> |
int |
46 |
> |
main( |
47 |
> |
int argc, |
48 |
> |
char **argv |
49 |
> |
) |
50 |
|
{ |
51 |
|
int dim = 0; |
52 |
|
FILE *fp; |
55 |
|
if (argc > 1 && !strcmp(argv[1], "-d")) { |
56 |
|
argc--; argv++; |
57 |
|
dim = 1; |
58 |
< |
#ifdef MSDOS |
59 |
< |
setmode(fileno(stdin), _fmode = O_BINARY); |
47 |
< |
#endif |
58 |
> |
SET_DEFAULT_BINARY(); /* for output file */ |
59 |
> |
SET_FILE_BINARY(stdin); |
60 |
|
} else if (argc == 2 && !strcmp(argv[1], "-")) { |
61 |
< |
#ifdef MSDOS |
62 |
< |
setmode(fileno(stdin), O_BINARY); |
51 |
< |
setmode(fileno(stdout), O_BINARY); |
52 |
< |
#endif |
61 |
> |
SET_FILE_BINARY(stdin); |
62 |
> |
SET_FILE_BINARY(stdout); |
63 |
|
getheader(stdin, NULL, NULL); |
64 |
|
copycat(); |
65 |
< |
exit(0); |
65 |
> |
return 0; |
66 |
|
} |
67 |
|
for (i = 1; i < argc; i++) { |
68 |
|
fputs(argv[i], stdout); |
73 |
|
fputs(": ", stdout); |
74 |
|
getdim(fp); |
75 |
|
} else { |
76 |
< |
tabstr(":\n"); |
76 |
> |
tabstr(":\n", NULL); |
77 |
|
getheader(fp, tabstr, NULL); |
78 |
|
putchar('\n'); |
79 |
|
} |
80 |
|
fclose(fp); |
81 |
|
} |
82 |
|
} |
83 |
< |
if (argc == 1) |
83 |
> |
if (argc == 1) { |
84 |
|
if (dim) { |
85 |
|
getdim(stdin); |
86 |
|
} else { |
87 |
< |
getheader(stdin, fputs, stdout); |
87 |
> |
getheader(stdin, (gethfunc*)fputs, stdout); |
88 |
|
putchar('\n'); |
89 |
|
} |
90 |
< |
exit(0); |
90 |
> |
} |
91 |
> |
return 0; |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
< |
getdim(fp) /* get dimensions from file */ |
96 |
< |
register FILE *fp; |
95 |
> |
static void |
96 |
> |
getdim( /* get dimensions from file */ |
97 |
> |
register FILE *fp |
98 |
> |
) |
99 |
|
{ |
100 |
|
int j; |
101 |
|
register int c; |
129 |
|
} |
130 |
|
|
131 |
|
|
132 |
< |
copycat() /* copy input to output */ |
132 |
> |
static void |
133 |
> |
copycat(void) /* copy input to output */ |
134 |
|
{ |
135 |
|
register int c; |
136 |
|
|