+/*
+ * 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 <sys/file.h>
-#include <sys/errno.h>
+#include <errno.h>
+#include "extern.h"
#define BUFSIZE 4096
sync_fp = fopen(sync_file, "r+");
if (sync_fp == NULL)
return -1;
- sync_seek == 0;
+ sync_seek = 0;
return 0;
}
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)
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;
}
#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;
}
}
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;