xref: /illumos-gate/usr/src/cmd/banner/banner.c (revision 2a8bcb4e)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
28*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #include <locale.h>
32*7c478bd9Sstevel@tonic-gate #include <stdio.h>
33*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #define	nchars 128	/* number of chars in char set */
37*7c478bd9Sstevel@tonic-gate #define	nlines  7	/* number of lines in a banner character */
38*7c478bd9Sstevel@tonic-gate #define	pposs 85	/* number of print positions */
39*7c478bd9Sstevel@tonic-gate 			/* on a line (must be multiple of 4) */
40*7c478bd9Sstevel@tonic-gate 			/* followed by end of string character */
41*7c478bd9Sstevel@tonic-gate #define	pospch 8	/* number of char positions per banner char */
42*7c478bd9Sstevel@tonic-gate #define	chpln  10	/* number of banner characters per line */
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate struct bann {
45*7c478bd9Sstevel@tonic-gate 	char alpha[nlines][pposs];
46*7c478bd9Sstevel@tonic-gate };
47*7c478bd9Sstevel@tonic-gate static struct bann buffer, *bp = &buffer;
48*7c478bd9Sstevel@tonic-gate static char ctbl[nchars][nlines] = {
49*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
50*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
51*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
52*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
53*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
54*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
55*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
56*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
57*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
58*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
59*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
60*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
61*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
62*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
63*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
64*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
65*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
66*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
67*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
68*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
69*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
70*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
71*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
72*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
73*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
74*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
75*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
76*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
77*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
78*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
79*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
80*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/* below 040 */
81*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000, 	/*  */
82*7c478bd9Sstevel@tonic-gate 	034, 034, 034, 010, 0, 034, 034, 	/* ! */
83*7c478bd9Sstevel@tonic-gate 	0167, 0167, 042, 0, 0, 0, 0,		/* " */
84*7c478bd9Sstevel@tonic-gate 	024, 024, 0177, 024, 0177, 024, 024, 	/* # */
85*7c478bd9Sstevel@tonic-gate 	076, 0111, 0110, 076, 011, 0111, 076, 	/* $ */
86*7c478bd9Sstevel@tonic-gate 	0161, 0122, 0164, 010, 027, 045, 0107, 	/* % */
87*7c478bd9Sstevel@tonic-gate 	030, 044, 030, 070, 0105, 0102, 071, 	/* & */
88*7c478bd9Sstevel@tonic-gate 	034, 034, 010, 020, 0, 0, 0,    	/* ' */
89*7c478bd9Sstevel@tonic-gate 	014, 020, 040, 040, 040, 020, 014, 	/* ( */
90*7c478bd9Sstevel@tonic-gate 	030, 4, 2, 2, 2, 4, 030,		/* ) */
91*7c478bd9Sstevel@tonic-gate 	0, 042, 024, 0177, 024, 042, 0, 	/* * */
92*7c478bd9Sstevel@tonic-gate 	0, 010, 010, 076, 010, 010, 0,   	/* + */
93*7c478bd9Sstevel@tonic-gate 	0, 0, 0, 034, 034, 010, 020,    	/* , */
94*7c478bd9Sstevel@tonic-gate 	0, 0, 0, 076, 0, 0, 0,			/* - */
95*7c478bd9Sstevel@tonic-gate 	0, 0, 0, 0, 034, 034, 034,		/* . */
96*7c478bd9Sstevel@tonic-gate 	1, 2, 4, 010, 020, 040, 0100,   	/* / */
97*7c478bd9Sstevel@tonic-gate 	034, 042, 0101, 0101, 0101, 042, 034, 	/* 0 */
98*7c478bd9Sstevel@tonic-gate 	010, 030, 050, 010, 010, 010, 076, 	/* 1 */
99*7c478bd9Sstevel@tonic-gate 	076, 0101, 1, 076, 0100, 0100, 0177, 	/* 2 */
100*7c478bd9Sstevel@tonic-gate 	076, 0101, 1, 076, 1, 0101, 076, 	/* 3 */
101*7c478bd9Sstevel@tonic-gate 	0100, 0102, 0102, 0102, 0177, 2, 2, 	/* 4 */
102*7c478bd9Sstevel@tonic-gate 	0177, 0100, 0100, 0176, 1, 0101, 076, 	/* 5 */
103*7c478bd9Sstevel@tonic-gate 	076, 0101, 0100, 0176, 0101, 0101, 076, /* 6 */
104*7c478bd9Sstevel@tonic-gate 	0177, 0102, 04, 010, 020, 020, 020, 	/* 7 */
105*7c478bd9Sstevel@tonic-gate 	076, 0101, 0101, 076, 0101, 0101, 076, 	/* 8 */
106*7c478bd9Sstevel@tonic-gate 	076, 0101, 0101, 077, 1, 0101, 076, 	/* 9 */
107*7c478bd9Sstevel@tonic-gate 	010, 034, 010, 0, 010, 034, 010, 	/* : */
108*7c478bd9Sstevel@tonic-gate 	034, 034, 0, 034, 034, 010, 020, 	/* ; */
109*7c478bd9Sstevel@tonic-gate 	4, 010, 020, 040, 020, 010, 4,    	/* < */
110*7c478bd9Sstevel@tonic-gate 	0, 0, 076, 0, 076, 0, 0,		/* = */
111*7c478bd9Sstevel@tonic-gate 	020, 010, 4, 2, 4, 010, 020,    	/* > */
112*7c478bd9Sstevel@tonic-gate 	076, 0101, 1, 016, 010, 0, 010, 	/* ? */
113*7c478bd9Sstevel@tonic-gate 	076, 0101, 0135, 0135, 0136, 0100, 076, 	/* @ */
114*7c478bd9Sstevel@tonic-gate 	010, 024, 042, 0101, 0177, 0101, 0101,   	/* A */
115*7c478bd9Sstevel@tonic-gate 	0176, 0101, 0101, 0176, 0101, 0101, 0176, 	/* B */
116*7c478bd9Sstevel@tonic-gate 	076, 0101, 0100, 0100, 0100, 0101, 076, 	/* C */
117*7c478bd9Sstevel@tonic-gate 	0176, 0101, 0101, 0101, 0101, 0101, 0176, 	/* D */
118*7c478bd9Sstevel@tonic-gate 	0177, 0100, 0100, 0174, 0100, 0100, 0177, 	/* E */
119*7c478bd9Sstevel@tonic-gate 	0177, 0100, 0100, 0174, 0100, 0100, 0100, 	/* F */
120*7c478bd9Sstevel@tonic-gate 	076, 0101, 0100, 0117, 0101, 0101, 076, 	/* G */
121*7c478bd9Sstevel@tonic-gate 	0101, 0101, 0101, 0177, 0101, 0101, 0101, 	/* H */
122*7c478bd9Sstevel@tonic-gate 	034, 010, 010, 010, 010, 010, 034,		/* I */
123*7c478bd9Sstevel@tonic-gate 	1, 1, 1, 1, 0101, 0101, 076,			/* J */
124*7c478bd9Sstevel@tonic-gate 	0102, 0104, 0110, 0160, 0110, 0104, 0102, 	/* K */
125*7c478bd9Sstevel@tonic-gate 	0100, 0100, 0100, 0100, 0100, 0100, 0177, 	/* L */
126*7c478bd9Sstevel@tonic-gate 	0101, 0143, 0125, 0111, 0101, 0101, 0101, 	/* M */
127*7c478bd9Sstevel@tonic-gate 	0101, 0141, 0121, 0111, 0105, 0103, 0101, 	/* N */
128*7c478bd9Sstevel@tonic-gate 	0177, 0101, 0101, 0101, 0101, 0101, 0177, 	/* O */
129*7c478bd9Sstevel@tonic-gate 	0176, 0101, 0101, 0176, 0100, 0100, 0100, 	/* P */
130*7c478bd9Sstevel@tonic-gate 	076, 0101, 0101, 0101, 0105, 0102, 075, 	/* Q */
131*7c478bd9Sstevel@tonic-gate 	0176, 0101, 0101, 0176, 0104, 0102, 0101, 	/* R */
132*7c478bd9Sstevel@tonic-gate 	076, 0101, 0100, 076, 1, 0101, 076,		/* S */
133*7c478bd9Sstevel@tonic-gate 	0177, 010, 010, 010, 010, 010, 010,		/* T */
134*7c478bd9Sstevel@tonic-gate 	0101, 0101, 0101, 0101, 0101, 0101, 076, 	/* U */
135*7c478bd9Sstevel@tonic-gate 	0101, 0101, 0101, 0101, 042, 024, 010,   	/* V */
136*7c478bd9Sstevel@tonic-gate 	0101, 0111, 0111, 0111, 0111, 0111, 066, 	/* W */
137*7c478bd9Sstevel@tonic-gate 	0101, 042, 024, 010, 024, 042, 0101,    	/* X */
138*7c478bd9Sstevel@tonic-gate 	0101, 042, 024, 010, 010, 010, 010,		/* Y */
139*7c478bd9Sstevel@tonic-gate 	0177, 2, 4, 010, 020, 040, 0177,		/* Z */
140*7c478bd9Sstevel@tonic-gate 	076, 040, 040, 040, 040, 040, 076,		/* [ */
141*7c478bd9Sstevel@tonic-gate 	0100, 040, 020, 010, 004, 002, 001,		/* \ */
142*7c478bd9Sstevel@tonic-gate 	076, 2, 2, 2, 2, 2, 076,			/* ] */
143*7c478bd9Sstevel@tonic-gate 	010, 024, 042, 0, 0, 0, 0,			/* ^ */
144*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 0177,		/* _ */
145*7c478bd9Sstevel@tonic-gate 	034, 034, 010, 04, 0, 0, 0,			/* ` */
146*7c478bd9Sstevel@tonic-gate 	0, 014, 022, 041, 077, 041, 041, 	/* A */
147*7c478bd9Sstevel@tonic-gate 	0, 076, 041, 076, 041, 041, 076, 	/* B */
148*7c478bd9Sstevel@tonic-gate 	0, 036, 041, 040, 040, 041, 036, 	/* C */
149*7c478bd9Sstevel@tonic-gate 	0, 076, 041, 041, 041, 041, 076, 	/* D */
150*7c478bd9Sstevel@tonic-gate 	0, 077, 040, 076, 040, 040, 077, 	/* E */
151*7c478bd9Sstevel@tonic-gate 	0, 077, 040, 076, 040, 040, 040, 	/* F */
152*7c478bd9Sstevel@tonic-gate 	0, 036, 041, 040, 047, 041, 036, 	/* G */
153*7c478bd9Sstevel@tonic-gate 	0, 041, 041, 077, 041, 041, 041, 	/* H */
154*7c478bd9Sstevel@tonic-gate 	0, 004, 004, 004, 004, 004, 004, 	/* I */
155*7c478bd9Sstevel@tonic-gate 	0, 001, 001, 001, 001, 041, 036, 	/* J */
156*7c478bd9Sstevel@tonic-gate 	0, 041, 042, 074, 044, 042, 041, 	/* K */
157*7c478bd9Sstevel@tonic-gate 	0, 040, 040, 040, 040, 040, 077, 	/* L */
158*7c478bd9Sstevel@tonic-gate 	0, 041, 063, 055, 041, 041, 041, 	/* M */
159*7c478bd9Sstevel@tonic-gate 	0, 041, 061, 051, 045, 043, 041, 	/* N */
160*7c478bd9Sstevel@tonic-gate 	0, 036, 041, 041, 041, 041, 036, 	/* O */
161*7c478bd9Sstevel@tonic-gate 	0, 076, 041, 041, 076, 040, 040, 	/* P */
162*7c478bd9Sstevel@tonic-gate 	0, 036, 041, 041, 045, 042, 035, 	/* Q */
163*7c478bd9Sstevel@tonic-gate 	0, 076, 041, 041, 076, 042, 041, 	/* R */
164*7c478bd9Sstevel@tonic-gate 	0, 036, 040, 036, 001, 041, 036, 	/* S */
165*7c478bd9Sstevel@tonic-gate 	0, 037, 004, 004, 004, 004, 004, 	/* T */
166*7c478bd9Sstevel@tonic-gate 	0, 041, 041, 041, 041, 041, 036, 	/* U */
167*7c478bd9Sstevel@tonic-gate 	0, 041, 041, 041, 041, 022, 014, 	/* V */
168*7c478bd9Sstevel@tonic-gate 	0, 041, 041, 041, 055, 063, 041, 	/* W */
169*7c478bd9Sstevel@tonic-gate 	0, 041, 022, 014, 014, 022, 041, 	/* X */
170*7c478bd9Sstevel@tonic-gate 	0, 021, 012, 004, 004, 004, 004, 	/* Y */
171*7c478bd9Sstevel@tonic-gate 	0, 077, 002, 004, 010, 020, 077, 	/* Z */
172*7c478bd9Sstevel@tonic-gate 	034, 040, 040, 0140, 040, 040, 034, 	/* { */
173*7c478bd9Sstevel@tonic-gate 	010, 010, 010, 0, 010, 010, 010, 	/* | */
174*7c478bd9Sstevel@tonic-gate 	034, 2, 2, 3, 2, 2, 034,		/* } */
175*7c478bd9Sstevel@tonic-gate 	060, 0111, 06, 0, 0, 0, 0,		/* ~ */
176*7c478bd9Sstevel@tonic-gate 	0, 000, 000, 000, 000, 000, 000 	/* DEL */
177*7c478bd9Sstevel@tonic-gate };
178*7c478bd9Sstevel@tonic-gate static char blank = ' ';
179*7c478bd9Sstevel@tonic-gate static char plot = '#';
180*7c478bd9Sstevel@tonic-gate static int  msk = 0100; /* ? */
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate static void banner(char *s, struct bann *bufp);
183*7c478bd9Sstevel@tonic-gate static void banfil(char *c, struct bann *p);
184*7c478bd9Sstevel@tonic-gate static void banset(char c, struct bann *p);
185*7c478bd9Sstevel@tonic-gate static void banprt(struct bann *ptr);
186*7c478bd9Sstevel@tonic-gate static char convert(unsigned char c);
187*7c478bd9Sstevel@tonic-gate 
188*7c478bd9Sstevel@tonic-gate int
main(int argc,char ** argv)189*7c478bd9Sstevel@tonic-gate main(int argc, char **argv)
190*7c478bd9Sstevel@tonic-gate {
191*7c478bd9Sstevel@tonic-gate 	int i;
192*7c478bd9Sstevel@tonic-gate 	/*
193*7c478bd9Sstevel@tonic-gate 	 * if invoked with no arguments, prints error comment
194*7c478bd9Sstevel@tonic-gate 	 * if invoked with an argument, prints it in banner form.
195*7c478bd9Sstevel@tonic-gate 	 */
196*7c478bd9Sstevel@tonic-gate 	(void) setlocale(LC_ALL, "");
197*7c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN)
198*7c478bd9Sstevel@tonic-gate #define	TEXT_DOMAIN	"SYS_TEST"
199*7c478bd9Sstevel@tonic-gate #endif
200*7c478bd9Sstevel@tonic-gate 	(void) textdomain(TEXT_DOMAIN);
201*7c478bd9Sstevel@tonic-gate 	if (argc < 2) {
202*7c478bd9Sstevel@tonic-gate 		(void) printf(gettext
203*7c478bd9Sstevel@tonic-gate 		    ("Usage: banner \"up to 10 char arg string\" . . .\n"));
204*7c478bd9Sstevel@tonic-gate 		exit(1);
205*7c478bd9Sstevel@tonic-gate 	}
206*7c478bd9Sstevel@tonic-gate 	for (i = 1; i < argc; ++i) {
207*7c478bd9Sstevel@tonic-gate 		banner(argv[i], bp);
208*7c478bd9Sstevel@tonic-gate 		banprt(bp);
209*7c478bd9Sstevel@tonic-gate 		(void) printf("\n");
210*7c478bd9Sstevel@tonic-gate 	}
211*7c478bd9Sstevel@tonic-gate 	return (0);
212*7c478bd9Sstevel@tonic-gate }
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate static void
banner(char * s,struct bann * bufp)215*7c478bd9Sstevel@tonic-gate banner(char *s, struct bann *bufp)
216*7c478bd9Sstevel@tonic-gate {
217*7c478bd9Sstevel@tonic-gate 	char *p, *q;
218*7c478bd9Sstevel@tonic-gate 	unsigned char c;
219*7c478bd9Sstevel@tonic-gate 	struct bann *r;
220*7c478bd9Sstevel@tonic-gate 	p = s;
221*7c478bd9Sstevel@tonic-gate 	r = bufp;
222*7c478bd9Sstevel@tonic-gate 	banset(blank, bufp);
223*7c478bd9Sstevel@tonic-gate 	while ((c = *s++) != 0 && ((ptrdiff_t)s-(ptrdiff_t)p) <= chpln) {
224*7c478bd9Sstevel@tonic-gate 		if ((c & 0300)) { /* 8th bit is on */
225*7c478bd9Sstevel@tonic-gate 			c = convert(c);
226*7c478bd9Sstevel@tonic-gate 		}
227*7c478bd9Sstevel@tonic-gate 		q = ctbl[c];
228*7c478bd9Sstevel@tonic-gate 		banfil(q, r);
229*7c478bd9Sstevel@tonic-gate 		r = (struct bann *)((char *)r + pospch);
230*7c478bd9Sstevel@tonic-gate 	}
231*7c478bd9Sstevel@tonic-gate }
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate static void
banfil(char * c,struct bann * p)234*7c478bd9Sstevel@tonic-gate banfil(char *c, struct bann *p)
235*7c478bd9Sstevel@tonic-gate {
236*7c478bd9Sstevel@tonic-gate 	int i, j;
237*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < nlines; i++) {
238*7c478bd9Sstevel@tonic-gate 		for (j = 0; j < pospch; j++) {
239*7c478bd9Sstevel@tonic-gate 			if (((c[i]<<j)&msk) != 0) p->alpha[i][j] = plot;
240*7c478bd9Sstevel@tonic-gate 		}
241*7c478bd9Sstevel@tonic-gate 	}
242*7c478bd9Sstevel@tonic-gate }
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate static void
banset(char c,struct bann * p)245*7c478bd9Sstevel@tonic-gate banset(char c, struct bann *p)
246*7c478bd9Sstevel@tonic-gate {
247*7c478bd9Sstevel@tonic-gate 	int i, j;
248*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < nlines; i++)
249*7c478bd9Sstevel@tonic-gate 		for (j = 0; j < pposs-1; j++)
250*7c478bd9Sstevel@tonic-gate 			p->alpha[i][j] = c;
251*7c478bd9Sstevel@tonic-gate }
252*7c478bd9Sstevel@tonic-gate 
253*7c478bd9Sstevel@tonic-gate static void
banprt(struct bann * ptr)254*7c478bd9Sstevel@tonic-gate banprt(struct bann *ptr)
255*7c478bd9Sstevel@tonic-gate {
256*7c478bd9Sstevel@tonic-gate 	int i, j;
257*7c478bd9Sstevel@tonic-gate 	for (i = 0; i < nlines; i++) {
258*7c478bd9Sstevel@tonic-gate 		ptr->alpha[i][pposs-1] = '\0';
259*7c478bd9Sstevel@tonic-gate 		for (j = pposs-2; j >= 0; j--) {
260*7c478bd9Sstevel@tonic-gate 			if (ptr->alpha[i][j] != blank)break;
261*7c478bd9Sstevel@tonic-gate 			ptr->alpha[i][j] = '\0';
262*7c478bd9Sstevel@tonic-gate 		}
263*7c478bd9Sstevel@tonic-gate 		(void) printf("%s\n", ptr->alpha[i]);
264*7c478bd9Sstevel@tonic-gate 	}
265*7c478bd9Sstevel@tonic-gate }
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate static char
convert(unsigned char c)268*7c478bd9Sstevel@tonic-gate convert(unsigned char c)
269*7c478bd9Sstevel@tonic-gate {
270*7c478bd9Sstevel@tonic-gate 	if (c >= 0xc0 && c <= 0xc6)
271*7c478bd9Sstevel@tonic-gate 		return ('A');
272*7c478bd9Sstevel@tonic-gate 	if (c >= 0xc8 && c <= 0xcb)
273*7c478bd9Sstevel@tonic-gate 		return ('E');
274*7c478bd9Sstevel@tonic-gate 	if (c == 0xc7)
275*7c478bd9Sstevel@tonic-gate 		return ('C');
276*7c478bd9Sstevel@tonic-gate 	if (c >= 0xcc && c <= 0xcf)
277*7c478bd9Sstevel@tonic-gate 		return ('I');
278*7c478bd9Sstevel@tonic-gate 	if (c == 0xd0)
279*7c478bd9Sstevel@tonic-gate 		return ('D');
280*7c478bd9Sstevel@tonic-gate 	if (c == 0xd1)
281*7c478bd9Sstevel@tonic-gate 		return ('N');
282*7c478bd9Sstevel@tonic-gate 	if (c >= 0xd2 && c <= 0xd6)
283*7c478bd9Sstevel@tonic-gate 		return ('O');
284*7c478bd9Sstevel@tonic-gate 	if (c == 0xd7)
285*7c478bd9Sstevel@tonic-gate 		return ('X');
286*7c478bd9Sstevel@tonic-gate 	if (c == 0xd8)
287*7c478bd9Sstevel@tonic-gate 		return ('O');
288*7c478bd9Sstevel@tonic-gate 	if (c >= 0xd9 && c <= 0xdc)
289*7c478bd9Sstevel@tonic-gate 		return ('U');
290*7c478bd9Sstevel@tonic-gate 	if (c == 0xdd)
291*7c478bd9Sstevel@tonic-gate 		return ('Y');
292*7c478bd9Sstevel@tonic-gate 	if (c == 0xde)
293*7c478bd9Sstevel@tonic-gate 		return ('P');
294*7c478bd9Sstevel@tonic-gate 	if (c == 0xdf)
295*7c478bd9Sstevel@tonic-gate 		return ('B');
296*7c478bd9Sstevel@tonic-gate 	if (c >= 0xe0 && c <= 0xe6)
297*7c478bd9Sstevel@tonic-gate 		return ('a');
298*7c478bd9Sstevel@tonic-gate 	if (c == 0xe7)
299*7c478bd9Sstevel@tonic-gate 		return ('c');
300*7c478bd9Sstevel@tonic-gate 	if (c >= 0xe8 && c <= 0xeb)
301*7c478bd9Sstevel@tonic-gate 		return ('e');
302*7c478bd9Sstevel@tonic-gate 	if (c >= 0xec && c <= 0xef)
303*7c478bd9Sstevel@tonic-gate 		return ('i');
304*7c478bd9Sstevel@tonic-gate 	if (c == 0xf0)
305*7c478bd9Sstevel@tonic-gate 		return ('d');
306*7c478bd9Sstevel@tonic-gate 	if (c == 0xf1)
307*7c478bd9Sstevel@tonic-gate 		return ('n');
308*7c478bd9Sstevel@tonic-gate 	if (c >= 0xf2 && c <= 0xf6)
309*7c478bd9Sstevel@tonic-gate 		return ('o');
310*7c478bd9Sstevel@tonic-gate 	if (c >= 0xf9 && c <= 0xfc)
311*7c478bd9Sstevel@tonic-gate 		return ('u');
312*7c478bd9Sstevel@tonic-gate 	if (c == 0xfd)
313*7c478bd9Sstevel@tonic-gate 		return ('y');
314*7c478bd9Sstevel@tonic-gate 	if (c == 0xfe)
315*7c478bd9Sstevel@tonic-gate 		return ('p');
316*7c478bd9Sstevel@tonic-gate 	if (c == 0xff)
317*7c478bd9Sstevel@tonic-gate 		return ('y');
318*7c478bd9Sstevel@tonic-gate 	return (c & 0177);
319*7c478bd9Sstevel@tonic-gate }
320