summaryrefslogtreecommitdiffstats
path: root/canfield
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>1997-10-10 12:26:34 +0000
committerlukem <lukem@NetBSD.org>1997-10-10 12:26:34 +0000
commit4af35eddcd99b72236d11e2354dd8fcd3b9f6e74 (patch)
treeb5301debb2cb032e91d96ad619385e02f97382bb /canfield
parent952db1ec53b2365d68d84970049975065cd884f5 (diff)
downloadbsdgames-darwin-4af35eddcd99b72236d11e2354dd8fcd3b9f6e74.tar.gz
bsdgames-darwin-4af35eddcd99b72236d11e2354dd8fcd3b9f6e74.tar.zst
bsdgames-darwin-4af35eddcd99b72236d11e2354dd8fcd3b9f6e74.zip
WARNSify
Diffstat (limited to 'canfield')
-rw-r--r--canfield/canfield/canfield.66
-rw-r--r--canfield/canfield/canfield.c145
-rw-r--r--canfield/cfscores/cfscores.c40
3 files changed, 152 insertions, 39 deletions
diff --git a/canfield/canfield/canfield.6 b/canfield/canfield/canfield.6
index 17b34ae3..f1d6bc45 100644
--- a/canfield/canfield/canfield.6
+++ b/canfield/canfield/canfield.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: canfield.6,v 1.4 1995/03/21 15:08:30 cgd Exp $
+.\" $NetBSD: canfield.6,v 1.5 1997/10/10 12:26:34 lukem Exp $
.\"
.\" Copyright (c) 1983, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -41,7 +41,7 @@
.Nm cfscores
.Nd the solitaire card game canfield
.Sh SYNOPSIS
-.Nm canfield
+.Nm
.Nm cfscores
.Op Fl a
.Op Ar user
@@ -71,7 +71,7 @@ available.
The command
.Sq Ic c
causes
-.Nm canfield
+.Nm
to maintain card counting statistics
on the bottom of the screen.
When properly used this can greatly increase one's chances of
diff --git a/canfield/canfield/canfield.c b/canfield/canfield/canfield.c
index 406b698d..0f684d39 100644
--- a/canfield/canfield/canfield.c
+++ b/canfield/canfield/canfield.c
@@ -1,4 +1,4 @@
-/* $NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $ */
+/* $NetBSD: canfield.c,v 1.8 1997/10/10 12:26:39 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,17 +33,17 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1980, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)canfield.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $";
+__RCSID("$NetBSD: canfield.c,v 1.8 1997/10/10 12:26:39 lukem Exp $");
#endif
#endif /* not lint */
@@ -60,12 +60,15 @@ static char rcsid[] = "$NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $";
#include <sys/types.h>
-#include <curses.h>
-#include <termios.h>
#include <ctype.h>
+#include <curses.h>
+#include <fcntl.h>
#include <signal.h>
+#include <stdlib.h>
#include <string.h>
#include <termios.h>
+#include <termios.h>
+#include <unistd.h>
#include "pathnames.h"
@@ -199,6 +202,54 @@ bool startedgame = FALSE, infullgame = FALSE;
time_t acctstart;
int dbfd = -1;
+void askquit __P((int));
+void cleanup __P((int));
+void cleanupboard __P((void));
+void clearabovemovebox __P((void));
+void clearbelowmovebox __P((void));
+void clearmsg __P((void));
+void clearstat __P((void));
+void destinerror __P((void));
+bool diffcolor __P((struct cardtype *, struct cardtype *));
+void dumberror __P((void));
+bool finish __P((void));
+void fndbase __P((struct cardtype **, int, int));
+void getcmd __P((int, int, char *));
+void initall __P((void));
+void initdeck __P((struct cardtype *[]));
+void initgame __P((void));
+void instruct __P((void));
+int main __P((int, char *[]));
+void makeboard __P((void));
+void movebox __P((void));
+void movecard __P((void));
+void movetofound __P((struct cardtype **, int));
+void movetotalon __P((void));
+bool notempty __P((struct cardtype *));
+void printbottombettingbox __P((void));
+void printbottominstructions __P((void));
+void printcard __P((int, int, struct cardtype *));
+void printrank __P((int, int, struct cardtype *, bool));
+void printtopbettingbox __P((void));
+void printtopinstructions __P((void));
+bool rankhigher __P((struct cardtype *, int));
+bool ranklower __P((struct cardtype *, struct cardtype *));
+void removecard __P((int, int));
+int samesuit __P((struct cardtype *, int));
+void showcards __P((void));
+void showstat __P((void));
+void shuffle __P((struct cardtype *[]));
+void simpletableau __P((struct cardtype **, int));
+void startgame __P((void));
+void suspend __P((void));
+bool tabok __P((struct cardtype *, int));
+void tabprint __P((int, int));
+void tabtotab __P((int, int));
+void transit __P((struct cardtype **, struct cardtype **));
+void updatebettinginfo __P((void));
+void usedstock __P((void));
+void usedtalon __P((void));
+
/*
* The following procedures print the board onto the screen using the
* addressible cursor. The end of these procedures will also be
@@ -206,6 +257,7 @@ int dbfd = -1;
*
* procedure to set the move command box
*/
+void
movebox()
{
switch (status) {
@@ -240,6 +292,7 @@ movebox()
/*
* print directions above move box
*/
+void
printtopinstructions()
{
move(tboxrow, boxcol);
@@ -273,6 +326,7 @@ printtopinstructions()
/*
* Print the betting box.
*/
+void
printtopbettingbox()
{
@@ -307,6 +361,7 @@ printtopbettingbox()
/*
* clear info above move box
*/
+void
clearabovemovebox()
{
int i;
@@ -322,6 +377,7 @@ clearabovemovebox()
/*
* print instructions below move box
*/
+void
printbottominstructions()
{
move(bboxrow, boxcol);
@@ -335,6 +391,7 @@ printbottominstructions()
/*
* print betting information below move box
*/
+void
printbottombettingbox()
{
move(bboxrow, boxcol);
@@ -348,6 +405,7 @@ printbottombettingbox()
/*
* clear info below move box
*/
+void
clearbelowmovebox()
{
int i;
@@ -363,6 +421,7 @@ clearbelowmovebox()
/*
* procedure to put the board on the screen using addressable cursor
*/
+void
makeboard()
{
clear();
@@ -401,11 +460,13 @@ makeboard()
/*
* clean up the board for another game
*/
+void
cleanupboard()
{
int cnt, row, col;
struct cardtype *ptr;
+ col = 0;
if (Cflag) {
clearstat();
for(ptr = stock, row = stockrow;
@@ -456,6 +517,7 @@ cleanupboard()
/*
* procedure to create a deck of cards
*/
+void
initdeck(deck)
struct cardtype *deck[];
{
@@ -481,6 +543,7 @@ initdeck(deck)
/*
* procedure to shuffle the deck
*/
+void
shuffle(deck)
struct cardtype *deck[];
{
@@ -504,7 +567,9 @@ shuffle(deck)
/*
* procedure to remove the card from the board
*/
+void
removecard(a, b)
+ int a, b;
{
move(b, a);
printw(" ");
@@ -513,7 +578,9 @@ removecard(a, b)
/*
* procedure to print the cards on the board
*/
+void
printrank(a, b, cp, inverse)
+ int a, b;
struct cardtype *cp;
bool inverse;
{
@@ -546,6 +613,7 @@ printrank(a, b, cp, inverse)
/*
* procedure to print out a card
*/
+void
printcard(a, b, cp)
int a,b;
struct cardtype *cp;
@@ -572,6 +640,7 @@ printcard(a, b, cp)
* of another location. The pointers always point to the top
* of the piles.
*/
+void
transit(source, dest)
struct cardtype **source, **dest;
{
@@ -588,8 +657,10 @@ transit(source, dest)
* Note that it is only called on a foundation pile at the beginning of
* the game, so the pile will have exactly one card in it.
*/
+void
fndbase(cp, column, row)
struct cardtype **cp;
+ int column, row;
{
bool nomore;
@@ -632,9 +703,10 @@ fndbase(cp, column, row)
/*
* procedure to initialize the things necessary for the game
*/
+void
initgame()
{
- register i;
+ int i;
for (i=0; i<18; i++) {
deck[i]->visible = TRUE;
@@ -677,9 +749,10 @@ initgame()
/*
* procedure to print the beginning cards and to start each game
*/
+void
startgame()
{
- register int j;
+ int j;
shuffle(deck);
initgame();
@@ -717,6 +790,7 @@ startgame()
/*
* procedure to clear the message printed from an error
*/
+void
clearmsg()
{
int i;
@@ -733,6 +807,7 @@ clearmsg()
/*
* procedure to print an error message if the move is not listed
*/
+void
dumberror()
{
errmsg = TRUE;
@@ -743,6 +818,7 @@ dumberror()
/*
* procedure to print an error message if the move is not possible
*/
+void
destinerror()
{
errmsg = TRUE;
@@ -755,7 +831,7 @@ destinerror()
*/
bool
notempty(cp)
-struct cardtype *cp;
+ struct cardtype *cp;
{
if (cp == NIL) {
errmsg = TRUE;
@@ -803,6 +879,7 @@ diffcolor(cp1, cp2)
bool
tabok(cp, des)
struct cardtype *cp;
+ int des;
{
if ((cp == stock) && (tableau[des] == NIL))
return (TRUE);
@@ -822,6 +899,7 @@ tabok(cp, des)
/*
* procedure to turn the cards onto the talon from the deck
*/
+void
movetotalon()
{
int i, fin;
@@ -906,10 +984,12 @@ movetotalon()
/*
* procedure to print card counting info on screen
*/
+
+void
showstat()
{
int row, col;
- register struct cardtype *ptr;
+ struct cardtype *ptr;
if (!Cflag)
return;
@@ -948,6 +1028,7 @@ showstat()
/*
* procedure to clear card counting info from screen
*/
+void
clearstat()
{
int row;
@@ -967,6 +1048,7 @@ clearstat()
/*
* procedure to update card counting base
*/
+void
usedtalon()
{
removecard(coldcol, coldrow);
@@ -991,6 +1073,7 @@ usedtalon()
/*
* procedure to update stock card counting base
*/
+void
usedstock()
{
stockcnt--;
@@ -1003,9 +1086,10 @@ usedstock()
/*
* let 'em know how they lost!
*/
+void
showcards()
{
- register struct cardtype *ptr;
+ struct cardtype *ptr;
int row;
if (!Cflag || cardsoff == 52)
@@ -1050,12 +1134,13 @@ showcards()
/*
* procedure to update the betting values
*/
+void
updatebettinginfo()
{
long thiscosts, gamecosts, totalcosts;
double thisreturn, gamereturn, totalreturn;
time_t now;
- register long dollars;
+ long dollars;
time(&now);
dollars = (now - acctstart) / secondsperdollar;
@@ -1107,8 +1192,10 @@ updatebettinginfo()
/*
* procedure to move a card from the stock or talon to the tableau
*/
+void
simpletableau(cp, des)
-struct cardtype **cp;
+ struct cardtype **cp;
+ int des;
{
int origin;
@@ -1139,7 +1226,9 @@ struct cardtype **cp;
/*
* print the tableau
*/
+void
tabprint(sour, des)
+ int sour, des;
{
int dlength, slength, i;
struct cardtype *tempcard;
@@ -1164,8 +1253,9 @@ tabprint(sour, des)
/*
* procedure to move from the tableau to the tableau
*/
+void
tabtotab(sour, des)
- register int sour, des;
+ int sour, des;
{
struct cardtype *temp;
@@ -1193,6 +1283,7 @@ tabtotab(sour, des)
bool
rankhigher(cp, let)
struct cardtype *cp;
+ int let;
{
if (found[let]->rank == King)
if (cp->rank == Ace)
@@ -1208,8 +1299,10 @@ rankhigher(cp, let)
/*
* function to determine if two cards are the same suit
*/
+int
samesuit(cp, let)
struct cardtype *cp;
+ int let;
{
if (cp->suit == found[let]->suit)
return (TRUE);
@@ -1220,8 +1313,10 @@ samesuit(cp, let)
/*
* procedure to move a card to the correct foundation pile
*/
+void
movetofound(cp, source)
struct cardtype **cp;
+ int source;
{
tempbase = 0;
mtfdone = FALSE;
@@ -1270,6 +1365,7 @@ movetofound(cp, source)
/*
* procedure to get a command
*/
+void
getcmd(row, col, cp)
int row, col;
char *cp;
@@ -1320,6 +1416,7 @@ getcmd(row, col, cp)
/*
* Suspend the game (shell escape if no process control on system)
*/
+void
suspend()
{
#ifndef SIGTSTP
@@ -1341,11 +1438,13 @@ suspend()
/*
* procedure to evaluate and make the specific moves
*/
+void
movecard()
{
int source, dest;
char osrcpile, odestpile;
+ source = dest = 0;
done = FALSE;
errmsg = FALSE;
do {
@@ -1536,9 +1635,10 @@ char *bettinginstructions[] = {
/*
* procedure to printout instructions
*/
+void
instruct()
{
- register char **cp;
+ char **cp;
move(originrow, origincol);
printw("This is the game of solitaire called Canfield. Do\n");
@@ -1571,6 +1671,7 @@ instruct()
/*
* procedure to initialize the game
*/
+void
initall()
{
int i;
@@ -1640,7 +1741,8 @@ finish()
* procedure to clean up and exit
*/
void
-cleanup()
+cleanup(dummy)
+ int dummy;
{
total.thinktime += 1;
@@ -1663,7 +1765,8 @@ cleanup()
* Field an interrupt.
*/
void
-askquit()
+askquit(dummy)
+ int dummy;
{
move(msgrow, msgcol);
printw("Really wish to quit? ");
@@ -1672,13 +1775,14 @@ askquit()
} while (srcpile != 'y' && srcpile != 'n');
clearmsg();
if (srcpile == 'y')
- cleanup();
+ cleanup(0);
signal(SIGINT, askquit);
}
/*
* Can you tell that this used to be a Pascal program?
*/
+int
main(argc, argv)
int argc;
char *argv[];
@@ -1711,6 +1815,7 @@ main(argc, argv)
else
cleanupboard();
}
- cleanup();
+ cleanup(0);
/* NOTREACHED */
+ return(0);
}
diff --git a/canfield/cfscores/cfscores.c b/canfield/cfscores/cfscores.c
index 4a3a0e8f..90988cdb 100644
--- a/canfield/cfscores/cfscores.c
+++ b/canfield/cfscores/cfscores.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cfscores.c,v 1.3 1995/03/21 15:08:37 cgd Exp $ */
+/* $NetBSD: cfscores.c,v 1.4 1997/10/10 12:26:44 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -33,22 +33,25 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)cfscores.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: cfscores.c,v 1.3 1995/03/21 15:08:37 cgd Exp $";
+__RCSID("$NetBSD: cfscores.c,v 1.4 1997/10/10 12:26:44 lukem Exp $");
#endif
#endif /* not lint */
#include <sys/types.h>
+#include <fcntl.h>
#include <pwd.h>
+#include <stdio.h>
+#include <unistd.h>
#include "pathnames.h"
struct betinfo {
@@ -64,11 +67,15 @@ struct betinfo {
int dbfd;
+int main __P((int, char *[]));
+void printuser __P((struct passwd *, int));
+
+int
main(argc, argv)
int argc;
char *argv[];
{
- register struct passwd *pw;
+ struct passwd *pw;
int uid;
if (argc > 2) {
@@ -108,8 +115,9 @@ main(argc, argv)
/*
* print out info for specified password entry
*/
+void
printuser(pw, printfail)
- register struct passwd *pw;
+ struct passwd *pw;
int printfail;
{
struct betinfo total;
@@ -141,14 +149,14 @@ printuser(pw, printfail)
printf("* Losses for %-10s*\n", pw->pw_name);
printf("*======================*\n");
printf("|Costs Total |\n");
- printf("| Hands %8d |\n", total.hand);
- printf("| Inspections %8d |\n", total.inspection);
- printf("| Games %8d |\n", total.game);
- printf("| Runs %8d |\n", total.runs);
- printf("| Information %8d |\n", total.information);
- printf("| Think time %8d |\n", total.thinktime);
- printf("|Total Costs %8d |\n", total.wins - total.worth);
- printf("|Winnings %8d |\n", total.wins);
- printf("|Net Worth %8d |\n", total.worth);
+ printf("| Hands %8ld |\n", total.hand);
+ printf("| Inspections %8ld |\n", total.inspection);
+ printf("| Games %8ld |\n", total.game);
+ printf("| Runs %8ld |\n", total.runs);
+ printf("| Information %8ld |\n", total.information);
+ printf("| Think time %8ld |\n", total.thinktime);
+ printf("|Total Costs %8ld |\n", total.wins - total.worth);
+ printf("|Winnings %8ld |\n", total.wins);
+ printf("|Net Worth %8ld |\n", total.worth);
printf("*----------------------*\n\n");
}