CVS commit: src/games/canfield/canfield

2014-03-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Mar 22 23:47:03 UTC 2014

Modified Files:
src/games/canfield/canfield: canfield.c

Log Message:
Use ssize_t for read() results. Don't use int for lseek() results.
Call srandom() with time(), not getpid().


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/games/canfield/canfield/canfield.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/canfield/canfield.c
diff -u src/games/canfield/canfield/canfield.c:1.29 src/games/canfield/canfield/canfield.c:1.30
--- src/games/canfield/canfield/canfield.c:1.29	Sat Mar 22 23:42:48 2014
+++ src/games/canfield/canfield/canfield.c	Sat Mar 22 23:47:03 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: canfield.c,v 1.29 2014/03/22 23:42:48 dholland Exp $	*/
+/*	$NetBSD: canfield.c,v 1.30 2014/03/22 23:47:03 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)canfield.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: canfield.c,v 1.29 2014/03/22 23:42:48 dholland Exp $");
+__RCSID("$NetBSD: canfield.c,v 1.30 2014/03/22 23:47:03 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -1637,9 +1637,9 @@ instruct(void)
 static void
 initall(void)
 {
-	int i;
+	ssize_t i;
 
-	srandom(getpid());
+	srandom(time(NULL));
 	time(&acctstart);
 	initdeck(deck);
 	uid = getuid();
@@ -1652,8 +1652,7 @@ initall(void)
 		return;
 	if (dbfd < 3)
 		exit(1);
-	i = lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
-	if (i < 0) {
+	if (lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET) < 0) {
 		close(dbfd);
 		dbfd = -1;
 		return;



CVS commit: src/games/canfield/cfscores

2014-03-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Mar 22 23:45:34 UTC 2014

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Use ssize_t for read() results. Don't use int for lseek() results.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/cfscores/cfscores.c
diff -u src/games/canfield/cfscores/cfscores.c:1.21 src/games/canfield/cfscores/cfscores.c:1.22
--- src/games/canfield/cfscores/cfscores.c:1.21	Sun Jan  3 17:08:45 2010
+++ src/games/canfield/cfscores/cfscores.c	Sat Mar 22 23:45:34 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: cfscores.c,v 1.21 2010/01/03 17:08:45 dholland Exp $	*/
+/*	$NetBSD: cfscores.c,v 1.22 2014/03/22 23:45:34 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)cfscores.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: cfscores.c,v 1.21 2010/01/03 17:08:45 dholland Exp $");
+__RCSID("$NetBSD: cfscores.c,v 1.22 2014/03/22 23:45:34 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -106,7 +106,7 @@ printuser(const struct passwd *pw, int p
 {
 	struct betinfo total;
 	off_t pos;
-	int i;
+	ssize_t i;
 
 	pos = pw->pw_uid * (off_t)sizeof(struct betinfo);
 	/* test pos, not pw_uid; uid_t can be unsigned, which makes gcc warn */
@@ -114,9 +114,9 @@ printuser(const struct passwd *pw, int p
 		warnx("Bad uid %d", (int)pw->pw_uid);
 		return;
 	}
-	i = lseek(dbfd, pos, SEEK_SET);
-	if (i < 0)
-		warn("lseek %s", _PATH_SCORE);
+	if (lseek(dbfd, pos, SEEK_SET) < 0) {
+		warn("%s: lseek", _PATH_SCORE);
+	}
 	i = read(dbfd, &total, sizeof(total));
 	if (i < 0)
 		warn("read %s", _PATH_SCORE);



CVS commit: src/games/canfield/canfield

2014-03-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Mar 22 23:42:48 UTC 2014

Modified Files:
src/games/canfield/canfield: canfield.c

