X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/3e8dc8d1dd873f0b6b85f088674c80ee18a0e4f6..fd88f5c5678c80ff5e338adc372d28a52ad20530:/usr/src/games/sail/sync.c diff --git a/usr/src/games/sail/sync.c b/usr/src/games/sail/sync.c index 011a32177c..8f8dc7dbb9 100644 --- a/usr/src/games/sail/sync.c +++ b/usr/src/games/sail/sync.c @@ -1,10 +1,43 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #ifndef lint -static char *sccsid = "@(#)sync.c 2.8 85/04/06"; -#endif +static char sccsid[] = "@(#)sync.c 8.2 (Berkeley) 4/28/95"; +#endif /* not lint */ -#include "externs.h" #include -#include +#include +#include "extern.h" #define BUFSIZE 4096 @@ -69,7 +102,7 @@ sync_open() sync_fp = fopen(sync_file, "r+"); if (sync_fp == NULL) return -1; - sync_seek == 0; + sync_seek = 0; return 0; } @@ -104,15 +137,15 @@ Write(type, ship, isstr, a, b, c, d) Sync() { - int (*sig1)(), (*sig2)(); + sig_t sighup, sigint; register n; int type, shipnum, isstr, a, b, c, d; char buf[80]; char erred = 0; extern errno; - sig1 = signal(SIGHUP, SIG_IGN); - sig2 = signal(SIGINT, SIG_IGN); + sighup = signal(SIGHUP, SIG_IGN); + sigint = signal(SIGINT, SIG_IGN); for (n = TIMEOUT; --n >= 0;) { #ifdef LOCK_EX if (flock(fileno(sync_fp), LOCK_EX|LOCK_NB) >= 0) @@ -174,7 +207,8 @@ bad: out: if (!erred && sync_bp != sync_buf) { (void) fseek(sync_fp, 0L, 2); - (void) fputs(sync_buf, sync_fp); + (void) fwrite(sync_buf, sizeof *sync_buf, sync_bp - sync_buf, + sync_fp); (void) fflush(sync_fp); sync_bp = sync_buf; } @@ -184,8 +218,8 @@ out: #else (void) unlink(sync_lock); #endif - (void) signal(SIGHUP, sig1); - (void) signal(SIGINT, sig2); + (void) signal(SIGHUP, sighup); + (void) signal(SIGINT, sigint); return erred ? -1 : 0; } @@ -253,7 +287,10 @@ sync_update(type, ship, a, b, c, d) } case W_SIGNAL: if (mode == MODE_PLAYER) - Signal("\7%s (%c%c): %s", ship, a); + if (nobells) + Signal("%s (%c%c): %s", ship, a); + else + Signal("\7%s (%c%c): %s", ship, a); break; case W_CREW: { register struct shipspecs *s = ship->specs;