1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32: #include <sys/cdefs.h>
33: #ifndef lint
34: #if 0
35: static char sccsid[] = "@(#)varpush.c 8.1 (Berkeley) 5/31/93";
36: #else
37: __RCSID("$NetBSD: varpush.c,v 1.8 2004/01/27 20:30:30 jsm Exp $");
38: #endif
39: #endif
40:
41: # include <paths.h>
42: # include "mille.h"
43:
44:
45:
46:
47:
48:
49:
50:
51:
52: bool
53: varpush(file, func)
54: int file;
55: #if defined(__linux__) && !defined(__GLIBC__)
56: ssize_t (*func)(int, const struct iovec *, size_t);
57: #else
58: ssize_t (*func)(int, const struct iovec *, int);
59: #endif
60: {
61: int temp;
62: const struct iovec vec[] = {
63: { (void *) &Debug, sizeof Debug },
64: { (void *) &Finished, sizeof Finished },
65: { (void *) &Order, sizeof Order },
66: { (void *) &End, sizeof End },
67: { (void *) &On_exit, sizeof On_exit },
68: { (void *) &Handstart, sizeof Handstart },
69: { (void *) &Numgos, sizeof Numgos },
70: { (void *) Numseen, sizeof Numseen },
71: { (void *) &Play, sizeof Play },
72: { (void *) &Window, sizeof Window },
73: { (void *) Deck, sizeof Deck },
74: { (void *) &Discard, sizeof Discard },
75: { (void *) Player, sizeof Player }
76: };
77:
78: if (((func)(file, vec, sizeof(vec) / sizeof(vec[0]))) < 0) {
79: error(strerror(errno));
80: return FALSE;
81: }
82: if (func == readv) {
83: if ((read(file, (void *) &temp, sizeof temp)) < 0) {
84: error(strerror(errno));
85: return FALSE;
86: }
87: Topcard = &Deck[temp];
88: #ifdef DEBUG
89: if (Debug) {
90: char buf[80];
91: over:
92: printf("Debug file:");
93: gets(buf);
94: if ((outf = fopen(buf, "w")) == NULL) {
95: warn("%s", buf);
96: goto over;
97: }
98: if (strcmp(buf, _PATH_DEVNULL) != 0)
99: setbuf(outf, (char *)NULL);
100: }
101: #endif
102: } else {
103: temp = Topcard - Deck;
104: if ((write(file, (void *) &temp, sizeof temp)) < 0) {
105: error(strerror(errno));
106: return FALSE;
107: }
108: }
109: return TRUE;
110: }