Log Message:
Use uid_t to hold getuid() results, and don't check getuid for failure
as it isn't allowed to fail.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/games/canfield/canfield/canfield.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/canfield/canfield.c
diff -u src/games/canfield/canfield/canfield.c:1.28 src/games/canfield/canfield/canfield.c:1.29
--- src/games/canfield/canfield/canfield.c:1.28	Mon May 23 22:46:35 2011
+++ src/games/canfield/canfield/canfield.c	Sat Mar 22 23:42:48 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: canfield.c,v 1.28 2011/05/23 22:46:35 joerg Exp $	*/
+/*	$NetBSD: canfield.c,v 1.29 2014/03/22 23:42:48 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)canfield.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: canfield.c,v 1.28 2011/05/23 22:46:35 joerg Exp $");
+__RCSID("$NetBSD: canfield.c,v 1.29 2014/03/22 23:42:48 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -168,7 +168,7 @@ static bool mtfdone, Cflag = FALSE;
 #define BETTINGBOX	2
 #define NOBOX		3
 static int status = INSTRUCTIONBOX;
-static int uid;
+static uid_t uid;
 
 /*
  * Basic betting costs
@@ -1643,8 +1643,6 @@ initall(void)
 	time(&acctstart);
 	initdeck(deck);
 	uid = getuid();
-	if (uid < 0)
-		uid = 0;
 	dbfd = open(_PATH_SCORE, O_RDWR);
 
 	/* Revoke setgid privileges */



CVS commit: src/games/canfield/canfield

2011-05-23 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon May 23 22:46:35 UTC 2011

Modified Files:
src/games/canfield/canfield: canfield.c

Log Message:
Don't use strings from arrays as format string.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/games/canfield/canfield/canfield.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/canfield/canfield.c
diff -u src/games/canfield/canfield/canfield.c:1.27 src/games/canfield/canfield/canfield.c:1.28
--- src/games/canfield/canfield/canfield.c:1.27	Fri Jan  1 06:37:15 2010
+++ src/games/canfield/canfield/canfield.c	Mon May 23 22:46:35 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: canfield.c,v 1.27 2010/01/01 06:37:15 dholland Exp $	*/
+/*	$NetBSD: canfield.c,v 1.28 2011/05/23 22:46:35 joerg Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)canfield.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: canfield.c,v 1.27 2010/01/01 06:37:15 dholland Exp $");
+__RCSID("$NetBSD: canfield.c,v 1.28 2011/05/23 22:46:35 joerg Exp $");
 #endif
 #endif /* not lint */
 
@@ -1613,7 +1613,7 @@
 		return;
 	clear();
 	for (cp = basicinstructions; *cp != 0; cp++)
-		printw(*cp);
+		printw("%s", *cp);
 	refresh();
 	getch();
 	clear();
@@ -1626,7 +1626,7 @@
 		return;
 	clear();
 	for (cp = bettinginstructions; *cp != 0; cp++)
-		printw(*cp);
+		printw("%s", *cp);
 	refresh();
 	getch();
 }



CVS commit: src/games/canfield/cfscores

