-/* $NetBSD: save.c,v 1.4 1997/10/11 01:53:33 lukem Exp $ */
+/* $NetBSD: save.c,v 1.9 2005/07/01 00:03:36 jmc Exp $ */
/*-
* Copyright (c) 1991, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: save.c,v 1.4 1997/10/11 01:53:33 lukem Exp $");
+__RCSID("$NetBSD: save.c,v 1.9 2005/07/01 00:03:36 jmc Exp $");
#endif
#endif /* not lint */
+#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include "hdr.h"
{&oldlc2, sizeof(oldlc2)},
{&oldloc, sizeof(oldloc)},
{&panic, sizeof(panic)},
- {&saved, sizeof(saved)},
+ {&saveday, sizeof(saveday)},
{&savet, sizeof(savet)},
{&scorng, sizeof(scorng)},
{&spk, sizeof(spk)},
{NULL, 0}
};
+/* Two passes on data: first to get checksum, second */
+/* to output the data using checksum to start random #s */
int
-save(outfile) /* Two passes on data: first to get checksum,
- * second */
- char *outfile; /* to output the data using checksum to start
- * random #s */
+save(const char *outfile)
{
FILE *out;
struct savestruct *p;
*s = (*s ^ random()) & 0xFF; /* Lightly encrypt */
fwrite(p->address, p->width, 1, out);
}
- fclose(out);
+ if (fclose(out) != 0) {
+ warn("writing %s", outfile);
+ return 1;
+ }
return 0;
}
int
-restore(infile)
- char *infile;
+restore(const char *infile)
{
FILE *in;
struct savestruct *p;