| 1 | /* |
| 2 | * Copyright (c) 1982 Regents of the University of California. |
| 3 | * All rights reserved. The Berkeley software License Agreement |
| 4 | * specifies the terms and conditions for redistribution. |
| 5 | */ |
| 6 | |
| 7 | #ifndef lint |
| 8 | static char sccsid[] = "@(#)varpush.c 5.2 (Berkeley) %G%"; |
| 9 | #endif not lint |
| 10 | |
| 11 | # include "mille.h" |
| 12 | |
| 13 | /* |
| 14 | * @(#)varpush.c 1.1 (Berkeley) 4/1/82 |
| 15 | */ |
| 16 | |
| 17 | int read(), write(); |
| 18 | |
| 19 | /* |
| 20 | * push variables around via the routine func() on the file |
| 21 | * channel file. func() is either read or write. |
| 22 | */ |
| 23 | varpush(file, func) |
| 24 | reg int file; |
| 25 | reg int (*func)(); { |
| 26 | |
| 27 | int temp; |
| 28 | |
| 29 | (*func)(file, (char *) &Debug, sizeof Debug); |
| 30 | (*func)(file, (char *) &Finished, sizeof Finished); |
| 31 | (*func)(file, (char *) &Order, sizeof Order); |
| 32 | (*func)(file, (char *) &End, sizeof End); |
| 33 | (*func)(file, (char *) &On_exit, sizeof On_exit); |
| 34 | (*func)(file, (char *) &Handstart, sizeof Handstart); |
| 35 | (*func)(file, (char *) &Numgos, sizeof Numgos); |
| 36 | (*func)(file, (char *) Numseen, sizeof Numseen); |
| 37 | (*func)(file, (char *) &Play, sizeof Play); |
| 38 | (*func)(file, (char *) &Window, sizeof Window); |
| 39 | (*func)(file, (char *) Deck, sizeof Deck); |
| 40 | (*func)(file, (char *) &Discard, sizeof Discard); |
| 41 | (*func)(file, (char *) Player, sizeof Player); |
| 42 | if (func == read) { |
| 43 | read(file, (char *) &temp, sizeof temp); |
| 44 | Topcard = &Deck[temp]; |
| 45 | if (Debug) { |
| 46 | char buf[80]; |
| 47 | over: |
| 48 | printf("Debug file:"); |
| 49 | gets(buf); |
| 50 | if ((outf = fopen(buf, "w")) == NULL) { |
| 51 | perror(buf); |
| 52 | goto over; |
| 53 | } |
| 54 | if (strcmp(buf, "/dev/null") != 0) |
| 55 | setbuf(outf, (char *)NULL); |
| 56 | } |
| 57 | } |
| 58 | else { |
| 59 | temp = Topcard - Deck; |
| 60 | write(file, (char *) &temp, sizeof temp); |
| 61 | } |
| 62 | } |
| 63 | |