2010-01-03 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jan  3 17:08:45 UTC 2010

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Christos points out that usage should not use errx, but should use
getprogname.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/cfscores/cfscores.c
diff -u src/games/canfield/cfscores/cfscores.c:1.20 src/games/canfield/cfscores/cfscores.c:1.21
--- src/games/canfield/cfscores/cfscores.c:1.20	Fri Jan  1 06:37:16 2010
+++ src/games/canfield/cfscores/cfscores.c	Sun Jan  3 17:08:45 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cfscores.c,v 1.20 2010/01/01 06:37:16 dholland Exp $	*/
+/*	$NetBSD: cfscores.c,v 1.21 2010/01/03 17:08:45 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)cfscores.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: cfscores.c,v 1.20 2010/01/01 06:37:16 dholland Exp $");
+__RCSID("$NetBSD: cfscores.c,v 1.21 2010/01/03 17:08:45 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -68,7 +68,9 @@
 	setgid(getgid());
 
 	if (argc > 2) {
-		errx(1, "Usage: cfscores -a | cfscores [user]");
+		fprintf(stderr, "Usage: %s -a | %s [user]\n",
+			getprogname(), getprogname());
+		exit(1);
 	}
 	dbfd = open(_PATH_SCORE, O_RDONLY);
 	if (dbfd < 0)



CVS commit: src/games/canfield/canfield

2010-01-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Jan  1 11:45:34 UTC 2010

Modified Files:
src/games/canfield/canfield: canfield.6

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/games/canfield/canfield/canfield.6

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/canfield/canfield.6
diff -u src/games/canfield/canfield/canfield.6:1.11 src/games/canfield/canfield/canfield.6:1.12
--- src/games/canfield/canfield/canfield.6:1.11	Fri Jan  1 07:35:09 2010
+++ src/games/canfield/canfield/canfield.6	Fri Jan  1 11:45:34 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: canfield.6,v 1.11 2010/01/01 07:35:09 dholland Exp $
+.\"	$NetBSD: canfield.6,v 1.12 2010/01/01 11:45:34 wiz Exp $
 .\"
 .\" Copyright (c) 1983, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -44,17 +44,19 @@
 .Fl a
 .Sh DESCRIPTION
 If you have never played solitaire before, it is recommended
-that you consult a solitaire instruction book. In
-Canfield, tableau cards may be built on each other downward
-in alternate colors. An entire pile must be moved as a unit
-in building. Top cards of the piles are available
-to be played on foundations, but never into empty spaces.
-.Pp
-Spaces must be filled from the stock. The top card of
-the stock also is available to be played on foundations or
-built on tableau piles. After the stock is exhausted,
-tableau spaces may be filled from the talon and the player may
-keep them open until he wishes to use them.
+that you consult a solitaire instruction book.
+In Canfield, tableau cards may be built on each other downward in
+alternate colors.
+An entire pile must be moved as a unit in building.
+Top cards of the piles are available to be played on foundations,
+but never into empty spaces.
+.Pp
+Spaces must be filled from the stock.
+The top card of the stock also is available to be played on
+foundations or built on tableau piles.
+After the stock is exhausted, tableau spaces may be filled from
+the talon and the player may keep them open until he wishes to use
+them.
 .Pp
 Cards are dealt from the hand to the talon by threes
 and this repeats until there are no more cards in the hand



CVS commit: src/games/canfield/canfield

2009-12-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan  1 07:35:09 UTC 2010

Modified Files:
src/games/canfield/canfield: canfield.6

Log Message:
Adjust SYNOPSIS for cfscores to better match reality. Note in BUGS
that the score file isn't portable. Bump date (first time since 1993,
and first in 2010...)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/games/canfield/canfield/canfield.6

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/canfield/canfield.6
diff -u src/games/canfield/canfield/canfield.6:1.10 src/games/canfield/canfield/canfield.6:1.11
--- src/games/canfield/canfield/canfield.6:1.10	Thu Sep 15 02:09:41 2005
+++ src/games/canfield/canfield/canfield.6	Fri Jan  1 07:35:09 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: canfield.6,v 1.10 2005/09/15 02:09:41 wiz Exp $
+.\"	$NetBSD: canfield.6,v 1.11 2010/01/01 07:35:09 dholland Exp $
 .\"
 .\" Copyright (c) 1983, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	@(#)canfield.6	8.1 (Berkeley) 5/31/93
 .\"
-.Dd May 31, 1993
+.Dd January 1, 2010
 .Dt CANFIELD 6
 .Os
 .Sh NAME
@@ -39,8 +39,9 @@
 .Sh SYNOPSIS
 .Nm
 .Nm cfscores
-.Op Fl a
 .Op Ar user
+.Nm cfscores
+.Fl a
 .Sh DESCRIPTION
 If you have never played solitaire before, it is recommended
 that you consult a solitaire instruction book. In
@@ -120,3 +121,5 @@
 Mikey Olson, and Eric Allman.
 .Sh BUGS
 It is impossible to cheat.
+.Pp
+The score file database is not portable.



CVS commit: src/games/canfield

2009-12-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan  1 06:37:16 UTC 2010

Modified Files:
src/games/canfield/canfield: canfield.c
src/games/canfield/cfscores: cfscores.c
Added Files:
src/games/canfield/canfield: betinfo.h

Log Message:
Split struct betinfo into its own header file so it can be shared
between canfield and cfscores, instead of copy-pasted.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/games/canfield/canfield/betinfo.h
cvs rdiff -u -r1.26 -r1.27 src/games/canfield/canfield/canfield.c
cvs rdiff -u -r1.19 -r1.20 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/canfield/canfield.c
diff -u src/games/canfield/canfield/canfield.c:1.26 src/games/canfield/canfield/canfield.c:1.27
--- src/games/canfield/canfield/canfield.c:1.26	Wed Aug 12 05:35:44 2009
+++ src/games/canfield/canfield/canfield.c	Fri Jan  1 06:37:15 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: canfield.c,v 1.26 2009/08/12 05:35:44 dholland Exp $	*/
+/*	$NetBSD: canfield.c,v 1.27 2010/01/01 06:37:15 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)canfield.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: canfield.c,v 1.26 2009/08/12 05:35:44 dholland Exp $");
+__RCSID("$NetBSD: canfield.c,v 1.27 2010/01/01 06:37:15 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -66,6 +66,7 @@
 #include 
 #include 
 
+#include "betinfo.h"
 #include "pathnames.h"
 
 #define	decksize	52
@@ -183,16 +184,6 @@
 /*
  * Variables associated with betting 
  */
