xref: /original-bsd/old/vfilters/necf/necf.c (revision 40192f2d)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char sccsid[] = "@(#)necf.c	5.1 (Berkeley) 05/15/85";
9 #endif not lint
10 
11 #include <stdio.h>
12 #include <sgtty.h>
13 
14 #define PAGESIZE	66
15 
16 main()
17 {
18 	extern char _sobuf[BUFSIZ];
19 	extern char *rindex();
20 	char line[256];
21 	register char c, *cp;
22 	register lnumber;
23 
24 	setbuf(stdout, _sobuf);
25 #ifdef SHEETFEEDER
26 	printf("\033=\033\033\033O\f");
27 #else
28 	printf("\033=");
29 #endif
30 	lnumber = 0;
31 	while (fgets(line, sizeof(line), stdin) != NULL) {
32 #ifdef SHEETFEEDER
33 		if (lnumber == PAGESIZE-1) {
34 			putchar('\f');
35 			lnumber = 0;
36 		}
37 		if (lnumber >= 2) {
38 #endif
39 #ifdef TTY
40 			if ((cp = rindex(line, '\n')) != NULL)
41 				*cp = '\r';
42 #endif
43 			printf("%s", line);
44 #ifdef SHEETFEEDER
45 		}
46 		lnumber++;
47 #endif
48 	}
49 	fflush (stdout);
50 }
51