root/usr/src/cmd/lp/cmd/lptest/lptest.c
/*
 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/*        All Rights Reserved   */

/*
 * Copyright (c) 1983 Regents of the University of California.
 * All rights reserved.  The Berkeley software License Agreement
 * specifies the terms and conditions for redistribution.
 */

/*
 * lptest -- line printer test program (and other devices).
 */

#include <stdio.h>

int
main(int argc, char **argv)
{
        int             len, count;
        register int    i, j, fc, nc;
        char            outbuf[BUFSIZ];

        setbuf(stdout, outbuf);
        if (argc >= 2)
                len = atoi(argv[1]);
        else
                len = 79;
        if (argc >= 3)
                count = atoi(argv[2]);
        else
                count = 200;
        fc = ' ';
        for (i = 0; i < count; i++) {
                if (++fc == 0177)
                        fc = ' ';
                nc = fc;
                for (j = 0; j < len; j++) {
                        putchar(nc);
                        if (++nc == 0177)
                                nc = ' ';
                }
                putchar('\n');
        }
        (void) fflush(stdout);

        return (0);
}