summaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>2000-07-23 21:49:08 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>2000-07-23 21:49:08 +0000
commit02987a4b80b90523e231e88ea50eec97b413715f (patch)
tree0c1e8ebc25501cf1861a289a53eac63982b7e7c1 /games
parentbb6ee9445b49236cf0f512084eb9cfb7c27b91fe (diff)
Code cleanups (some from NetBSD), typo fix.
Don't barf if stdin hits EOF. Install cfscores in /var/games if one isn't already there.
Diffstat (limited to 'games')
-rw-r--r--games/canfield/canfield/Makefile7
-rw-r--r--games/canfield/canfield/canfield.c235
-rw-r--r--games/canfield/canfield/pathnames.h1
-rw-r--r--games/canfield/cfscores/Makefile2
-rw-r--r--games/canfield/cfscores/cfscores.c42
5 files changed, 200 insertions, 87 deletions
diff --git a/games/canfield/canfield/Makefile b/games/canfield/canfield/Makefile
index 8ff3b425c55..e1d6acfa4ee 100644
--- a/games/canfield/canfield/Makefile
+++ b/games/canfield/canfield/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5 1995/03/21 15:08:28 cgd Exp $
+# $OpenBSD: Makefile,v 1.5 2000/07/23 21:49:03 pjanzen Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= canfield
@@ -8,6 +8,11 @@ LDADD= -lcurses
HIDEGAME=hidegame
MLINKS= canfield.6 cfscores.6
+beforeinstall:
+ @if [ ! -f ${DESTDIR}/var/games/cfscores ]; then \
+ ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 664 \
+ /dev/null ${DESTDIR}/var/games/cfscores ; \
+ fi
.include "../../Makefile.inc"
.include <bsd.prog.mk>
diff --git a/games/canfield/canfield/canfield.c b/games/canfield/canfield/canfield.c
index e8a6d18a0dd..b47d7a47070 100644
--- a/games/canfield/canfield/canfield.c
+++ b/games/canfield/canfield/canfield.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: canfield.c,v 1.5 2000/07/23 21:49:04 pjanzen Exp $ */
/* $NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $ */
/*
@@ -43,7 +44,7 @@ static char copyright[] =
#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 $";
+static char rcsid[] = "$OpenBSD: canfield.c,v 1.5 2000/07/23 21:49:04 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -67,13 +68,14 @@ static char rcsid[] = "$NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $";
#include <stdlib.h>
#include <string.h>
#include <termios.h>
+#include <time.h>
#include <unistd.h>
#include "pathnames.h"
#define decksize 52
-#define originrow 0
-#define origincol 0
+#define originrow 0
+#define origincol 0
#define basecol 1
#define boxcol 42
#define tboxrow 2
@@ -95,17 +97,17 @@ static char rcsid[] = "$NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $";
#define taloncol 2
#define talonrow 13
#define tabrow 8
-#define ctoprow 21
-#define cbotrow 23
-#define cinitcol 14
-#define cheightcol 1
-#define cwidthcol 4
-#define handstatrow 21
-#define handstatcol 7
-#define talonstatrow 22
-#define talonstatcol 7
-#define stockstatrow 23
-#define stockstatcol 7
+#define ctoprow 21
+#define cbotrow 23
+#define cinitcol 14
+#define cheightcol 1
+#define cwidthcol 4
+#define handstatrow 21
+#define handstatcol 7
+#define talonstatrow 22
+#define talonstatcol 7
+#define stockstatrow 23
+#define stockstatcol 7
#define Ace 1
#define Jack 11
#define Queen 12
@@ -122,17 +124,17 @@ static char rcsid[] = "$NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $";
#define black 'b'
#define red 'r'
-#define stk 1
+#define stk 1
#define tal 2
-#define tab 3
-#define INCRHAND(row, col) {\
+#define tab 3
+#define INCRHAND(row, col) {\
row -= cheightcol;\
if (row < ctoprow) {\
row = cbotrow;\
col += cwidthcol;\
}\
}
-#define DECRHAND(row, col) {\
+#define DECRHAND(row, col) {\
row += cheightcol;\
if (row > cbotrow) {\
row = ctoprow;\
@@ -166,23 +168,23 @@ int mtforigin, tempbase;
int coldcol, cnewcol, coldrow, cnewrow;
bool errmsg, done;
bool mtfdone, Cflag = FALSE;
-#define INSTRUCTIONBOX 1
-#define BETTINGBOX 2
-#define NOBOX 3
+#define INSTRUCTIONBOX 1
+#define BETTINGBOX 2
+#define NOBOX 3
int status = INSTRUCTIONBOX;
int uid;
/*
* Basic betting costs
*/
-#define costofhand 13
-#define costofinspection 13
-#define costofgame 26
-#define costofrunthroughhand 5
-#define costofinformation 1
-#define secondsperdollar 60
-#define maxtimecharge 3
-#define valuepercardup 5
+#define costofhand 13
+#define costofinspection 13
+#define costofgame 26
+#define costofrunthroughhand 5
+#define costofinformation 1
+#define secondsperdollar 60
+#define maxtimecharge 3
+#define valuepercardup 5
/*
* Variables associated with betting
*/
@@ -201,6 +203,53 @@ bool startedgame = FALSE, infullgame = FALSE;
time_t acctstart;
int dbfd = -1;
+void askquit __P((int));
+void cleanup __P((int)) __attribute__((__noreturn__));
+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((const struct cardtype *, const struct cardtype *));
+void dumberror __P((void));
+bool finish __P((void));
+void fndbase __P((struct cardtype **, int, int));
+void getcmd __P((int, int, const char *));
+void initall __P((void));
+void initdeck __P((struct cardtype *[]));
+void initgame __P((void));
+void instruct __P((void));
+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((const struct cardtype *));
+void printbottombettingbox __P((void));
+void printbottominstructions __P((void));
+void printcard __P((int, int, const struct cardtype *));
+void printrank __P((int, int, const struct cardtype *, bool));
+void printtopbettingbox __P((void));
+void printtopinstructions __P((void));
+bool rankhigher __P((const struct cardtype *, int));
+bool ranklower __P((const struct cardtype *, const struct cardtype *));
+void removecard __P((int, int));
+int samesuit __P((const 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((const 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
@@ -208,6 +257,7 @@ int dbfd = -1;
*
* procedure to set the move command box
*/
+void
movebox()
{
switch (status) {
@@ -242,6 +292,7 @@ movebox()
/*
* print directions above move box
*/
+void
printtopinstructions()
{
move(tboxrow, boxcol);
@@ -275,6 +326,7 @@ printtopinstructions()
/*
* Print the betting box.
*/
+void
printtopbettingbox()
{
@@ -309,6 +361,7 @@ printtopbettingbox()
/*
* clear info above move box
*/
+void
clearabovemovebox()
{
int i;
@@ -324,6 +377,7 @@ clearabovemovebox()
/*
* print instructions below move box
*/
+void
printbottominstructions()
{
move(bboxrow, boxcol);
@@ -337,6 +391,7 @@ printbottominstructions()
/*
* print betting information below move box
*/
+void
printbottombettingbox()
{
move(bboxrow, boxcol);
@@ -350,6 +405,7 @@ printbottombettingbox()
/*
* clear info below move box
*/
+void
clearbelowmovebox()
{
int i;
@@ -365,6 +421,7 @@ clearbelowmovebox()
/*
* procedure to put the board on the screen using addressable cursor
*/
+void
makeboard()
{
clear();
@@ -403,6 +460,7 @@ makeboard()
/*
* clean up the board for another game
*/
+void
cleanupboard()
{
int cnt, row, col;
@@ -458,6 +516,7 @@ cleanupboard()
/*
* procedure to create a deck of cards
*/
+void
initdeck(deck)
struct cardtype *deck[];
{
@@ -483,6 +542,7 @@ initdeck(deck)
/*
* procedure to shuffle the deck
*/
+void
shuffle(deck)
struct cardtype *deck[];
{
@@ -506,7 +566,9 @@ shuffle(deck)
/*
* procedure to remove the card from the board
*/
+void
removecard(a, b)
+ int a, b;
{
move(b, a);
printw(" ");
@@ -515,8 +577,10 @@ removecard(a, b)
/*
* procedure to print the cards on the board
*/
+void
printrank(a, b, cp, inverse)
- struct cardtype *cp;
+ int a, b;
+ const struct cardtype *cp;
bool inverse;
{
move(b, a);
@@ -548,9 +612,10 @@ printrank(a, b, cp, inverse)
/*
* procedure to print out a card
*/
+void
printcard(a, b, cp)
- int a,b;
- struct cardtype *cp;
+ int a, b;
+ const struct cardtype *cp;
{
if (cp == NIL)
removecard(a, b);
@@ -574,6 +639,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;
{
@@ -590,8 +656,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;
@@ -634,9 +702,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;
@@ -679,9 +748,10 @@ initgame()
/*
* procedure to print the beginning cards and to start each game
*/
+void
startgame()
{
- register int j;
+ int j;
shuffle(deck);
initgame();
@@ -719,6 +789,7 @@ startgame()
/*
* procedure to clear the message printed from an error
*/
+void
clearmsg()
{
int i;
@@ -735,6 +806,7 @@ clearmsg()
/*
* procedure to print an error message if the move is not listed
*/
+void
dumberror()
{
errmsg = TRUE;
@@ -745,6 +817,7 @@ dumberror()
/*
* procedure to print an error message if the move is not possible
*/
+void
destinerror()
{
errmsg = TRUE;
@@ -757,7 +830,7 @@ destinerror()
*/
bool
notempty(cp)
-struct cardtype *cp;
+ const struct cardtype *cp;
{
if (cp == NIL) {
errmsg = TRUE;
@@ -773,7 +846,7 @@ struct cardtype *cp;
*/
bool
ranklower(cp1, cp2)
- struct cardtype *cp1, *cp2;
+ const struct cardtype *cp1, *cp2;
{
if (cp2->rank == Ace)
if (cp1->rank == King)
@@ -791,7 +864,7 @@ ranklower(cp1, cp2)
*/
bool
diffcolor(cp1, cp2)
- struct cardtype *cp1, *cp2;
+ const struct cardtype *cp1, *cp2;
{
if (cp1->color == cp2->color)
return (FALSE);
@@ -804,7 +877,8 @@ diffcolor(cp1, cp2)
*/
bool
tabok(cp, des)
- struct cardtype *cp;
+ const struct cardtype *cp;
+ int des;
{
if ((cp == stock) && (tableau[des] == NIL))
return (TRUE);
@@ -824,6 +898,7 @@ tabok(cp, des)
/*
* procedure to turn the cards onto the talon from the deck
*/
+void
movetotalon()
{
int i, fin;
@@ -908,10 +983,11 @@ movetotalon()
/*
* procedure to print card counting info on screen
*/
+void
showstat()
{
int row, col;
- register struct cardtype *ptr;
+ struct cardtype *ptr;
if (!Cflag)
return;
@@ -950,6 +1026,7 @@ showstat()
/*
* procedure to clear card counting info from screen
*/
+void
clearstat()
{
int row;
@@ -969,6 +1046,7 @@ clearstat()
/*
* procedure to update card counting base
*/
+void
usedtalon()
{
removecard(coldcol, coldrow);
@@ -993,6 +1071,7 @@ usedtalon()
/*
* procedure to update stock card counting base
*/
+void
usedstock()
{
stockcnt--;
@@ -1005,9 +1084,10 @@ usedstock()
/*
* let 'em know how they lost!
*/
+void
showcards()
{
- register struct cardtype *ptr;
+ struct cardtype *ptr;
int row;
if (!Cflag || cardsoff == 52)
@@ -1052,12 +1132,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;
@@ -1084,24 +1165,25 @@ updatebettinginfo()
if (status != BETTINGBOX)
return;
move(tboxrow + 2, boxcol + 13);
- printw("%4d%8d%9d", this.hand, game.hand, total.hand);
+ printw("%4ld%8ld%9ld", this.hand, game.hand, total.hand);
move(tboxrow + 3, boxcol + 13);
- printw("%4d%8d%9d", this.inspection, game.inspection, total.inspection);
+ printw("%4ld%8ld%9ld", this.inspection, game.inspection,
+ total.inspection);
move(tboxrow + 4, boxcol + 13);
- printw("%4d%8d%9d", this.game, game.game, total.game);
+ printw("%4ld%8ld%9ld", this.game, game.game, total.game);
move(tboxrow + 5, boxcol + 13);
- printw("%4d%8d%9d", this.runs, game.runs, total.runs);
+ printw("%4ld%8ld%9ld", this.runs, game.runs, total.runs);
move(tboxrow + 6, boxcol + 13);
- printw("%4d%8d%9d", this.information, game.information,
+ printw("%4ld%8ld%9ld", this.information, game.information,
total.information);
move(tboxrow + 7, boxcol + 13);
- printw("%4d%8d%9d", this.thinktime, game.thinktime, total.thinktime);
+ printw("%4ld%8ld%9ld", this.thinktime, game.thinktime, total.thinktime);
move(tboxrow + 8, boxcol + 13);
- printw("%4d%8d%9d", thiscosts, gamecosts, totalcosts);
+ printw("%4ld%8ld%9ld", thiscosts, gamecosts, totalcosts);
move(tboxrow + 9, boxcol + 13);
- printw("%4d%8d%9d", this.wins, game.wins, total.wins);
+ printw("%4ld%8ld%9ld", this.wins, game.wins, total.wins);
move(tboxrow + 10, boxcol + 13);
- printw("%4d%8d%9d", this.worth, game.worth, total.worth);
+ printw("%4ld%8ld%9ld", this.worth, game.worth, total.worth);
move(tboxrow + 11, boxcol + 13);
printw("%4.0f%%%7.1f%%%8.1f%%", thisreturn, gamereturn, totalreturn);
}
@@ -1109,8 +1191,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;
@@ -1141,7 +1225,9 @@ struct cardtype **cp;
/*
* print the tableau
*/
+void
tabprint(sour, des)
+ int sour, des;
{
int dlength, slength, i;
struct cardtype *tempcard;
@@ -1166,8 +1252,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;
@@ -1194,7 +1281,8 @@ tabtotab(sour, des)
*/
bool
rankhigher(cp, let)
- struct cardtype *cp;
+ const struct cardtype *cp;
+ int let;
{
if (found[let]->rank == King)
if (cp->rank == Ace)
@@ -1210,8 +1298,10 @@ rankhigher(cp, let)
/*
* function to determine if two cards are the same suit
*/
+int
samesuit(cp, let)
- struct cardtype *cp;
+ const struct cardtype *cp;
+ int let;
{
if (cp->suit == found[let]->suit)
return (TRUE);
@@ -1222,8 +1312,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;
@@ -1272,9 +1364,10 @@ movetofound(cp, source)
/*
* procedure to get a command
*/
+void
getcmd(row, col, cp)
int row, col;
- char *cp;
+ const char *cp;
{
char cmd[2] = { '\0', '\0'}, ch;
int i;
@@ -1286,7 +1379,9 @@ getcmd(row, col, cp)
move(row, col);
refresh();
do {
- ch = getch() & 0177;
+ if ((ch = getch()) == ERR)
+ cleanup(0);
+ ch &= 0177;
if (ch >= 'A' && ch <= 'Z')
ch += ('a' - 'A');
if (ch == '\f') {
@@ -1322,6 +1417,7 @@ getcmd(row, col, cp)
/*
* Suspend the game (shell escape if no process control on system)
*/
+void
suspend()
{
#ifndef SIGTSTP
@@ -1343,6 +1439,7 @@ suspend()
/*
* procedure to evaluate and make the specific moves
*/
+void
movecard()
{
int source, dest;
@@ -1491,8 +1588,8 @@ movecard()
} while (!done);
}
-char *basicinstructions[] = {
- "Here are brief instuctions to the game of Canfield:\n\n",
+const char *const basicinstructions[] = {
+ "Here are brief instructions to the game of Canfield:\n\n",
" If you have never played solitaire before, it is recom-\n",
"mended that you consult a solitaire instruction book. In\n",
"Canfield, tableau cards may be built on each other downward\n",
@@ -1513,7 +1610,7 @@ char *basicinstructions[] = {
"push any key when you are finished: ",
0 };
-char *bettinginstructions[] = {
+const char *const bettinginstructions[] = {
" The rules for betting are somewhat less strict than\n",
"those used in the official version of the game. The initial\n",
"deal costs $13. You may quit at this point or inspect the\n",
@@ -1538,9 +1635,10 @@ char *bettinginstructions[] = {
/*
* procedure to printout instructions
*/
+void
instruct()
{
- register char **cp;
+ const char *const *cp;
move(originrow, origincol);
printw("This is the game of solitaire called Canfield. Do\n");
@@ -1552,7 +1650,7 @@ instruct()
return;
clear();
for (cp = basicinstructions; *cp != 0; cp++)
- printw(*cp);
+ printw("%s", *cp);
refresh();
getch();
clear();
@@ -1565,7 +1663,7 @@ instruct()
return;
clear();
for (cp = bettinginstructions; *cp != 0; cp++)
- printw(*cp);
+ printw("%s", *cp);
refresh();
getch();
}
@@ -1573,6 +1671,7 @@ instruct()
/*
* procedure to initialize the game
*/
+void
initall()
{
int i;
@@ -1580,6 +1679,7 @@ initall()
srandom(getpid());
time(&acctstart);
initdeck(deck);
+ uid = getuid();
if (uid < 0)
uid = 0;
dbfd = open(_PATH_SCORE, O_RDWR);
@@ -1642,7 +1742,8 @@ finish()
* procedure to clean up and exit
*/
void
-cleanup()
+cleanup(dummy)
+ int dummy;
{
total.thinktime += 1;
@@ -1665,7 +1766,8 @@ cleanup()
* Field an interrupt.
*/
void
-askquit()
+askquit(dummy)
+ int dummy;
{
move(msgrow, msgcol);
printw("Really wish to quit? ");
@@ -1674,13 +1776,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[];
@@ -1718,6 +1821,6 @@ main(argc, argv)
else
cleanupboard();
}
- cleanup();
+ cleanup(0);
/* NOTREACHED */
}
diff --git a/games/canfield/canfield/pathnames.h b/games/canfield/canfield/pathnames.h
index 4ecb7bb9a43..9fefc5b9162 100644
--- a/games/canfield/canfield/pathnames.h
+++ b/games/canfield/canfield/pathnames.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: pathnames.h,v 1.2 2000/07/23 21:49:04 pjanzen Exp $ */
/* $NetBSD: pathnames.h,v 1.3 1995/03/21 15:08:34 cgd Exp $ */
/*-
diff --git a/games/canfield/cfscores/Makefile b/games/canfield/cfscores/Makefile
index bdc6269f8c3..78ccc6a39f7 100644
--- a/games/canfield/cfscores/Makefile
+++ b/games/canfield/cfscores/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 1995/03/21 15:08:36 cgd Exp $
+# $OpenBSD: Makefile,v 1.2 2000/07/23 21:49:07 pjanzen Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= cfscores
diff --git a/games/canfield/cfscores/cfscores.c b/games/canfield/cfscores/cfscores.c
index c3f9fe3be89..fb0bbf7be49 100644
--- a/games/canfield/cfscores/cfscores.c
+++ b/games/canfield/cfscores/cfscores.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: cfscores.c,v 1.5 2000/07/23 21:49:07 pjanzen Exp $ */
/* $NetBSD: cfscores.c,v 1.3 1995/03/21 15:08:37 cgd Exp $ */
/*
@@ -43,11 +44,12 @@ static char copyright[] =
#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 $";
+static char rcsid[] = "$OpenBSD: cfscores.c,v 1.5 2000/07/23 21:49:07 pjanzen Exp $";
#endif
#endif /* not lint */
#include <sys/types.h>
+#include <err.h>
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h>
@@ -67,22 +69,23 @@ struct betinfo {
int dbfd;
+void printuser __P((const struct passwd *, int));
+
+int
main(argc, argv)
int argc;
char *argv[];
{
- register struct passwd *pw;
+ struct passwd *pw;
int uid;
if (argc > 2) {
- printf("Usage: cfscores [user]\n");
+ fprintf(stderr, "Usage: cfscores [user]\n");
exit(1);
}
dbfd = open(_PATH_SCORE, O_RDONLY);
- if (dbfd < 0) {
- perror(_PATH_SCORE);
- exit(2);
- }
+ if (dbfd < 0)
+ err(2, "%s", _PATH_SCORE);
/* revoke privs */
setegid(getgid());
@@ -116,8 +119,9 @@ main(argc, argv)
/*
* print out info for specified password entry
*/
+void
printuser(pw, printfail)
- register struct passwd *pw;
+ const struct passwd *pw;
int printfail;
{
struct betinfo total;
@@ -129,12 +133,12 @@ printuser(pw, printfail)
}
i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), SEEK_SET);
if (i < 0) {
- perror("lseek");
+ warn("lseek %s", _PATH_SCORE);
return;
}
i = read(dbfd, (char *)&total, sizeof(total));
if (i < 0) {
- perror("read");
+ warn("lseek %s", _PATH_SCORE);
return;
}
if (i == 0 || total.hand == 0) {
@@ -149,14 +153,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");
}