DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T s

⟦76a4a8419⟧ TextFile

    Length: 974 (0x3ce)
    Types: TextFile
    Names: »score.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Midway/score.c« 

TextFile

#include <stdio.h>
#include <pwd.h>
#include "globals.h"

#define LOGFILE "/usr/public/.midwaylog"

int maxpoints[2] = {637, 384};
struct logs {
	int uid;
	int fshipnum;
	int netpoints;
} log[20], zero;

main()
{
	FILE *fp;
	register int k, n;
	struct passwd *getpwuid();
	int score;
	long st;
	char buf[32];

	if (fp = fopen(LOGFILE, "r+")){
		n = fread(log, sizeof(struct logs), 20, fp);
		rewind(fp);
		printf("\n\nNAME\t\tSHIP\t\t\tTONS SUNK\tPERCENT\n\n");
		for (k=0; k < 20; k++) {
			st = (long) log[k].netpoints * 100L;
			score = (int) (st / (long) maxpoints[(Japanese(log[k].fshipnum))]);
			printf("%-10s%16s%20ld%10d%%\n", getpwuid(log[k].uid) -> pw_name, shiplist[log[k].fshipnum].name, log[k].netpoints * 1000L, score);
			printf("\nSave? ");
			scanf("%s", buf);
			if (*buf == 'y') 
				fwrite(log + k, sizeof(struct logs), 1, fp);
			else {
				printf("Removing...\n");
				n--;
			}
		}
		fwrite(&zero, sizeof(struct logs), 20 - n, fp);
	}
	fclose(fp);
}