varpush.c revision 1.4
1/* $NetBSD: varpush.c,v 1.4 1995/03/24 05:02:35 cgd Exp $ */ 2 3/* 4 * Copyright (c) 1982, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by the University of 18 * California, Berkeley and its contributors. 19 * 4. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 */ 35 36#ifndef lint 37#if 0 38static char sccsid[] = "@(#)varpush.c 8.1 (Berkeley) 5/31/93"; 39#else 40static char rcsid[] = "$NetBSD: varpush.c,v 1.4 1995/03/24 05:02:35 cgd Exp $"; 41#endif 42#endif /* not lint */ 43 44# include <paths.h> 45# include "mille.h" 46 47/* 48 * @(#)varpush.c 1.1 (Berkeley) 4/1/82 49 */ 50 51int read(), write(); 52 53/* 54 * push variables around via the routine func() on the file 55 * channel file. func() is either read or write. 56 */ 57varpush(file, func) 58reg int file; 59reg int (*func)(); { 60 61 int temp; 62 63 (*func)(file, (char *) &Debug, sizeof Debug); 64 (*func)(file, (char *) &Finished, sizeof Finished); 65 (*func)(file, (char *) &Order, sizeof Order); 66 (*func)(file, (char *) &End, sizeof End); 67 (*func)(file, (char *) &On_exit, sizeof On_exit); 68 (*func)(file, (char *) &Handstart, sizeof Handstart); 69 (*func)(file, (char *) &Numgos, sizeof Numgos); 70 (*func)(file, (char *) Numseen, sizeof Numseen); 71 (*func)(file, (char *) &Play, sizeof Play); 72 (*func)(file, (char *) &Window, sizeof Window); 73 (*func)(file, (char *) Deck, sizeof Deck); 74 (*func)(file, (char *) &Discard, sizeof Discard); 75 (*func)(file, (char *) Player, sizeof Player); 76 if (func == read) { 77 read(file, (char *) &temp, sizeof temp); 78 Topcard = &Deck[temp]; 79#ifdef DEBUG 80 if (Debug) { 81 char buf[80]; 82over: 83 printf("Debug file:"); 84 gets(buf); 85 if ((outf = fopen(buf, "w")) == NULL) { 86 perror(buf); 87 goto over; 88 } 89 if (strcmp(buf, _PATH_DEVNULL) != 0) 90 setbuf(outf, (char *)NULL); 91 } 92#endif 93 } 94 else { 95 temp = Topcard - Deck; 96 write(file, (char *) &temp, sizeof temp); 97 } 98} 99