home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1995 October
/
Simtel-MSDOS-Oct1995-CD1.iso
/
disc1
/
printer
/
page.c
< prev
next >
Wrap
C/C++ Source or Header
|
1984-07-06
|
2KB
|
74 lines
#include <stdio.h>
#define pagelen 60
#define tabsize 8
/* page: print out files, converting tabs to spaces and inserting a f.f. */
/* every 66 lines. Submitted by Ron Kuper, Millar Elevator Ind., NYC */
main(argc,argv)
int argc;
char *argv[];
int i, line;
FILE *infile, *fopen();
char inbuf[133], *retn, *fgets();
if (argc==1)
fputs("Usage: PAGE file1 file2 ...",stderr);
exit(0);
for (i=1; i<argc; i++)
infile = fopen (argv[i],"r");
if (infile==NULL)
fprintf(stderr,"page: skipping file ");
fputs(argv[i],stderr);
else
putc('\014',stdout); /* send inital ff */
line = 0;
do
retn=fgets(inbuf,256,infile);
if (retn==NULL)
putc('\014',stdout);
else
outline(inbuf);
line++;
if (line==pagelen)
line = 0;
putc('\014',stdout);
while (retn!=NULL);
fclose(infile);
outline(txt)
char *txt;
register int i,j,col;
col = 0;
for (i=0; txt[i]!='\0'; i++)
if (txt[i]!='\t')
putc(txt[i],stdout);
col++;
else
j = col % tabsize;
if (j!=tabsize)
j = tabsize - j;
col += j;
while (j>0)
putc(' ',stdout);
j--;
------