-/* $NetBSD: io.c,v 1.23 2009/07/13 19:05:40 roy Exp $ */
+/* $NetBSD: io.c,v 1.26 2011/05/23 22:48:52 joerg Exp $ */
/*-
* Copyright (c) 1980, 1993
#if 0
static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: io.c,v 1.23 2009/07/13 19:05:40 roy Exp $");
+__RCSID("$NetBSD: io.c,v 1.26 2011/05/23 22:48:52 joerg Exp $");
#endif
#endif /* not lint */
#endif
#define CTRL(X) (X - 'A' + 1)
-char linebuf[LINESIZE];
+static int msgcrd(CARD, BOOLEAN, const char *, BOOLEAN);
+static void printcard(WINDOW *, int, CARD, BOOLEAN);
+static int incard(CARD *);
+static void wait_for(int);
+static int readchar(void);
-const char *const rankname[RANKS] = {
+static char linebuf[LINESIZE];
+
+static const char *const rankname[RANKS] = {
"ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN",
"EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING"
};
-const char *const rankchar[RANKS] = {
+static const char *const rankchar[RANKS] = {
"A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K"
};
-const char *const suitname[SUITS] = {"SPADES", "HEARTS", "DIAMONDS", "CLUBS"};
+static const char *const suitname[SUITS] = {
+ "SPADES", "HEARTS", "DIAMONDS", "CLUBS"
+};
-const char *const suitchar[SUITS] = {"S", "H", "D", "C"};
+static const char *const suitchar[SUITS] = {"S", "H", "D", "C"};
/*
* msgcard:
* Call msgcrd in one of two forms
*/
int
-msgcard(c, brief)
- CARD c;
- BOOLEAN brief;
+msgcard(CARD c, BOOLEAN brief)
{
if (brief)
return (msgcrd(c, TRUE, NULL, TRUE));
* msgcrd:
* Print the value of a card in ascii
*/
-int
+static int
msgcrd(CARD c, BOOLEAN brfrank, const char *mid, BOOLEAN brfsuit)
{
if (c.rank == EMPTY || c.suit == EMPTY)
if (brfrank)
addmsg("%1.1s", rankchar[c.rank]);
else
- addmsg(rankname[c.rank]);
+ addmsg("%s", rankname[c.rank]);
if (mid != NULL)
- addmsg(mid);
+ addmsg("%s", mid);
if (brfsuit)
addmsg("%1.1s", suitchar[c.suit]);
else
- addmsg(suitname[c.suit]);
+ addmsg("%s", suitname[c.suit]);
return (TRUE);
}
* printcard:
* Print out a card.
*/
-void
+static void
printcard(WINDOW *win, int cardno, CARD c, BOOLEAN blank)
{
prcard(win, cardno * 2, cardno, c, blank);
exit(74);
}
for (;;) {
- msg(prompt);
+ msg("%s", prompt);
if (incard(&crd)) { /* if card is full card */
if (!is_one(crd, hand, n))
msg("That's not in your hand");
* Inputs a card in any format. It reads a line ending with a CR
* and then parses it.
*/
-int
+static int
incard(CARD *crd)
{
int i;
int sum;
for (sum = 0;;) {
- msg(prompt);
+ msg("%s", prompt);
if (!(p = get_line()) || *p == '\0') {
msg(quiet ? "Not a number" :
"That doesn't look like a number");
* msg:
* Display a message at the top of the screen.
*/
-char Msgbuf[BUFSIZ] = {'\0'};
-int Mpos = 0;
+static char Msgbuf[BUFSIZ] = {'\0'};
+static int Mpos = 0;
static int Newpos = 0;
void
* endmsg:
* Display a new msg.
*/
-int Lineno = 0;
+static int Lineno = 0;
void
endmsg(void)
* wait_for
* Sit around until the guy types the right key
*/
-void
+static void
wait_for(int ch)
{
int c;
* readchar:
* Reads and returns a character, checking for gross input errors
*/
-int
+static int
readchar(void)
{
int cnt;