+/* $NetBSD: cfscores.c,v 1.6 1998/08/29 22:47:57 hubertf Exp $ */
+
/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
+ * 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
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1983 Regents of the University of California.\n\
- 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
-/*static char sccsid[] = "from: @(#)cfscores.c 5.6 (Berkeley) 6/1/90";*/
-static char rcsid[] = "$Id: cfscores.c,v 1.2 1993/08/01 18:55:25 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)cfscores.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: cfscores.c,v 1.6 1998/08/29 22:47:57 hubertf Exp $");
+#endif
#endif /* not lint */
#include <sys/types.h>
+#include <err.h>
+#include <fcntl.h>
#include <pwd.h>
+#include <stdio.h>
+#include <unistd.h>
#include "pathnames.h"
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) {
printf("Usage: cfscores [user]\n");
exit(1);
}
- dbfd = open(_PATH_SCORE, 0);
- if (dbfd < 0) {
- perror(_PATH_SCORE);
- exit(2);
- }
+ dbfd = open(_PATH_SCORE, O_RDONLY);
+ if (dbfd < 0)
+ err(2, "open %s", _PATH_SCORE);
setpwent();
if (argc == 1) {
uid = getuid();
/*
* print out info for specified password entry
*/
+void
printuser(pw, printfail)
- register struct passwd *pw;
+ struct passwd *pw;
int printfail;
{
struct betinfo total;
printf("Bad uid %d\n", pw->pw_uid);
return;
}
- i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), 0);
- if (i < 0) {
- perror("lseek");
- return;
- }
+ i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), SEEK_SET);
+ if (i < 0)
+ warn("lseek %s", _PATH_SCORE);
i = read(dbfd, (char *)&total, sizeof(total));
- if (i < 0) {
- perror("read");
- return;
- }
+ if (i < 0)
+ warn("read %s", _PATH_SCORE);
if (i == 0 || total.hand == 0) {
if (printfail)
printf("%s has never played canfield.\n", pw->pw_name);
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");
}