summaryrefslogtreecommitdiffstats
path: root/hunt/hunt
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>1997-10-11 08:13:40 +0000
committerlukem <lukem@NetBSD.org>1997-10-11 08:13:40 +0000
commit00c616df1fcdefe33be74ec3f41f39b0c3852e5c (patch)
tree8187488c95dae0e421541d7cbc113dd3e6a76eac /hunt/hunt
parent553d721d7a1deaf8fc7b01155b66150ce13f2783 (diff)
downloadbsdgames-darwin-00c616df1fcdefe33be74ec3f41f39b0c3852e5c.tar.gz
bsdgames-darwin-00c616df1fcdefe33be74ec3f41f39b0c3852e5c.tar.zst
bsdgames-darwin-00c616df1fcdefe33be74ec3f41f39b0c3852e5c.zip
use err/warn instead of perror
Diffstat (limited to 'hunt/hunt')
-rw-r--r--hunt/hunt/connect.c10
-rw-r--r--hunt/hunt/hunt.c70
-rw-r--r--hunt/hunt/playit.c11
3 files changed, 39 insertions, 52 deletions
diff --git a/hunt/hunt/connect.c b/hunt/hunt/connect.c
index ae91c2ab..b3fcd7bd 100644
--- a/hunt/hunt/connect.c
+++ b/hunt/hunt/connect.c
@@ -1,4 +1,4 @@
-/* $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
@@ -7,7 +7,7 @@
#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"
@@ -16,9 +16,9 @@ __RCSID("$NetBSD: connect.c,v 1.2 1997/10/10 16:32:23 lukem Exp $");
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;
diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c
index f92f6bf5..b7470590 100644
--- a/hunt/hunt/hunt.c
+++ b/hunt/hunt/hunt.c
@@ -1,4 +1,4 @@
-/* $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
@@ -7,12 +7,13 @@
#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>
@@ -119,14 +120,13 @@ main(ac, av)
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;
@@ -136,7 +136,7 @@ main(ac, av)
# 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
@@ -162,8 +162,7 @@ main(ac, av)
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':
@@ -173,7 +172,7 @@ main(ac, av)
# 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':
@@ -234,10 +233,8 @@ main(ac, av)
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();
@@ -280,19 +277,17 @@ main(ac, av)
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");
}
}
@@ -305,10 +300,8 @@ main(ac, av)
* 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
@@ -320,17 +313,16 @@ main(ac, av)
(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);
}
@@ -433,7 +425,7 @@ list_drivers()
test_socket = socket(SOCK_FAMILY, SOCK_DGRAM, 0);
if (test_socket < 0) {
- perror("socket");
+ warn("socket");
leave(1, "socket system call failed");
/* NOTREACHED */
}
@@ -473,7 +465,7 @@ list_drivers()
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 */
}
@@ -485,7 +477,7 @@ list_drivers()
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 */
}
@@ -535,7 +527,7 @@ get_response:
}
if (errno != 0 && errno != EINTR) {
- perror("select/recvfrom");
+ warn("select/recvfrom");
leave(1, "select/recvfrom");
/* NOTREACHED */
}
@@ -640,14 +632,10 @@ dump_scores(host)
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);
@@ -685,7 +673,7 @@ start_driver()
refresh();
procid = fork();
if (procid == -1) {
- perror("fork");
+ warn("fork");
leave(1, "fork failed.");
}
if (procid == 0) {
diff --git a/hunt/hunt/playit.c b/hunt/hunt/playit.c
index e6776673..5d558aa2 100644
--- a/hunt/hunt/playit.c
+++ b/hunt/hunt/playit.c
@@ -1,4 +1,4 @@
-/* $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
@@ -7,10 +7,11 @@
#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>
@@ -572,10 +573,8 @@ redraw_screen()
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];