X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/5ff78ede5ea1a80c654d3f0684cd5f36d5253ae1..5091acb41289c711cd19e004627df9d31a1b8b1f:/bcd/bcd.c?ds=sidebyside diff --git a/bcd/bcd.c b/bcd/bcd.c index ea554a34..6cc595a0 100644 --- a/bcd/bcd.c +++ b/bcd/bcd.c @@ -1,4 +1,4 @@ -/* $NetBSD: bcd.c,v 1.5 1995/03/21 15:08:15 cgd Exp $ */ +/* $NetBSD: bcd.c,v 1.11 2000/07/03 03:57:40 matt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -36,14 +36,18 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1989, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94"; +#else +__RCSID("$NetBSD: bcd.c,v 1.11 2000/07/03 03:57:40 matt Exp $"); +#endif #endif /* not lint */ /* @@ -79,9 +83,12 @@ static char sccsid[] = "@(#)bcd.c 8.2 (Berkeley) 3/20/94"; #include #include +#include +#include #include +#include -u_short holes[256] = { +const u_short holes[256] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -121,6 +128,9 @@ u_short holes[256] = { */ #define bit(w,i) ((w)&(1<<(i))) +int main __P((int, char *[])); +void printcard __P((char *)); + int main(argc, argv) int argc; @@ -128,6 +138,9 @@ main(argc, argv) { char cardline[80]; + /* revoke setgid privileges */ + setgid(getgid()); + /* * The original bcd prompts with a "%" when reading from stdin, * but this seems kind of silly. So this one doesn't. @@ -144,16 +157,16 @@ main(argc, argv) #define COLUMNS 48 +void printcard(str) - register char *str; + char *str; { - static char rowchars[] = " 123456789"; - register int i, row; - register char *p; - char *index(); + static const char rowchars[] = " 123456789"; + int i, row; + unsigned char *p; /* ruthlessly remove newlines and truncate at 48 characters. */ - if ((p = index(str, '\n'))) + if ((p = strchr(str, '\n'))) *p = '\0'; if (strlen(str) > COLUMNS) @@ -177,7 +190,7 @@ printcard(str) p = str; putchar('/'); for (i = 1; *p; i++, p++) - if (holes[*p]) + if (holes[(int)*p]) putchar(*p); else putchar(' '); @@ -195,7 +208,7 @@ printcard(str) for (row = 0; row <= 11; ++row) { putchar('|'); for (i = 0, p = str; *p; i++, p++) { - if (bit(holes[*p], 11 - row)) + if (bit(holes[(int)*p], 11 - row)) putchar(']'); else putchar(rowchars[row]);