xref: /csrg-svn/usr.sbin/lpr/lptest/lptest.c (revision 22434)
1*22434Sdist /*
2*22434Sdist  * Copyright (c) 1983 Regents of the University of California.
3*22434Sdist  * All rights reserved.  The Berkeley software License Agreement
4*22434Sdist  * specifies the terms and conditions for redistribution.
5*22434Sdist  */
6*22434Sdist 
715230Sralph #ifndef lint
8*22434Sdist char copyright[] =
9*22434Sdist "@(#) Copyright (c) 1983 Regents of the University of California.\n\
10*22434Sdist  All rights reserved.\n";
11*22434Sdist #endif not lint
1215230Sralph 
13*22434Sdist #ifndef lint
14*22434Sdist static char sccsid[] = "@(#)lptest.c	5.1 (Berkeley) 06/06/85";
15*22434Sdist #endif not lint
16*22434Sdist 
1715230Sralph /*
1815230Sralph  * lptest -- line printer test program (and other devices).
1915230Sralph  */
2015230Sralph 
2115230Sralph #include <stdio.h>
2215230Sralph 
2315230Sralph main(argc, argv)
2415230Sralph 	int argc;
2515230Sralph 	char **argv;
2615230Sralph {
2715230Sralph 	int len, count;
2815230Sralph 	register i, j, fc, nc;
2915230Sralph 	char outbuf[BUFSIZ];
3015230Sralph 
3115230Sralph 	setbuf(stdout, outbuf);
3215230Sralph 	if (argc >= 2)
3315230Sralph 		len = atoi(argv[1]);
3415230Sralph 	else
3515230Sralph 		len = 79;
3615230Sralph 	if (argc >= 3)
3715230Sralph 		count = atoi(argv[2]);
3815230Sralph 	else
3915230Sralph 		count = 200;
4015230Sralph 	fc = ' ';
4115230Sralph 	for (i = 0; i < count; i++) {
4215230Sralph 		if (++fc == 0177)
4315230Sralph 			fc = ' ';
4415230Sralph 		nc = fc;
4515230Sralph 		for (j = 0; j < len; j++) {
4615230Sralph 			putchar(nc);
4715230Sralph 			if (++nc == 0177)
4815230Sralph 				nc = ' ';
4915230Sralph 		}
5015230Sralph 		putchar('\n');
5115230Sralph 	}
5215230Sralph 	(void) fflush(stdout);
5315230Sralph }
54