Importing NetBSD banner

This commit is contained in:
David Höppner 2012-12-24 19:00:31 +00:00 committed by Lionel Sambuc
parent 6ee180f5f7
commit 4de64f892a
12 changed files with 2549 additions and 184 deletions

View file

@ -2,7 +2,7 @@
.include <bsd.own.mk>
SUBDIR= add_route arp ash at backup banner basename btrace \
SUBDIR= add_route arp ash at backup basename btrace \
cawf cd cdprobe cpp \
chmod chown ci cleantmp cmp co \
comm compress cp crc cron crontab cut \

View file

@ -1,4 +0,0 @@
PROG= banner
MAN=
.include <bsd.prog.mk>

View file

@ -1,153 +0,0 @@
/* banner - print a banner Author: Brian Wallis */
/*****************************************************************
*
* SYSVbanner.c
*
* This is a PD version of the SYS V banner program (at least I think
* it is compatible to SYS V) which I wrote to use with the clock
* program written by:
** DCF, Inc.
** 14623 North 49th Place
** Scottsdale, AZ 85254
* and published in the net comp.sources.misc newsgroup in early July
* since the BSD banner program works quite differently.
*
* There is no copyright or responsibility accepted for the use
* of this software.
*
* Brian Wallis, brw@jim.odr.oz, 4 July 1988
*
*****************************************************************/
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv);
char *glyphs[] = {
" @@@ @@ @@ @ @ @@@@@ @@ @@@ ",
" @@@ @@ @@ @ @ @ @ @@@ @ @ @ @@@ ",
" @@@ @ @ @@@@@@@@ @ @@ @ @@ @ ",
" @ @ @ @@@@@ @ @@@ @ ",
" @@@@@@@ @ @ @ @ @ @ ",
" @@@ @ @ @ @ @ @ @@ @ @ ",
" @@@ @ @ @@@@@ @ @@ @@@@ @ ",
" @@ @@ @",
" @ @ @ @ @ @ ",
" @ @ @ @ @ @ ",
" @ @ @@@@@@@ @@@@@ @@@ @@@@@ @ ",
" @ @ @ @ @ @@@ @ ",
" @ @ @ @ @ @ @@@ @ ",
" @@ @@ @ @@@ @ ",
" @@@ @ @@@@@ @@@@@ @ @@@@@@@ @@@@@ @@@@@@@",
" @ @ @@ @ @@ @@ @ @ @ @@ @ ",
"@ @ @ @ @ @ @@ @ @ @ @ ",
"@ @ @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;
char *argv[];
{
int a, b, c, len, ind;
char line[80];
for (argv++; --argc; argv++) {
len = strlen(*argv);
if (len > 10) len = 10;
for (a = 0; a < 7; a++) {
for (b = 0; b < len; b++) {
if ((ind = (*argv)[b] - ' ') < 0) ind = 0;
for (c = 0; c < 7; c++) {
line[b * 8 + c] = glyphs[(ind / 8 * 7) + a][(ind % 8 * 7) + c] == '@' ? ind + ' ' : ' ';
}
line[b * 8 + 7] = ' ';
}
for (b = len * 8 - 1; b >= 0; b--) {
if (line[b] != ' ') break;
line[b] = '\0';
}
printf("%s\n", line);
}
printf("\n");
}
return(0);
}

View file

@ -1,4 +1,4 @@
MAN= ash.1 at.1 banner.1 basename.1 \
MAN= ash.1 at.1 basename.1 \
bsfilt.1 cawf.1 chgrp.1 \
chmod.1 cmp.1 comm.1 compress.1 \
cp.1 crc.1 crontab.1 dd.1 \

View file

@ -1,24 +0,0 @@
.TH BANNER 1
.SH NAME
banner \- print a banner
.SH SYNOPSIS
\fBbanner \fIarg ...\fR
.br
.de FL
.TP
\\fB\\$1\\fR
\\$2
..
.de EX
.TP 20
\\fB\\$1\\fR
# \\$2
..
.SH EXAMPLES
.TP 20
.B banner happy birthday
# Print a banner saying happy birthday
.SH DESCRIPTION
.PP
\fIBanner\fR prints its arguments on \fIstdout\fR using a matrix
of 6 x 6 pixels per character.

View file

@ -121,6 +121,7 @@
2012/10/17 12:00:00,tools/tic
2012/10/17 12:00:00,tools/tsort
2009/05/08 12:48:43,usr.bin/apropos
2012/10/17 12:00:00,usr.bin/banner
2012/10/17 12:00:00,usr.bin/bzip2
2012/10/17 12:00:00,usr.bin/bzip2recover
2013/03/15 12:00:00,usr.bin/cal

View file

@ -4,7 +4,7 @@
.include <bsd.own.mk>
SUBDIR= \
\
banner \
bzip2 bzip2recover \
cal chpass cksum \
col ctags \

17
usr.bin/banner/Makefile Normal file
View file

@ -0,0 +1,17 @@
# $NetBSD: Makefile,v 1.4 2009/04/14 22:15:17 lukem Exp $
PROG= banner
SRCS= $(PROG).c chset.c
# if you want to make chars from the letter involved (like lpd), then
# un-comment the following.
#CPPFLAGS+= -DNOHASH_ONLY
# if you want to use the same char set that lpd uses then un-comment
# the following. Lpd uses a much nicer character set but banner
# output will not be the same as the real thing.
#CPPFLAGS+= -DLPD_CHSET
.include <bsd.prog.mk>

63
usr.bin/banner/banner.1 Normal file
View file

@ -0,0 +1,63 @@
.\" $NetBSD: banner.1,v 1.9 2012/02/29 08:54:55 wiz Exp $
.\"
.\" @(#)Copyright (c) 1995, Simon J. Gerraty.
.\"
.\" This is free software. It comes with NO WARRANTY.
.\" Permission to use, modify and distribute this source code
.\" is granted subject to the following conditions.
.\" 1/ that the above copyright notice and this notice
.\" are preserved in all copies and that due credit be given
.\" to the author.
.\" 2/ that any changes to this code are clearly commented
.\" as such so that the author does not get blamed for bugs
.\" other than his own.
.\"
.\" Please send copies of changes and bug-fixes to:
.\" sjg@zen.void.oz.au
.\"
.Dd February 26, 2012
.Dt BANNER 1
.Os
.Sh NAME
.Nm banner
.Nd print strings in large letters
.Sh SYNOPSIS
.Nm
.Op Fl l
.Op Fl b Ar bg
.Op Fl f Ar fg
.Ar string ...
.Sh DESCRIPTION
.Nm
prints up to 10 chars of each
.Ar string
in large letters on the standard output.
.Pp
The options are:
.Bl -tag -width Ds
.It Fl b Ar bg
Use
.Ar bg
as the background color (character) rather than the default
.Dq \ .
.It Fl f Ar fg
Use
.Ar fg
as the foreground color (character) rather than the default
.Dq # .
If
.Ar fg
is
.Dq - ,
then the actual letter being printed is used as the
foreground color in the same way that LPD does it.
The results are quite variable.
.It Fl l
Use the more attractive LPD font instead of the traditional
.Nm
font.
.El
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
.Xr banner 6

211
usr.bin/banner/banner.c Normal file
View file

@ -0,0 +1,211 @@
/* $NetBSD: banner.c,v 1.15 2012/02/29 08:55:25 wiz Exp $ */
/*
* Changes for banner(1)
*
* @(#)Copyright (c) 1995, Simon J. Gerraty.
*
* This is free software. It comes with NO WARRANTY.
* Permission to use, modify and distribute this source code
* is granted subject to the following conditions.
* 1/ that the above copyright notice and this notice
* are preserved in all copies and that due credit be given
* to the author.
* 2/ that any changes to this code are clearly commented
* as such so that the author does not get blamed for bugs
* other than his own.
*
* Please send copies of changes and bug-fixes to:
* sjg@zen.void.oz.au
*/
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1983, 1993\
The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)printjob.c 8.2 (Berkeley) 4/16/94";
#else
__RCSID("$NetBSD: banner.c,v 1.15 2012/02/29 08:55:25 wiz Exp $");
#endif
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "banner.h"
static long PW = LINELEN;
/*
* <sjg> lpd makes chars out of the letter in question.
* the results are somewhat mixed. Sticking to '#' as
* banner(1) does is more consistent.
*/
static int ForeGnd = '#';
static int BackGnd = ' ';
static int Drop = 0; /* 3 for the LPD font */
static int dropit (int);
static void scan_out (int, char *, int);
static char *scnline (int, char *, int);
__dead static void usage(void);
/* the char gen code below is lifted from lpd */
static char *
scnline(int key, char *p, int c)
{
int scnwidth;
if (ForeGnd)
c = ForeGnd;
for (scnwidth = WIDTH; --scnwidth;) {
key <<= 1;
*p++ = key & 0200 ? c : BackGnd;
}
return (p);
}
#define TRC(q) (((q)-' ')&0177)
static int
dropit(int c)
{
switch(c) {
case TRC('_'):
case TRC(';'):
case TRC(','):
case TRC('g'):
case TRC('j'):
case TRC('p'):
case TRC('q'):
case TRC('y'):
return (Drop);
default:
return (0);
}
}
static void
scan_out(int scfd, char *scsp, int dlm)
{
char *strp;
int nchrs, j;
char outbuf[LINELEN+1], *sp, c, cc;
int d, scnhgt;
for (scnhgt = 0; scnhgt++ < HEIGHT+Drop; ) {
strp = &outbuf[0];
if (BackGnd != ' ')
*strp++ = BackGnd;
sp = scsp;
for (nchrs = 0; *sp != dlm && *sp != '\0'; ) {
cc = *sp++;
if(cc < ' ' || ((int)cc) >= 0x7f)
cc = ' ';
d = dropit(c = TRC(cc));
if ((!d && scnhgt > HEIGHT) || (scnhgt <= Drop && d))
for (j = WIDTH; --j;)
*strp++ = BackGnd;
else if (Drop == 0)
strp = scnline(
scnkey_def[(int)c][scnhgt-1-d], strp, cc);
else
strp = scnline(
scnkey_lpd[(int)c][scnhgt-1-d], strp, cc);
if (nchrs++ >= PW/(WIDTH+1)-1)
break;
*strp++ = BackGnd;
}
if (BackGnd != ' ')
*strp++ = BackGnd;
else {
while (*--strp == ' ' && strp >= outbuf)
;
strp++;
}
*strp++ = '\n';
(void) write(scfd, outbuf, strp-outbuf);
}
}
/*
* for each word, print up to 10 chars in big letters.
*/
int
main(int argc, char **argv)
{
char word[10+1]; /* strings limited to 10 chars */
int c;
while ((c = getopt(argc, argv, "b:f:l")) != -1) {
switch (c) {
case 'f':
if (*optarg == '-')
ForeGnd = 0;
else
ForeGnd = *optarg;
break;
case 'b':
BackGnd = *optarg;
break;
case 'l':
Drop = 3; /* for LPD font */
break;
default:
usage();
}
}
for (; optind < argc; ++optind) {
(void)strlcpy(word, argv[optind], sizeof (word));
scan_out(STDOUT_FILENO, word, '\0');
}
exit(0);
}
static void
usage(void)
{
fprintf(stderr, "usage: %s [-l] [-b bg] [-f fg] string ...\n",
getprogname());
exit(1);
}

28
usr.bin/banner/banner.h Normal file
View file

@ -0,0 +1,28 @@
/* $NetBSD: banner.h,v 1.4 2000/10/04 19:33:16 mjl Exp $ */
/*
* Various defines needed for code lifted from lpd.
*
* @(#)Copyright (c) 1995, Simon J. Gerraty.
*
* This is free software. It comes with NO WARRANTY.
* Permission to use, modify and distribute this source code
* is granted subject to the following conditions.
* 1/ that the above copyright notice and this notice
* are preserved in all copies and that due credit be given
* to the author.
* 2/ that any changes to this code are clearly commented
* as such so that the author does not get blamed for bugs
* other than his own.
*
* Please send copies of changes and bug-fixes to:
* sjg@zen.void.oz.au
*/
#define LINELEN 132
#define BACKGND ' '
#define HEIGHT 9 /* height of characters */
#define WIDTH 8 /* width of characters */
extern const char scnkey_lpd[][HEIGHT];
extern const char scnkey_def[][HEIGHT];

2226
usr.bin/banner/chset.c Normal file

File diff suppressed because it is too large Load diff