home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
1
/
1699
/
iffil.c
next >
Wrap
C/C++ Source or Header
|
1990-12-28
|
2KB
|
83 lines
/*
iffil, a printcap filter to print on the HP LaserJet Series II
Written by Brian Utterback
December 1987
*/
#include <stdio.h>
main(argc,argv)
int argc;
char *argv[];
{
int c,atoi();
int contr,width,length;
int nlines=0,npages=2;
FILE *fopen(), *fp;
char *cp,*indent;
char *logi,*host,*actf;
while (--argc) {
if (*(cp = *++argv) == '-' ) {
switch (cp[1]) {
case 'w':
width = atoi(&cp[2]);
break;
case 'l':
length = atoi(&cp[2]);
break;
case 'c':
contr++;
break;
case 'i':
indent = &cp[2];
break;
case 'n':
logi = argv[1];
break;
case 'h':
host = argv[1];
actf = argv[2];
break;
}
}
};
printf("\033E"); /* Reset the printer */
printf("\033&k3G"); /* cr || nl -> cr+nl */
if ( length == 78 ) /* Legal paper */
printf("\033&l3a2H"); /* Hand feed */
if ( length == 45 ) { /* Landscape */
if (width == 136 || width == 226 )
printf("\033&l3a2H"); /* Legal again */
printf("\033&l1O"); /* set to Landscape */
};
if (width == 132 || width == 176 || width == 226 )
printf("\033(s16.66H"); /* Compressed print */
printf("\033&a%sL",indent); /* Indented */
while ( (c = getchar()) != EOF) {
if ( c == '\n' || c == '\r' ) nlines++;
if ( c == '\f' || nlines > length) {
nlines = 0;
npages++;
};
putchar(c);
};
if (access(actf, 02) >= 0 && (fp = fopen(actf,"a")) != NULL ) {
fprintf(fp,"%7.2f\t%s:%s\n",(float)npages,host,logi);
fclose(fp);
} else {
fprintf(stderr,
"iffil: Can't open %s\n", actf);
exit(1);
};
}