+/* $NetBSD: dumpgame.c,v 1.5 1997/10/12 21:24:42 christos Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char sccsid[] = "@(#)dumpgame.c 4.6 (Berkeley) 6/1/90";
+#if 0
+static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: dumpgame.c,v 1.5 1997/10/12 21:24:42 christos Exp $");
+#endif
#endif /* not lint */
-# include "trek.h"
+#include <stdio.h>
+#include <err.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include "trek.h"
/*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/
# define VERSION 2
int count;
};
+static int readdump __P((int));
+
struct dump Dump_template[] =
{
- (char *)&Ship, sizeof (Ship),
- (char *)&Now, sizeof (Now),
- (char *)&Param, sizeof (Param),
- (char *)&Etc, sizeof (Etc),
- (char *)&Game, sizeof (Game),
- (char *)Sect, sizeof (Sect),
- (char *)Quad, sizeof (Quad),
- (char *)&Move, sizeof (Move),
- (char *)Event, sizeof (Event),
- 0
+ { (char *)&Ship, sizeof (Ship) },
+ { (char *)&Now, sizeof (Now) },
+ { (char *)&Param, sizeof (Param) },
+ { (char *)&Etc, sizeof (Etc) },
+ { (char *)&Game, sizeof (Game) },
+ { (char *)Sect, sizeof (Sect) },
+ { (char *)Quad, sizeof (Quad) },
+ { (char *)&Move, sizeof (Move) },
+ { (char *)Event, sizeof (Event) },
+ { NULL, 0 }
};
/*
** output change.
*/
-dumpgame()
+/*ARGSUSED*/
+void
+dumpgame(v)
+ int v;
{
- int version;
- register int fd;
- register struct dump *d;
- register int i;
+ int version;
+ int fd;
+ struct dump *d;
+ int i;
- if ((fd = creat("trek.dump", 0644)) < 0)
- return (printf("cannot dump\n"));
+ if ((fd = creat("trek.dump", 0644)) < 0) {
+ warn("cannot open `trek.dump'");
+ return;
+ }
version = VERSION;
write(fd, &version, sizeof version);
** Return value is zero for success, one for failure.
*/
+int
restartgame()
{
- register int fd;
+ int fd;
int version;
if ((fd = open("trek.dump", 0)) < 0 ||
** Returns zero for success, one for failure.
*/
+static int
readdump(fd1)
int fd1;
{
- register int fd;
- register struct dump *d;
- register int i;
- int junk;
+ int fd;
+ struct dump *d;
+ int i;
+ long junk;
fd = fd1;