-struct betinfo {
-	long	hand;		/* cost of dealing hand */
-	long	inspection;	/* cost of inspecting hand */
-	long	game;		/* cost of buying game */
-	long	runs;		/* cost of running through hands */
-	long	information;	/* cost of information */
-	long	thinktime;	/* cost of thinking time */
-	long	wins;		/* total winnings */
-	long	worth;		/* net worth after costs */
-};
 static struct betinfo this, game, total;
 static bool startedgame = FALSE, infullgame = FALSE;
 static time_t acctstart;

Index: src/games/canfield/cfscores/cfscores.c
diff -u src/games/canfield/cfscores/cfscores.c:1.19 src/games/canfield/cfscores/cfscores.c:1.20
--- src/games/canfield/cfscores/cfscores.c:1.19	Fri Jan  1 06:31:18 2010
+++ src/games/canfield/cfscores/cfscores.c	Fri Jan  1 06:37:16 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cfscores.c,v 1.19 2010/01/01 06:31:18 dholland Exp $	*/
+/*	$NetBSD: cfscores.c,v 1.20 2010/01/01 06:37:16 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)cfscores.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: cfscores.c,v 1.19 2010/01/01 06:31:18 dholland Exp $");
+__RCSID("$NetBSD: cfscores.c,v 1.20 2010/01/01 06:37:16 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -51,19 +51,9 @@
 #include 
 #include 
 #include 
+#include "betinfo.h"
 #include "pathnames.h"
 
-struct betinfo {
-	long	hand;		/* cost of dealing hand */
-	long	inspection;	/* cost of inspecting hand */
-	long	game;		/* cost of buying game */
-	long	runs;		/* cost of running through hands */
-	long	information;	/* cost of information */
-	long	thinktime;	/* cost of thinking time */
-	long	wins;		/* total winnings */
-	long	worth;		/* net worth after costs */
-};
-
 static int dbfd;
 
 static void printuser(const struct passwd *, int);

Added files:

