X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/462fca95471224f85b85be911e72faee16cd1597..f8e5a55fcd64d3930e27c7729a7fa6a09bdc8fa9:/canfield/cfscores/cfscores.c diff --git a/canfield/cfscores/cfscores.c b/canfield/cfscores/cfscores.c index da9df376..e5830fef 100644 --- a/canfield/cfscores/cfscores.c +++ b/canfield/cfscores/cfscores.c @@ -1,6 +1,8 @@ +/* $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 @@ -31,19 +33,26 @@ * SUCH DAMAGE. */ +#include #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 +#include +#include #include +#include +#include #include "pathnames.h" struct betinfo { @@ -59,22 +68,24 @@ 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(); @@ -103,8 +114,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; @@ -114,16 +126,12 @@ printuser(pw, printfail) 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); @@ -136,14 +144,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"); }