ahci - Add workarounds for Marvell 88SE9215
[dragonfly.git] / games / sail / lo_main.c
blob59c759c2890c9c75a7d2572469be7077af5b5335
1 /*-
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * @(#)lo_main.c 8.1 (Berkeley) 5/31/93
30 * $FreeBSD: src/games/sail/lo_main.c,v 1.2 1999/11/30 03:49:34 billf Exp $
34 * Print out the top ten SAILors
36 * -l force a long listing (print out real usernames)
38 #include <sys/types.h>
39 #include <pwd.h>
40 #include "externs.h"
41 #include "pathnames.h"
43 const char *title[] = {
44 "Admiral", "Commodore", "Captain", "Captain",
45 "Captain", "Captain", "Captain", "Commander",
46 "Commander", "Lieutenant"
49 int
50 lo_main(void)
52 FILE *fp;
53 char sbuf[32];
54 int n = 0, ppl;
55 struct passwd *pass;
56 struct logs log;
57 struct ship *ship;
59 if ((fp = fopen(_PATH_LOGFILE, "r")) == NULL) {
60 perror(_PATH_LOGFILE);
61 exit(1);
63 switch (fread((char *)&ppl, sizeof ppl, 1, fp)) {
64 case 0:
65 printf("Nobody has sailed yet.\n");
66 exit(0);
67 case 1:
68 break;
69 default:
70 perror(_PATH_LOGFILE);
71 exit(1);
73 while (fread((char *)&log, sizeof log, 1, fp) == 1 &&
74 log.l_name[0] != '\0') {
75 if (longfmt && (pass = getpwuid(log.l_uid)) != NULL)
76 sprintf(sbuf, "%10.10s (%s)",
77 log.l_name, pass->pw_name);
78 else
79 sprintf(sbuf, "%20.20s", log.l_name);
80 ship = &scene[log.l_gamenum].ship[log.l_shipnum];
81 printf("%-10s %21s of the %15s %3d points, %5.2f equiv\n",
82 title[n++], sbuf, ship->shipname, log.l_netpoints,
83 (float) log.l_netpoints / ship->specs->pts);
85 printf("\n%d people have played.\n", ppl);
86 return 0;