summaryrefslogtreecommitdiff
path: root/games/trek/dumpgame.c
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>1998-08-19 07:42:28 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>1998-08-19 07:42:28 +0000
commited884b9fa4509c09f0f7ab71efe57a4e83a2e055 (patch)
treeef9d859a0754785b42ea5cacb27aff54b5000315 /games/trek/dumpgame.c
parentf4fc9566a4d35c0cc2bf8c7f1136287d8eec8c44 (diff)
tags, formatting, ANSI-fication, prototypes, de-typos, and the occasional
initialization, removal of unused variable, or other minor fix. Most changes are from or inspired by NetBSD.
Diffstat (limited to 'games/trek/dumpgame.c')
-rw-r--r--games/trek/dumpgame.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/games/trek/dumpgame.c b/games/trek/dumpgame.c
index 17e7e7a19eb..c8344f31506 100644
--- a/games/trek/dumpgame.c
+++ b/games/trek/dumpgame.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: dumpgame.c,v 1.2 1998/08/19 07:41:29 pjanzen Exp $ */
/* $NetBSD: dumpgame.c,v 1.4 1995/04/24 12:25:54 cgd Exp $ */
/*
@@ -37,11 +38,15 @@
#if 0
static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: dumpgame.c,v 1.4 1995/04/24 12:25:54 cgd Exp $";
+static char rcsid[] = "$OpenBSD: dumpgame.c,v 1.2 1998/08/19 07:41:29 pjanzen 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
@@ -55,18 +60,20 @@ struct dump
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 }
};
+static int readdump __P((int));
+
/*
** DUMP GAME
**
@@ -77,7 +84,9 @@ struct dump Dump_template[] =
** output change.
*/
-dumpgame()
+void
+dumpgame(v)
+ int v;
{
int version;
register int fd;
@@ -85,7 +94,10 @@ dumpgame()
register int i;
if ((fd = creat("trek.dump", 0644)) < 0)
- return (printf("cannot dump\n"));
+ {
+ warn("cannot open `trek.dump'");
+ return;
+ }
version = VERSION;
write(fd, &version, sizeof version);
@@ -112,6 +124,7 @@ dumpgame()
** Return value is zero for success, one for failure.
*/
+int
restartgame()
{
register int fd;
@@ -141,8 +154,9 @@ restartgame()
** Returns zero for success, one for failure.
*/
+static int
readdump(fd1)
-int fd1;
+ int fd1;
{
register int fd;
register struct dump *d;