+static u_int32_t numscores, max_uid;
+
+static void read_score(int);
+static void write_score(int);
+
+/*
+ * read_score:
+ * Read the score file in MI format
+ */
+static void
+read_score(inf)
+ int inf;
+{
+ SCORE *scp;
+
+ if (read(inf, &max_uid, sizeof max_uid) == sizeof max_uid) {
+ max_uid = ntohl(max_uid);
+
+ read(inf, Top, sizeof Top);
+ for (scp = Top; scp < &Top[MAXSCORES]; scp++) {
+ scp->s_uid = ntohl(scp->s_uid);
+ scp->s_score = ntohl(scp->s_score);
+ scp->s_auto = ntohl(scp->s_auto);
+ scp->s_level = ntohl(scp->s_level);
+ }
+ }
+ else {
+ for (scp = Top; scp < &Top[MAXSCORES]; scp++)
+ scp->s_score = 0;
+ max_uid = Max_per_uid;
+ }
+}
+
+/*
+ * write_score:
+ * Write the score file in MI format
+ */
+static void
+write_score(inf)
+ int inf;
+{
+ SCORE *scp;
+
+ lseek(inf, 0L, SEEK_SET);
+
+ max_uid = htonl(max_uid);
+ write(inf, &max_uid, sizeof max_uid);
+
+ for (scp = Top; scp < &Top[MAXSCORES]; scp++) {
+ scp->s_uid = htonl(scp->s_uid);
+ scp->s_score = htonl(scp->s_score);
+ scp->s_auto = htonl(scp->s_auto);
+ scp->s_level = htonl(scp->s_level);
+ }
+
+ write(inf, Top, sizeof Top);
+}
+
+