1 /* $NetBSD: banner.c,v 1.11 2003/08/07 11:13:09 agc Exp $ */
4 * Changes for banner(1)
6 * @(#)Copyright (c) 1995, Simon J. Gerraty.
8 * This is free software. It comes with NO WARRANTY.
9 * Permission to use, modify and distribute this source code
10 * is granted subject to the following conditions.
11 * 1/ that the above copyright notice and this notice
12 * are preserved in all copies and that due credit be given
14 * 2/ that any changes to this code are clearly commented
15 * as such so that the author does not get blamed for bugs
18 * Please send copies of changes and bug-fixes to:
23 * Copyright (c) 1983, 1993
24 * The Regents of the University of California. All rights reserved.
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * 3. Neither the name of the University nor the names of its contributors
35 * may be used to endorse or promote products derived from this software
36 * without specific prior written permission.
38 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
39 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
42 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 #include <sys/cdefs.h>
53 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
54 The Regents of the University of California. All rights reserved.");
59 static char sccsid
[] = "@(#)printjob.c 8.2 (Berkeley) 4/16/94";
61 __RCSID("$NetBSD: banner.c,v 1.11 2003/08/07 11:13:09 agc Exp $");
72 static long PW
= LINELEN
;
74 * <sjg> lpd makes chars out of the letter in question.
75 * the results are somewhat mixed. Sticking to '#' as
76 * banner(1) does is more consistent.
78 static int ForeGnd
= '#';
79 static int BackGnd
= ' ';
80 static int Drop
= 0; /* 3 for the LPD font */
82 static int dropit (int);
83 static void scan_out (int, char *, int);
84 static char *scnline (int, char *, int);
85 static void usage(void);
87 /* the char gen code below is lifted from lpd */
90 scnline(int key
, char *p
, int c
)
97 for (scnwidth
= WIDTH
; --scnwidth
;) {
99 *p
++ = key
& 0200 ? c
: BackGnd
;
104 #define TRC(q) (((q)-' ')&0177)
128 scan_out(int scfd
, char *scsp
, int dlm
)
132 char outbuf
[LINELEN
+1], *sp
, c
, cc
;
135 for (scnhgt
= 0; scnhgt
++ < HEIGHT
+Drop
; ) {
140 for (nchrs
= 0; *sp
!= dlm
&& *sp
!= '\0'; ) {
142 if(cc
< ' ' || ((int)cc
) >= 0x7f)
144 d
= dropit(c
= TRC(cc
));
145 if ((!d
&& scnhgt
> HEIGHT
) || (scnhgt
<= Drop
&& d
))
146 for (j
= WIDTH
; --j
;)
150 scnkey_def
[(int)c
][scnhgt
-1-d
], strp
, cc
);
153 scnkey_lpd
[(int)c
][scnhgt
-1-d
], strp
, cc
);
154 if (nchrs
++ >= PW
/(WIDTH
+1)-1)
161 while (*--strp
== ' ' && strp
>= outbuf
)
166 (void) write(scfd
, outbuf
, strp
-outbuf
);
171 * for each word, print up to 10 chars in big letters.
174 main(int argc
, char **argv
)
176 char word
[10+1]; /* strings limited to 10 chars */
179 while ((c
= getopt(argc
, argv
, "b:f:l")) != -1) {
191 Drop
= 3; /* for LPD font */
198 for (; optind
< argc
; ++optind
) {
199 (void)strlcpy(word
, argv
[optind
], sizeof (word
));
200 scan_out(STDOUT_FILENO
, word
, '\0');
208 fprintf(stderr
, "usage: %s [-f fgchar] [-b bgchar] [-l] message...\n",