1331722Seadler/*
21553Srgrimes * Copyright (c) 1983, 1993
31553Srgrimes *	The Regents of the University of California.  All rights reserved.
41553Srgrimes *
51553Srgrimes *
61553Srgrimes * Redistribution and use in source and binary forms, with or without
71553Srgrimes * modification, are permitted provided that the following conditions
81553Srgrimes * are met:
91553Srgrimes * 1. Redistributions of source code must retain the above copyright
101553Srgrimes *    notice, this list of conditions and the following disclaimer.
111553Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
121553Srgrimes *    notice, this list of conditions and the following disclaimer in the
131553Srgrimes *    documentation and/or other materials provided with the distribution.
141553Srgrimes * 4. Neither the name of the University nor the names of its contributors
151553Srgrimes *    may be used to endorse or promote products derived from this software
161553Srgrimes *    without specific prior written permission.
171553Srgrimes *
181553Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
191553Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
201553Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
211553Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
221553Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
231553Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
241553Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
251553Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261553Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
271553Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
281553Srgrimes * SUCH DAMAGE.
291553Srgrimes */
301553Srgrimes
311553Srgrimes#ifndef lint
3284692Sgadstatic const char copyright[] =
331553Srgrimes"@(#) Copyright (c) 1983, 1993\n\
341553Srgrimes	The Regents of the University of California.  All rights reserved.\n";
351553Srgrimes#endif /* not lint */
361553Srgrimes
37117622Sgad#if 0
381553Srgrimes#ifndef lint
391553Srgrimesstatic char sccsid[] = "@(#)lptest.c	8.1 (Berkeley) 6/6/93";
40117622Sgad#endif /* not lint */
4178146Sgad#endif
421553Srgrimes
43117622Sgad#include "lp.cdefs.h"		/* A cross-platform version of <sys/cdefs.h> */
44117622Sgad__FBSDID("$FreeBSD$");
45117622Sgad
461553Srgrimes#include <stdlib.h>
471553Srgrimes#include <stdio.h>
48135852Sphk#include <err.h>
491553Srgrimes
501553Srgrimes/*
511553Srgrimes * lptest -- line printer test program (and other devices).
521553Srgrimes */
5319202Simpint
5478146Sgadmain(int argc, char **argv)
551553Srgrimes{
561553Srgrimes	int len, count;
5778146Sgad	register int i, j, fc, nc;
581553Srgrimes	char outbuf[BUFSIZ];
591553Srgrimes
601553Srgrimes	setbuf(stdout, outbuf);
611553Srgrimes	if (argc >= 2)
621553Srgrimes		len = atoi(argv[1]);
631553Srgrimes	else
641553Srgrimes		len = 79;
651553Srgrimes	if (argc >= 3)
661553Srgrimes		count = atoi(argv[2]);
671553Srgrimes	else
681553Srgrimes		count = 200;
691553Srgrimes	fc = ' ';
701553Srgrimes	for (i = 0; i < count; i++) {
711553Srgrimes		if (++fc == 0177)
721553Srgrimes			fc = ' ';
731553Srgrimes		nc = fc;
741553Srgrimes		for (j = 0; j < len; j++) {
75135852Sphk			if (putchar(nc) == EOF)
76135852Sphk				err(1, "Write error");
771553Srgrimes			if (++nc == 0177)
781553Srgrimes				nc = ' ';
791553Srgrimes		}
80135852Sphk		if (putchar('\n') == EOF)
81135852Sphk			err(1, "Write error");
821553Srgrimes	}
831553Srgrimes	(void) fflush(stdout);
841553Srgrimes	exit(0);
851553Srgrimes}
86