Annotation of 43BSDReno/games/sail/lo_main.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: static char sccsid[] = "@(#)lo_main.c  5.6 (Berkeley) 6/1/90";
        !            22: #endif /* not lint */
        !            23: 
        !            24: /*
        !            25:  * Print out the top ten SAILors
        !            26:  *
        !            27:  * -l force a long listing (print out real usernames)
        !            28:  */
        !            29: #include <sys/types.h>
        !            30: #include <pwd.h>
        !            31: #include "externs.h"
        !            32: #include "pathnames.h"
        !            33: 
        !            34: char *title[] = {
        !            35:        "Admiral", "Commodore", "Captain", "Captain",
        !            36:        "Captain", "Captain", "Captain", "Commander",
        !            37:        "Commander", "Lieutenant"
        !            38: };
        !            39: 
        !            40: lo_main()
        !            41: {
        !            42:        FILE *fp;
        !            43:        char sbuf[32];
        !            44:        int n = 0, people;
        !            45:        struct passwd *getpwuid(), *pass;
        !            46:        struct logs log;
        !            47:        struct ship *ship;
        !            48: 
        !            49:        if ((fp = fopen(_PATH_LOGFILE, "r")) == 0) {
        !            50:                perror(_PATH_LOGFILE);
        !            51:                exit(1);
        !            52:        }
        !            53:        switch (fread((char *)&people, sizeof people, 1, fp)) {
        !            54:        case 0:
        !            55:                printf("Nobody has sailed yet.\n");
        !            56:                exit(0);
        !            57:        case 1:
        !            58:                break;
        !            59:        default:
        !            60:                perror(_PATH_LOGFILE);
        !            61:                exit(1);
        !            62:        }
        !            63:        while (fread((char *)&log, sizeof log, 1, fp) == 1 &&
        !            64:               log.l_name[0] != '\0') {
        !            65:                if (longfmt && (pass = getpwuid(log.l_uid)) != NULL)
        !            66:                        (void) sprintf(sbuf, "%10.10s (%s)",
        !            67:                                log.l_name, pass->pw_name);
        !            68:                else
        !            69:                        (void) sprintf(sbuf, "%20.20s", log.l_name);
        !            70:                ship = &scene[log.l_gamenum].ship[log.l_shipnum];
        !            71:                printf("%-10s %21s of the %15s %3d points, %5.2f equiv\n",
        !            72:                        title[n++], sbuf, ship->shipname, log.l_netpoints,
        !            73:                        (float) log.l_netpoints / ship->specs->pts);
        !            74:        }
        !            75:        printf("\n%d people have played.\n", people);
        !            76:        return 0;
        !            77: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.