Commit | Line | Data |
---|---|---|
9329f209 KB |
1 | /* |
2 | * Copyright (c) 1982 Regents of the University of California. | |
6ebb4e93 KB |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
65c7d3b6 KB |
6 | * provided that the above copyright notice and this paragraph are |
7 | * duplicated in all such forms and that any documentation, | |
8 | * advertising materials, and other materials related to such | |
9 | * distribution and use acknowledge that the software was developed | |
10 | * by the University of California, Berkeley. The name of the | |
11 | * University may not be used to endorse or promote products derived | |
12 | * from this software without specific prior written permission. | |
13 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
14 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
15 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
9329f209 KB |
16 | */ |
17 | ||
18 | #ifndef lint | |
65c7d3b6 | 19 | static char sccsid[] = "@(#)varpush.c 5.4 (Berkeley) %G%"; |
6ebb4e93 | 20 | #endif /* not lint */ |
9329f209 KB |
21 | |
22 | # include "mille.h" | |
23 | ||
24 | /* | |
25 | * @(#)varpush.c 1.1 (Berkeley) 4/1/82 | |
26 | */ | |
27 | ||
28 | int read(), write(); | |
29 | ||
30 | /* | |
31 | * push variables around via the routine func() on the file | |
32 | * channel file. func() is either read or write. | |
33 | */ | |
34 | varpush(file, func) | |
35 | reg int file; | |
36 | reg int (*func)(); { | |
37 | ||
38 | int temp; | |
39 | ||
40 | (*func)(file, (char *) &Debug, sizeof Debug); | |
41 | (*func)(file, (char *) &Finished, sizeof Finished); | |
42 | (*func)(file, (char *) &Order, sizeof Order); | |
43 | (*func)(file, (char *) &End, sizeof End); | |
44 | (*func)(file, (char *) &On_exit, sizeof On_exit); | |
45 | (*func)(file, (char *) &Handstart, sizeof Handstart); | |
46 | (*func)(file, (char *) &Numgos, sizeof Numgos); | |
47 | (*func)(file, (char *) Numseen, sizeof Numseen); | |
48 | (*func)(file, (char *) &Play, sizeof Play); | |
49 | (*func)(file, (char *) &Window, sizeof Window); | |
50 | (*func)(file, (char *) Deck, sizeof Deck); | |
51 | (*func)(file, (char *) &Discard, sizeof Discard); | |
52 | (*func)(file, (char *) Player, sizeof Player); | |
53 | if (func == read) { | |
54 | read(file, (char *) &temp, sizeof temp); | |
55 | Topcard = &Deck[temp]; | |
6ebb4e93 | 56 | #ifdef DEBUG |
9329f209 KB |
57 | if (Debug) { |
58 | char buf[80]; | |
59 | over: | |
60 | printf("Debug file:"); | |
61 | gets(buf); | |
62 | if ((outf = fopen(buf, "w")) == NULL) { | |
63 | perror(buf); | |
64 | goto over; | |
65 | } | |
66 | if (strcmp(buf, "/dev/null") != 0) | |
cdc3c16b | 67 | setbuf(outf, (char *)NULL); |
9329f209 | 68 | } |
6ebb4e93 | 69 | #endif |
9329f209 KB |
70 | } |
71 | else { | |
72 | temp = Topcard - Deck; | |
73 | write(file, (char *) &temp, sizeof temp); | |
74 | } | |
75 | } |