exit with sensible code; rm unnecessary uninitialized var access
[unix-history] / usr / src / games / mille / varpush.c
CommitLineData
9329f209
KB
1/*
2 * Copyright (c) 1982 Regents of the University of California.
6ebb4e93
KB
3 * All rights reserved.
4 *
7c5ab767 5 * %sccs.include.redist.c%
9329f209
KB
6 */
7
8#ifndef lint
7c5ab767 9static char sccsid[] = "@(#)varpush.c 5.6 (Berkeley) %G%";
6ebb4e93 10#endif /* not lint */
9329f209 11
a50c78ae 12# include <paths.h>
9329f209
KB
13# include "mille.h"
14
15/*
16 * @(#)varpush.c 1.1 (Berkeley) 4/1/82
17 */
18
19int read(), write();
20
21/*
22 * push variables around via the routine func() on the file
23 * channel file. func() is either read or write.
24 */
25varpush(file, func)
26reg int file;
27reg int (*func)(); {
28
29 int temp;
30
31 (*func)(file, (char *) &Debug, sizeof Debug);
32 (*func)(file, (char *) &Finished, sizeof Finished);
33 (*func)(file, (char *) &Order, sizeof Order);
34 (*func)(file, (char *) &End, sizeof End);
35 (*func)(file, (char *) &On_exit, sizeof On_exit);
36 (*func)(file, (char *) &Handstart, sizeof Handstart);
37 (*func)(file, (char *) &Numgos, sizeof Numgos);
38 (*func)(file, (char *) Numseen, sizeof Numseen);
39 (*func)(file, (char *) &Play, sizeof Play);
40 (*func)(file, (char *) &Window, sizeof Window);
41 (*func)(file, (char *) Deck, sizeof Deck);
42 (*func)(file, (char *) &Discard, sizeof Discard);
43 (*func)(file, (char *) Player, sizeof Player);
44 if (func == read) {
45 read(file, (char *) &temp, sizeof temp);
46 Topcard = &Deck[temp];
6ebb4e93 47#ifdef DEBUG
9329f209
KB
48 if (Debug) {
49 char buf[80];
50over:
51 printf("Debug file:");
52 gets(buf);
53 if ((outf = fopen(buf, "w")) == NULL) {
54 perror(buf);
55 goto over;
56 }
a50c78ae 57 if (strcmp(buf, _PATH_DEVNULL) != 0)
cdc3c16b 58 setbuf(outf, (char *)NULL);
9329f209 59 }
6ebb4e93 60#endif
9329f209
KB
61 }
62 else {
63 temp = Topcard - Deck;
64 write(file, (char *) &temp, sizeof temp);
65 }
66}