home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD1.img
/
d1xx
/
d168
/
src
/
com
/
scat.c
< prev
Wrap
C/C++ Source or Header
|
1988-11-22
|
892b
|
63 lines
#include <stdio.h>
#include <ctype.h>
main(ac, av)
char *av[];
{
register int i;
register FILE *stream;
for (i = 1; i < ac; ++i) {
stream = fopen(av[i], "r");
if (stream) {
scat(stream);
fclose(stream);
} else {
fprintf(stderr, "Unable to open %s\n", av[i]);
}
}
if (ac == 1)
scat(stdin);
}
scat(stream)
FILE *stream;
{
short c;
while ((c = fgetc(stream)) >= 0) {
if (isascii(c) && isprint(c)) {
reverse(0);
putc(c, stdout);
continue;
}
reverse(1);
putc((c|0x40)&0x7F, stdout);
if (c == '\n')
putc(c, stdout);
}
reverse(0);
}
reverse(mode)
{
static char xmode;
if (mode) {
if (!xmode) {
putc(0x9b, stdout);
putc(0x37, stdout);
putc('m', stdout);
}
} else {
if (xmode) {
putc(0x9b, stdout);
putc(0x30, stdout);
putc('m', stdout);
}
}
xmode = mode;
}