-/* $NetBSD: connect.c,v 1.2 1997/10/10 16:32:23 lukem Exp $ */
+/* $NetBSD: connect.c,v 1.3 1997/10/11 08:13:40 lukem Exp $ */
/*
* Hunt
* Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: connect.c,v 1.2 1997/10/10 16:32:23 lukem Exp $");
+__RCSID("$NetBSD: connect.c,v 1.3 1997/10/11 08:13:40 lukem Exp $");
#endif /* not lint */
# include "hunt.h"
void
do_connect(name, team, enter_status)
-char *name;
-char team;
-long enter_status;
+ char *name;
+ char team;
+ long enter_status;
{
static long uid;
static long mode;
-/* $NetBSD: hunt.c,v 1.2 1997/10/10 16:32:34 lukem Exp $ */
+/* $NetBSD: hunt.c,v 1.3 1997/10/11 08:13:41 lukem Exp $ */
/*
* Hunt
* Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hunt.c,v 1.2 1997/10/10 16:32:34 lukem Exp $");
+__RCSID("$NetBSD: hunt.c,v 1.3 1997/10/11 08:13:41 lukem Exp $");
#endif /* not lint */
# include <sys/stat.h>
# include <sys/time.h>
# include <ctype.h>
+# include <err.h>
# include <errno.h>
# include <curses.h>
# include <signal.h>
case 't':
team = *optarg;
if (!isdigit(team)) {
- fprintf(stderr, "Team names must be numeric\n");
+ warnx("Team names must be numeric");
team = ' ';
}
break;
case 'o':
# ifndef OTTO
- fputs("The -o flag is reserved for future use.\n",
- stderr);
+ warnx("The -o flag is reserved for future use.");
goto usage;
# else
Otto_mode = TRUE;
# ifdef MONITOR
Am_monitor = TRUE;
# else
- fputs("The monitor was not compiled in.\n", stderr);
+ warnx("The monitor was not compiled in.");
# endif
break;
# ifdef INTERNET
case 'w':
case 'h':
case 'p':
- fputs("Need TCP/IP for S, q, w, h, and p options.\n",
- stderr);
+ wanrx("Need TCP/IP for S, q, w, h, and p options.");
break;
# endif
case 'c':
# ifdef FLY
enter_status = Q_FLY;
# else
- fputs("The flying code was not compiled in.\n", stderr);
+ warnx("The flying code was not compiled in.");
# endif
break;
case 's':
fill_in_blanks();
(void) fflush(stdout);
- if (!isatty(0) || (term = getenv("TERM")) == NULL) {
- fprintf(stderr, "no terminal type\n");
- exit(1);
- }
+ if (!isatty(0) || (term = getenv("TERM")) == NULL)
+ errx(1, "no terminal type");
# ifdef USE_CURSES
initscr();
(void) noecho();
int option;
Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0);
- if (Socket < 0) {
- perror("socket");
- exit(1);
- }
+ if (Socket < 0)
+ err(1, "socket");
option = 1;
if (setsockopt(Socket, SOL_SOCKET, SO_USELOOPBACK,
&option, sizeof option) < 0)
- perror("setsockopt loopback");
+ warn("setsockopt loopback");
errno = 0;
if (connect(Socket, (struct sockaddr *) &Daemon,
DAEMON_SIZE) < 0) {
if (errno != ECONNREFUSED) {
- perror("connect");
+ warn("connect");
leave(1, "connect");
}
}
* set up a socket
*/
- if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0) {
- perror("socket");
- exit(1);
- }
+ if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0)
+ err(1, "socket");
/*
* attempt to connect the socket to a name; if it fails that
(void) strcpy(Daemon.sun_path, Sock_name);
if (connect(Socket, &Daemon, DAEMON_SIZE) < 0) {
if (errno != ENOENT) {
- perror("connect");
+ warn("connect");
leave(1, "connect2");
}
start_driver();
do {
(void) close(Socket);
- if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0) {
- perror("socket");
- exit(1);
- }
+ if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM,
+ 0)) < 0)
+ err(1, "socket");
sleep(2);
} while (connect(Socket, &Daemon, DAEMON_SIZE) < 0);
}
test_socket = socket(SOCK_FAMILY, SOCK_DGRAM, 0);
if (test_socket < 0) {
- perror("socket");
+ warn("socket");
leave(1, "socket system call failed");
/* NOTREACHED */
}
option = 1;
if (setsockopt(test_socket, SOL_SOCKET, SO_BROADCAST,
&option, sizeof option) < 0) {
- perror("setsockopt broadcast");
+ warn("setsockopt broadcast");
leave(1, "setsockopt broadcast");
/* NOTREACHED */
}
test.sin_addr = brdv[i].sin_addr;
if (sendto(test_socket, (char *) &msg, sizeof msg, 0,
(struct sockaddr *) &test, DAEMON_SIZE) < 0) {
- perror("sendto");
+ warn("sendto");
leave(1, "sendto");
/* NOTREACHED */
}
}
if (errno != 0 && errno != EINTR) {
- perror("select/recvfrom");
+ warn("select/recvfrom");
leave(1, "select/recvfrom");
/* NOTREACHED */
}
fflush(stdout);
s = socket(SOCK_FAMILY, SOCK_STREAM, 0);
- if (s < 0) {
- perror("socket");
- exit(1);
- }
- if (connect(s, (struct sockaddr *) &host, sizeof host) < 0) {
- perror("connect");
- exit(1);
- }
+ if (s < 0)
+ err(1, "socket");
+ if (connect(s, (struct sockaddr *) &host, sizeof host) < 0)
+ err(1, "connect");
while ((cnt = read(s, buf, BUFSIZ)) > 0)
write(fileno(stdout), buf, cnt);
(void) close(s);
refresh();
procid = fork();
if (procid == -1) {
- perror("fork");
+ warn("fork");
leave(1, "fork failed.");
}
if (procid == 0) {
-/* $NetBSD: playit.c,v 1.2 1997/10/10 16:32:43 lukem Exp $ */
+/* $NetBSD: playit.c,v 1.3 1997/10/11 08:13:44 lukem Exp $ */
/*
* Hunt
* Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: playit.c,v 1.2 1997/10/10 16:32:43 lukem Exp $");
+__RCSID("$NetBSD: playit.c,v 1.3 1997/10/11 08:13:44 lukem Exp $");
#endif /* not lint */
# include <sys/file.h>
+# include <err.h>
# include <errno.h>
# include <curses.h>
# include <ctype.h>
if (first) {
curscr = newwin(SCREEN_HEIGHT, SCREEN_WIDTH, 0, 0);
- if (curscr == NULL) {
- fprintf(stderr, "Can't create curscr\n");
- exit(1);
- }
+ if (curscr == NULL)
+ errx(1, "Can't create curscr");
# if !defined(BSD_RELEASE) || BSD_RELEASE < 44
for (i = 0; i < SCREEN_HEIGHT; i++)
curscr->_y[i] = screen[i];
-/* $NetBSD: driver.c,v 1.2 1997/10/10 16:33:08 lukem Exp $ */
+/* $NetBSD: driver.c,v 1.3 1997/10/11 08:13:47 lukem Exp $ */
/*
* Hunt
* Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: driver.c,v 1.2 1997/10/10 16:33:08 lukem Exp $");
+__RCSID("$NetBSD: driver.c,v 1.3 1997/10/11 08:13:47 lukem Exp $");
#endif /* not lint */
# include <sys/ioctl.h>
# ifdef LOG
syslog(LOG_WARNING, "select: %m");
# else
- perror("select");
+ warn("select");
# endif
errno = 0;
}
# ifdef LOG
syslog(LOG_ERR, "bind: %m");
# else
- perror("bind");
+ warn("bind");
# endif
cleanup(1);
}
# ifdef LOG
syslog(LOG_ERR, "getsockname: %m");
# else
- perror("getsockname");
+ warn("getsockname");
# endif
exit(1);
}
# ifdef LOG
syslog(LOG_WARNING, "setsockopt loopback %m");
# else
- perror("setsockopt loopback");
+ warn("setsockopt loopback");
# endif
# endif
if (bind(Socket, (struct sockaddr *) &Daemon, DAEMON_SIZE) < 0) {
# ifdef LOG
syslog(LOG_ERR, "bind: %m");
# else
- perror("bind");
+ warn("bind");
# endif
cleanup(1);
}
# ifdef LOG
syslog(LOG_ERR, "getsockname: %m");
# else
- perror("getsockname");
+ warn("getsockname");
# endif
exit(1);
}
# ifdef LOG
syslog(LOG_ERR, "bind: %m");
# else
- perror("bind");
+ warn("bind");
# endif
exit(1);
}
# ifdef LOG
syslog(LOG_ERR, "accept: %m");
# else
- perror("accept");
+ warn("accept");
# endif
return;
}
# ifdef LOG
syslog(LOG_ERR, "fdopen: %m");
# else
- perror("fdopen");
+ warn("fdopen");
# endif
(void) close(s);
return;
-/* $NetBSD: faketalk.c,v 1.3 1997/10/10 16:33:31 lukem Exp $ */
+/* $NetBSD: faketalk.c,v 1.4 1997/10/11 08:13:48 lukem Exp $ */
/*
* Hunt
* Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: faketalk.c,v 1.3 1997/10/10 16:33:31 lukem Exp $");
+__RCSID("$NetBSD: faketalk.c,v 1.4 1997/10/11 08:13:48 lukem Exp $");
#endif /* not lint */
#include "bsd.h"
# ifdef LOG
syslog(LOG_ERR, "faketalk: smtp protocol not supported\n");
# else
- fprintf(stderr, "faketalk: stmp protocol not supported\n");
+ warn("faketalk: stmp protocol not supported");
# endif
_exit(1);
}
# ifdef LOG
syslog(LOG_ERR, "falktalk: socket");
# else
- perror("falktalk: socket");
+ warn("falktalk: socket");
# endif
_exit(-1);
}
# ifdef LOG
syslog(LOG_ERR, "faketalk: connect");
# else
- perror("faketalk: connect");
+ warn("faketalk: connect");
# endif
_exit(-1);
}
# ifdef LOG
syslog(LOG_ERR, "fdopen failed\n");
# else
- fprintf(stderr, "fdopen failed\n");
+ warn("faketalk: fdopen");
# endif
_exit(-2);
}
-/* $NetBSD: shots.c,v 1.2 1997/10/10 16:33:54 lukem Exp $ */
+/* $NetBSD: shots.c,v 1.3 1997/10/11 08:13:50 lukem Exp $ */
/*
* Hunt
* Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: shots.c,v 1.2 1997/10/10 16:33:54 lukem Exp $");
+__RCSID("$NetBSD: shots.c,v 1.3 1997/10/11 08:13:50 lukem Exp $");
#endif /* not lint */
+# include <err.h>
# include <signal.h>
# include <stdlib.h>
# include "hunt.h"
for (pp = Player; pp < End_player; pp++)
if (pp->p_x == x && pp->p_y == y)
return pp;
- fprintf(stderr, "driver: couldn't find player at (%d,%d)\n", x, y);
- abort();
+ errx(1, "driver: couldn't find player at (%d,%d)", x, y);
/* NOTREACHED */
}
#ifdef LOG
#define p_error(str) syslog(LOG_WARNING, "faketalk %s: %m", str)
#else
-#define p_error(str) perror(str)
+#define p_error(str) warn(str)
#endif
void ctl_transact __P((struct in_addr, CTL_MSG, int, CTL_RESPONSE *));