-/* $NetBSD: banner.c,v 1.3 1995/03/25 07:44:49 glass Exp $ */
+/* $NetBSD: banner.c,v 1.8 1998/09/14 09:30:57 hubertf Exp $ */
/*
* Copyright (c) 1980, 1993, 1994
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1980, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993, 1994\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
-static char sccsid[] = "@(#)banner.c 8.3 (Berkeley) 4/2/94";
+static char sccsid[] = "@(#)banner.c 8.4 (Berkeley) 4/29/95";
#else
-static char rcsid[] = "$NetBSD: banner.c,v 1.3 1995/03/25 07:44:49 glass Exp $";
+__RCSID("$NetBSD: banner.c,v 1.8 1998/09/14 09:30:57 hubertf Exp $");
#endif
#endif /* not lint */
/*
* banner - prints large signs
- * banner [-w#] [-d] [-t] message ...
+ * banner [-w width] [-d] [-t] message ...
*/
#include <err.h>
#define NBYTES 9271
/* Pointers into data_table for each ASCII char */
-int asc_ptr[NCHARS] = {
+const int asc_ptr[NCHARS] = {
/* ^@ */ 0, 0, 0, 0, 0, 0, 0, 0,
/* ^H */ 0, 0, 0, 0, 0, 0, 0, 0,
/* ^P */ 0, 0, 0, 0, 0, 0, 0, 0,
* is the next elt in array) and goto second
* next element in array.
*/
-char data_table[NBYTES] = {
+const char data_table[NBYTES] = {
/* 0 1 2 3 4 5 6 7 8 9 */
/* 0 */ 129, 227, 130, 34, 6, 90, 19, 129, 32, 10,
/* 10 */ 74, 40, 129, 31, 12, 64, 53, 129, 30, 14,
int debug, i, j, linen, max, nchars, pc, term, trace, x, y;
int width = DWIDTH; /* -w option: scrunch letters to 80 columns */
+
+int main __P((int, char *[]));
+
int
main(argc, argv)
int argc;
- char **argv;
+ char *argv[];
{
int ch;
- while ((ch = getopt(argc, argv, "w:td")) != EOF)
- switch(ch) {
- case 'w':
- width = atoi(optarg);
- if (width <= 0)
- width = 80;
- break;
+ while ((ch = getopt(argc, argv, "w:td")) != -1)
+ switch (ch) {
case 'd':
debug = 1;
break;
case 't':
trace = 1;
break;
+ case 'w':
+ width = atoi(optarg);
+ if (width <= 0)
+ errx(1, "illegal argument for -w option");
+ break;
case '?':
default:
- fprintf(stderr, "usage: banner [-w width]\n");
+ (void)fprintf(stderr, "usage: banner [-w width]\n");
exit(1);
}
argc -= optind;
}
nchars = strlen(message);
} else {
- fprintf(stderr,"Message: ");
+ if (isatty(fileno(stdin)))
+ fprintf(stderr,"Message: ");
(void)fgets(message, sizeof(message), stdin);
nchars = strlen(message);
message[nchars--] = '\0'; /* get rid of newline */