Index: src/games/canfield/canfield/betinfo.h
diff -u /dev/null src/games/canfield/canfield/betinfo.h:1.1
--- /dev/null	Fri Jan  1 06:37:16 2010
+++ src/games/canfield/canfield/betinfo.h	Fri Jan  1 06:37:15 2010
@@ -0,0 +1,44 @@
+/*	$NetBSD: betinfo.h,v 1.1 2010/01/01 06:37:15 dholland Exp $	*/
+
+/*
+ * Copyright (c) 1983, 1993
+ *	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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 

CVS commit: src/games/canfield/cfscores

2009-12-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan  1 06:31:18 UTC 2010

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Use NULL instead of 0 for pointer tests. Remove an unnecessary cast.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/cfscores/cfscores.c
diff -u src/games/canfield/cfscores/cfscores.c:1.18 src/games/canfield/cfscores/cfscores.c:1.19
--- src/games/canfield/cfscores/cfscores.c:1.18	Fri Jan  1 06:20:45 2010
+++ src/games/canfield/cfscores/cfscores.c	Fri Jan  1 06:31:18 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cfscores.c,v 1.18 2010/01/01 06:20:45 dholland Exp $	*/
+/*	$NetBSD: cfscores.c,v 1.19 2010/01/01 06:31:18 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)cfscores.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: cfscores.c,v 1.18 2010/01/01 06:20:45 dholland Exp $");
+__RCSID("$NetBSD: cfscores.c,v 1.19 2010/01/01 06:31:18 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -87,19 +87,19 @@
 	if (argc == 1) {
 		uid = getuid();
 		pw = getpwuid(uid);
-		if (pw == 0) {
+		if (pw == NULL) {
 			errx(2, "You are not listed in the password file?!?");
 		}
 		printuser(pw, 1);
 		exit(0);
 	}
 	if (strcmp(argv[1], "-a") == 0) {
-		while ((pw = getpwent()) != 0)
+		while ((pw = getpwent()) != NULL)
 			printuser(pw, 0);
 		exit(0);
 	}
 	pw = getpwnam(argv[1]);
-	if (pw == 0) {
+	if (pw == NULL) {
 		errx(3, "User %s unknown", argv[1]);
 	}
 	printuser(pw, 1);
@@ -125,7 +125,7 @@
 	i = lseek(dbfd, pos, SEEK_SET);
 	if (i < 0)
 		warn("lseek %s", _PATH_SCORE);
-	i = read(dbfd, (char *)&total, sizeof(total));
+	i = read(dbfd, &total, sizeof(total));
 	if (i < 0)
 		warn("read %s", _PATH_SCORE);
 	if (i == 0 || total.hand == 0) {



CVS commit: src/games/canfield/cfscores

2009-12-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan  1 06:20:45 UTC 2010

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Send error messages to stderr. Use errx/warnx, not printf.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/cfscores/cfscores.c
diff -u src/games/canfield/cfscores/cfscores.c:1.17 src/games/canfield/cfscores/cfscores.c:1.18
--- src/games/canfield/cfscores/cfscores.c:1.17	Fri Jan  1 06:16:36 2010
+++ src/games/canfield/cfscores/cfscores.c	Fri Jan  1 06:20:45 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cfscores.c,v 1.17 2010/01/01 06:16:36 dholland Exp $	*/
+/*	$NetBSD: cfscores.c,v 1.18 2010/01/01 06:20:45 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)cfscores.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: cfscores.c,v 1.17 2010/01/01 06:16:36 dholland Exp $");
+__RCSID("$NetBSD: cfscores.c,v 1.18 2010/01/01 06:20:45 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -78,8 +78,7 @@
 	setgid(getgid());
 
 	if (argc > 2) {
-		printf("Usage: cfscores -a | cfscores [user]\n");
-		exit(1);
+		errx(1, "Usage: cfscores -a | cfscores [user]");
 	}
 	dbfd = open(_PATH_SCORE, O_RDONLY);
 	if (dbfd < 0)
@@ -89,8 +88,7 @@
 		uid = getuid();
 		pw = getpwuid(uid);
 		if (pw == 0) {
-			printf("You are not listed in the password file?!?\n");
-			exit(2);
+			errx(2, "You are not listed in the password file?!?");
 		}
 		printuser(pw, 1);
 		exit(0);
@@ -102,8 +100,7 @@
 	}
 	pw = getpwnam(argv[1]);
 	if (pw == 0) {
-		printf("User %s unknown\n", argv[1]);
-		exit(3);
+		errx(3, "User %s unknown", argv[1]);
 	}
 	printuser(pw, 1);
 	exit(0);
@@ -122,7 +119,7 @@
 	pos = pw->pw_uid * (off_t)sizeof(struct betinfo);
 	/* test pos, not pw_uid; uid_t can be unsigned, which makes gcc warn */
 	if (pos < 0) {
-		printf("Bad uid %d\n", (int)pw->pw_uid);
+		warnx("Bad uid %d", (int)pw->pw_uid);
 		return;
 	}
 	i = lseek(dbfd, pos, SEEK_SET);



