1: /*
2: * Copyright (c) 1983 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: */
6:
7: #ifndef lint
8: static char sccsid[] = "@(#)lo_main.c 5.1 (Berkeley) 5/29/85";
9: #endif not lint
10:
11: /*
12: * Print out the top ten SAILors
13: *
14: * -l force a long listing (print out real usernames)
15: */
16: #include <pwd.h>
17: #include "externs.h"
18:
19: char *title[] = {
20: "Admiral", "Commodore", "Captain", "Captain",
21: "Captain", "Captain", "Captain", "Commander",
22: "Commander", "Lieutenant"
23: };
24:
25: lo_main()
26: {
27: FILE *fp;
28: char sbuf[32];
29: int n = 0, people;
30: struct passwd *getpwuid(), *pass;
31: struct logs log;
32: struct ship *ship;
33:
34: if ((fp = fopen(LOGFILE, "r")) == 0) {
35: perror(LOGFILE);
36: exit(1);
37: }
38: switch (fread((char *)&people, sizeof people, 1, fp)) {
39: case 0:
40: printf("Nobody has sailed yet.\n");
41: exit(0);
42: case 1:
43: break;
44: default:
45: perror(LOGFILE);
46: exit(1);
47: }
48: while (fread((char *)&log, sizeof log, 1, fp) == 1 &&
49: log.l_name[0] != '\0') {
50: if (longfmt && (pass = getpwuid(log.l_uid)) != NULL)
51: (void) sprintf(sbuf, "%10.10s (%s)",
52: log.l_name, pass->pw_name);
53: else
54: (void) sprintf(sbuf, "%20.20s", log.l_name);
55: ship = &scene[log.l_gamenum].ship[log.l_shipnum];
56: printf("%-10s %21s of the %15s %3d points, %5.2f equiv\n",
57: title[n++], sbuf, ship->shipname, log.l_netpoints,
58: (float) log.l_netpoints / ship->specs->pts);
59: }
60: printf("\n%d people have played.\n", people);
61: return 0;
62: }
Defined functions
Defined variables
sccsid
defined in line
8;
never used
title
defined in line
19; used 1 times