xref: /csrg-svn/usr.sbin/lpr/lptest/lptest.c (revision 56131)
122434Sdist /*
222434Sdist  * Copyright (c) 1983 Regents of the University of California.
334203Sbostic  * All rights reserved.
434203Sbostic  *
5*56131Selan  * Redistribution and use in source and binary forms, with or without
6*56131Selan  * modification, are permitted provided that the following conditions
7*56131Selan  * are met:
8*56131Selan  * 1. Redistributions of source code must retain the above copyright
9*56131Selan  *    notice, this list of conditions and the following disclaimer.
10*56131Selan  * 2. Redistributions in binary form must reproduce the above copyright
11*56131Selan  *    notice, this list of conditions and the following disclaimer in the
12*56131Selan  *    documentation and/or other materials provided with the distribution.
13*56131Selan  * 3. All advertising materials mentioning features or use of this software
14*56131Selan  *    must display the following acknowledgement:
15*56131Selan  *	This product includes software developed by the University of
16*56131Selan  *	California, Berkeley and its contributors.
17*56131Selan  * 4. Neither the name of the University nor the names of its contributors
18*56131Selan  *    may be used to endorse or promote products derived from this software
19*56131Selan  *    without specific prior written permission.
20*56131Selan  *
21*56131Selan  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22*56131Selan  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23*56131Selan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24*56131Selan  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25*56131Selan  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26*56131Selan  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27*56131Selan  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28*56131Selan  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29*56131Selan  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30*56131Selan  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*56131Selan  * SUCH DAMAGE.
3222434Sdist  */
3322434Sdist 
3415230Sralph #ifndef lint
3522434Sdist char copyright[] =
3622434Sdist "@(#) Copyright (c) 1983 Regents of the University of California.\n\
3722434Sdist  All rights reserved.\n";
3834203Sbostic #endif /* not lint */
3915230Sralph 
4022434Sdist #ifndef lint
41*56131Selan static char sccsid[] = "@(#)lptest.c	5.6 (Berkeley) 7/30/92";
4234203Sbostic #endif /* not lint */
4322434Sdist 
4455478Sbostic #include <stdlib.h>
4555478Sbostic #include <stdio.h>
4655478Sbostic 
4715230Sralph /*
4815230Sralph  * lptest -- line printer test program (and other devices).
4915230Sralph  */
50*56131Selan void
5115230Sralph main(argc, argv)
5215230Sralph 	int argc;
5315230Sralph 	char **argv;
5415230Sralph {
5515230Sralph 	int len, count;
5615230Sralph 	register i, j, fc, nc;
5715230Sralph 	char outbuf[BUFSIZ];
5815230Sralph 
5915230Sralph 	setbuf(stdout, outbuf);
6015230Sralph 	if (argc >= 2)
6115230Sralph 		len = atoi(argv[1]);
6215230Sralph 	else
6315230Sralph 		len = 79;
6415230Sralph 	if (argc >= 3)
6515230Sralph 		count = atoi(argv[2]);
6615230Sralph 	else
6715230Sralph 		count = 200;
6815230Sralph 	fc = ' ';
6915230Sralph 	for (i = 0; i < count; i++) {
7015230Sralph 		if (++fc == 0177)
7115230Sralph 			fc = ' ';
7215230Sralph 		nc = fc;
7315230Sralph 		for (j = 0; j < len; j++) {
7415230Sralph 			putchar(nc);
7515230Sralph 			if (++nc == 0177)
7615230Sralph 				nc = ' ';
7715230Sralph 		}
7815230Sralph 		putchar('\n');
7915230Sralph 	}
8015230Sralph 	(void) fflush(stdout);
8155478Sbostic 	exit(0);
8215230Sralph }
83