X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/462fca95471224f85b85be911e72faee16cd1597..c04c86951e9b1e852ef67779de06e401fadae0b8:/banner/banner.c diff --git a/banner/banner.c b/banner/banner.c index da69d315..9497c6f2 100644 --- a/banner/banner.c +++ b/banner/banner.c @@ -1,6 +1,8 @@ +/* $NetBSD: banner.c,v 1.10 1999/07/19 19:07:17 hubertf Exp $ */ + /* - * Copyright (c) 1980 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1980, 1993, 1994 + * 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 @@ -31,23 +33,30 @@ * SUCH DAMAGE. */ +#include #ifndef lint -char copyright[] = -"@(#) Copyright (c) 1980 The Regents of the University of California.\n\ - 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 -/*static char sccsid[] = "from: @(#)banner.c 4.3 (Berkeley) 6/1/90";*/ -static char rcsid[] = "$Id: banner.c,v 1.2 1993/08/01 18:56:19 mycroft Exp $"; +#if 0 +static char sccsid[] = "@(#)banner.c 8.4 (Berkeley) 4/29/95"; +#else +__RCSID("$NetBSD: banner.c,v 1.10 1999/07/19 19:07:17 hubertf Exp $"); +#endif #endif /* not lint */ /* * banner - prints large signs - * banner [-w#] [-d] [-t] message ... + * banner [-w width] [-d] [-t] message ... */ +#include #include +#include +#include +#include #define MAXMSG 1024 #define DWIDTH 132 @@ -55,7 +64,7 @@ static char rcsid[] = "$Id: banner.c,v 1.2 1993/08/01 18:56:19 mycroft Exp $"; #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, @@ -82,7 +91,7 @@ int asc_ptr[NCHARS] = { * 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, @@ -1014,74 +1023,48 @@ char data_table[NBYTES] = { /* 9270 */ 193 }; -int i,j; -int width = DWIDTH; /* -w option: scrunch letters to 80 columns */ -int debug; -int trace; -char line[DWIDTH]; -char print[DWIDTH]; -char message[MAXMSG]; -int nchars; -int linen; -int x,y; -int term; -int pc; -int max; +char line[DWIDTH]; +char message[MAXMSG]; +char print[DWIDTH]; +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[]; { - extern char *optarg; - extern int optind; int ch; - char *strcpy(), *strcat(); - while ((ch = getopt(argc, argv, "w:td")) != EOF) - switch((char)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; argv += optind; - for (i=0; i= NCHARS || + asc_ptr[(u_char) message[i]] == 0) { + warnx("The character '%c' is not in my character set", + message[i]); j++; } - if (j) exit(1); + if (j) + exit(1); if (trace) printf("Message '%s' is OK\n",message); /* Now have message. Print it one character at a time. */ - for (i=0; i NBYTES) { + while (!term) { + if (pc < 0 || pc > NBYTES) { printf("bad pc: %d\n",pc); exit(1); } @@ -1154,13 +1141,13 @@ main(argc, argv) x = x & 63; while (x--) { if (print[linen++]) { - for (j=0; j<=max; j++) + for (j=0; j <= max; j++) if (print[j]) putchar(line[j]); putchar('\n'); } } - for (j=0; j