]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
use err/warn instead of perror
authorlukem <lukem@NetBSD.org>
Sat, 11 Oct 1997 08:13:40 +0000 (08:13 +0000)
committerlukem <lukem@NetBSD.org>
Sat, 11 Oct 1997 08:13:40 +0000 (08:13 +0000)
hunt/hunt/connect.c
hunt/hunt/hunt.c
hunt/hunt/playit.c
hunt/huntd/driver.c
hunt/huntd/faketalk.c
hunt/huntd/shots.c
hunt/huntd/talk_ctl.h

index ae91c2abe7ba65f4b0c35d1f358692e06d40021a..b3fcd7bd95e2ff616089064ba764ae9f67e296b7 100644 (file)
@@ -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;
index f92f6bf505a0aca870e2c3e4808e851cbe53ffbc..b747059028de3aadb48f95b52f71fbf6f4e0ec15 100644 (file)
@@ -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) {
index e67766734c711f5725d5c1395012f3eafef242ce..5d558aa2199f2f65904468d168f1b2659eb5e416 100644 (file)
@@ -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];
index 1f3b47a376ad86351d20b8162fb067e5a3b935a1..2f8bdff2a92c2e00aa5a29360b8a9e8a1238f724 100644 (file)
@@ -1,4 +1,4 @@
-/*     $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
@@ -7,7 +7,7 @@
 
 #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>
@@ -117,7 +117,7 @@ again:
 # ifdef LOG
                                syslog(LOG_WARNING, "select: %m");
 # else
-                               perror("select");
+                               warn("select");
 # endif
                        errno = 0;
                }
@@ -295,7 +295,7 @@ init()
 # ifdef LOG
                        syslog(LOG_ERR, "bind: %m");
 # else
-                       perror("bind");
+                       warn("bind");
 # endif
                        cleanup(1);
                }
@@ -308,7 +308,7 @@ init()
 # ifdef LOG
                syslog(LOG_ERR, "getsockname: %m");
 # else
-               perror("getsockname");
+               warn("getsockname");
 # endif
                exit(1);
        }
@@ -334,7 +334,7 @@ init()
 # 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) {
@@ -344,7 +344,7 @@ init()
 # ifdef LOG
                        syslog(LOG_ERR, "bind: %m");
 # else
-                       perror("bind");
+                       warn("bind");
 # endif
                        cleanup(1);
                }
@@ -357,7 +357,7 @@ init()
 # ifdef LOG
                syslog(LOG_ERR, "getsockname: %m");
 # else
-               perror("getsockname");
+               warn("getsockname");
 # endif
                exit(1);
        }
@@ -391,7 +391,7 @@ init()
 # ifdef LOG
                        syslog(LOG_ERR, "bind: %m");
 # else
-                       perror("bind");
+                       warn("bind");
 # endif
                        exit(1);
                }
@@ -910,7 +910,7 @@ send_stats()
 # ifdef LOG
                syslog(LOG_ERR, "accept: %m");
 # else
-               perror("accept");
+               warn("accept");
 # endif
                return;
        }
@@ -919,7 +919,7 @@ send_stats()
 # ifdef LOG
                syslog(LOG_ERR, "fdopen: %m");
 # else
-               perror("fdopen");
+               warn("fdopen");
 # endif
                (void) close(s);
                return;
index e594b12e9f57baa71ad0bc103e2d22e7062042e8..2044ce1ddf15e130ddaf3a562e54e09be7ae8b92 100644 (file)
@@ -1,4 +1,4 @@
-/*     $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
@@ -11,7 +11,7 @@
 
 #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"
@@ -107,7 +107,7 @@ faketalk()
 # 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);
        }
@@ -121,7 +121,7 @@ faketalk()
 # ifdef LOG
                syslog(LOG_ERR, "falktalk:  socket");
 # else
-               perror("falktalk:  socket");
+               warn("falktalk:  socket");
 # endif
                _exit(-1);
        }
@@ -130,7 +130,7 @@ faketalk()
 # ifdef LOG
                syslog(LOG_ERR, "faketalk:  connect");
 # else
-               perror("faketalk:  connect");
+               warn("faketalk:  connect");
 # endif
                _exit(-1);
        }
@@ -138,7 +138,7 @@ faketalk()
 # ifdef LOG
                syslog(LOG_ERR, "fdopen failed\n");
 # else
-               fprintf(stderr, "fdopen failed\n");
+               warn("faketalk:  fdopen");
 # endif
                _exit(-2);
        }
index d0dfcf903fe55b0e85e19ea817c70a8bdd759e05..b4080dbd76c3e01e3eabacbca61ee72f3b76f3a8 100644 (file)
@@ -1,4 +1,4 @@
-/*     $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
@@ -7,9 +7,10 @@
 
 #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"
@@ -1018,8 +1019,7 @@ play_at(y, x)
        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 */
 }
 
index 59071ec330075484c21f0f719f9a384efeb02d6b..f8081b8373d438685a1f257b97f82e67c71397cb 100644 (file)
@@ -74,7 +74,7 @@ extern        CTL_MSG msg;
 #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 *));