CVS commit: src/games/canfield/cfscores

2009-12-31 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Jan  1 06:16:36 UTC 2010

Modified Files:
src/games/canfield/cfscores: cfscores.c

Log Message:
Correct usage message.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/cfscores/cfscores.c
diff -u src/games/canfield/cfscores/cfscores.c:1.16 src/games/canfield/cfscores/cfscores.c:1.17
--- src/games/canfield/cfscores/cfscores.c:1.16	Wed Aug 12 05:35:44 2009
+++ src/games/canfield/cfscores/cfscores.c	Fri Jan  1 06:16:36 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: cfscores.c,v 1.16 2009/08/12 05:35:44 dholland Exp $	*/
+/*	$NetBSD: cfscores.c,v 1.17 2010/01/01 06:16:36 dholland Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)cfscores.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: cfscores.c,v 1.16 2009/08/12 05:35:44 dholland Exp $");
+__RCSID("$NetBSD: cfscores.c,v 1.17 2010/01/01 06:16:36 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -78,7 +78,7 @@
 	setgid(getgid());
 
 	if (argc > 2) {
-		printf("Usage: cfscores [user]\n");
+		printf("Usage: cfscores -a | cfscores [user]\n");
 		exit(1);
 	}
 	dbfd = open(_PATH_SCORE, O_RDONLY);



CVS commit: src/games/canfield

2009-08-11 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Wed Aug 12 05:35:44 UTC 2009

Modified Files:
src/games/canfield/canfield: canfield.c
src/games/canfield/cfscores: cfscores.c

Log Message:
sprinkle static


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/games/canfield/canfield/canfield.c
cvs rdiff -u -r1.15 -r1.16 src/games/canfield/cfscores/cfscores.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/canfield/canfield/canfield.c
diff -u src/games/canfield/canfield/canfield.c:1.25 src/games/canfield/canfield/canfield.c:1.26
--- src/games/canfield/canfield/canfield.c:1.25	Fri Aug  8 16:10:47 2008
+++ src/games/canfield/canfield/canfield.c	Wed Aug 12 05:35:44 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: canfield.c,v 1.25 2008/08/08 16:10:47 drochner Exp $	*/
+/*	$NetBSD: canfield.c,v 1.26 2009/08/12 05:35:44 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)canfield.c	8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: canfield.c,v 1.25 2008/08/08 16:10:47 drochner Exp $");
+__RCSID("$NetBSD: canfield.c,v 1.26 2009/08/12 05:35:44 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -149,25 +149,25 @@
 
 #define	NIL	((struct cardtype *) -1)
 
-struct cardtype *deck[decksize];
-struct cardtype cards[decksize];
-struct cardtype *bottom[4], *found[4], *tableau[4];
-struct cardtype *talon, *hand, *stock, *basecard;
-int length[4];
-int cardsoff, base, cinhand, taloncnt, stockcnt, timesthru;
-char suitmap[4] = {spades, clubs, hearts, diamonds};
-char colormap[4] = {black, black, red, red};
-char pilemap[4] = {atabcol, btabcol, ctabcol, dtabcol};
-char srcpile, destpile;
-int mtforigin, tempbase;
-int coldcol, cnewcol, coldrow, cnewrow;
-bool errmsg, done;
-bool mtfdone, Cflag = FALSE;
+static struct cardtype *deck[decksize];
+static struct cardtype cards[decksize];
+static struct cardtype *bottom[4], *found[4], *tableau[4];
+static struct cardtype *talon, *hand, *stock, *basecard;
+static int length[4];
+static int cardsoff, base, cinhand, taloncnt, stockcnt, timesthru;
+static char suitmap[4] = {spades, clubs, hearts, diamonds};
+static char colormap[4] = {black, black, red, red};
+static char pilemap[4] = {atabcol, btabcol, ctabcol, dtabcol};
+static char srcpile, destpile;
+static int mtforigin, tempbase;
+static int coldcol, cnewcol, coldrow, cnewrow;
+static bool errmsg, done;
+static bool mtfdone, Cflag = FALSE;
 #define INSTRUCTIONBOX	1
 #define BETTINGBOX	2
 #define NOBOX		3
-int status = INSTRUCTIONBOX;
-int uid;
+static int status = INSTRUCTIONBOX;
+static int uid;
 
 /*
  * Basic betting costs
@@ -193,58 +193,57 @@
 	long	wins;		/* total winnings */
 	long	worth;		/* net worth after costs */
 };
