home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_01_03
/
1n03083a
< prev
next >
Wrap
Text File
|
1990-07-31
|
1KB
|
55 lines
/*
* ANSIPRT.C - reads a file with ANSI carriage control characters from STDIN
* and writes an expanded file to STDOUT. Use redirection to
* control input and output.
*/
#include <stdio.h>
#include <string.h>
char inline[1024];
main()
{
char *workptr;
fgets(inline, sizeof(inline), stdin);
while(!feof(stdin))
{
switch(inline[0])
{
case '1': /* formfeed */
fputc('\n',stdout);
fputc('\f',stdout);
break;
case '0': /* double-space */
fputc('\n',stdout);
fputc('\n',stdout);
break;
case '-': /* triple-space */
fputc('\n',stdout);
fputc('\n',stdout);
fputc('\n',stdout);
break;
case '+': /* overwrite */
fputc('\r',stdout);
break;
default: /* single-space by default */
fputc('\n',stdout);
break;
}
workptr = strchr(inline, '\n'); /* Convert LF to CR */
if(workptr != NULL)
*workptr = '\r';
fputs(&inline[1], stdout); /* skip first character */
fgets(inline, sizeof(inline), stdin);
}
}