-struct betinfo this, game, total;
-bool startedgame = FALSE, infullgame = FALSE;
-time_t acctstart;
-int dbfd = -1;
-
-void	askquit(int);
-void	cleanup(int) __dead;
-void	cleanupboard(void);
-void	clearabovemovebox(void);
-void	clearbelowmovebox(void);
-void	clearmsg(void);
-void	clearstat(void);
-void	destinerror(void);
-bool	diffcolor(const struct cardtype *, const struct cardtype *);
-void	dumberror(void);
-bool	finish(void);
-void	fndbase(struct cardtype **, int, int);
-void	getcmd(int, int, const char *);
-void	initall(void);
-void	initdeck(struct cardtype *[]);
-void	initgame(void);
-void	instruct(void);
-int	main(void);
-void	makeboard(void);
-void	movebox(void);
-void	movecard(void);
-void	movetofound(struct cardtype **, int);
-void	movetotalon(void);
-bool	notempty(const struct cardtype *);
-void	printbottombettingbox(void);
-void	printbottominstructions(void);
-void	printcard(int, int, const struct cardtype *);
-void	printrank(int, int, const struct cardtype *, bool);
-void	printtopbettingbox(void);
-void	printtopinstructions(void);
-bool	rankhigher(const struct cardtype *, int);
-bool	ranklower(const struct cardtype *, const struct cardtype *);
-void	removecard(int, int);
-int	samesuit(const struct cardtype *, int);
-void	showcards(void);
-void	showstat(void);
-void	shuffle(struct cardtype *[]);
-void	simpletableau(struct cardtype **, int);
-void	startgame(void);
-void	suspend(void);
-bool	tabok(const struct cardtype *, int);
-void	tabprint(int, int);
-void	tabtotab(int, int);
-void	transit(struct cardtype **, struct cardtype **);
-void	updatebettinginfo(void);
-void	usedstock(void);
-void	usedtalon(void);
+static struct betinfo this, game, total;
+static bool startedgame = FALSE, infullgame = FALSE;
+static time_t acctstart;
+static int dbfd = -1;
+
+static void	askquit(int);
+static void	cleanup(int) __dead;
+static void	cleanupboard(void);
+static void	clearabovemovebox(void);
+static void	clearbelowmovebox(void);
+static void	clearmsg(void);
+static void	clearstat(void);
+static void	destinerror(void);
+static bool	diffcolor(const struct cardtype *, const struct cardtype *);
+static void	dumberror(void);
+stat