summaryrefslogtreecommitdiffstats
path: root/hunt/hunt
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2014-03-29 21:24:26 +0000
committerdholland <dholland@NetBSD.org>2014-03-29 21:24:26 +0000
commitd6724a84e4ba41305086422afc071d9c8b92c09b (patch)
treec457518bb9f57b190abf81fec13cb6c911aacdf2 /hunt/hunt
parent32a54d49158271df4ffa0cf4422f612647973022 (diff)
downloadbsdgames-darwin-d6724a84e4ba41305086422afc071d9c8b92c09b.tar.gz
bsdgames-darwin-d6724a84e4ba41305086422afc071d9c8b92c09b.tar.zst
bsdgames-darwin-d6724a84e4ba41305086422afc071d9c8b92c09b.zip
Split hunt and huntd's includes, instead of incestuously sharing a pile
of external data and function declarations between the two programs. Common constants and defines now go in hunt_common.h. Stuff that belongs only to hunt is in hunt/hunt_private.h. Stuff that belongs only to huntd is in huntd/hunt.h. Copy some declarations that are used in both programs under the same names (but are not actually the same objects) from huntd/hunt.h to hunt/hunt_private.h. Move others that are only used in hunt. Remove some entirely unused material, and tidy up standard includes.
Diffstat (limited to 'hunt/hunt')
-rw-r--r--hunt/hunt/Makefile8
-rw-r--r--hunt/hunt/connect.c9
-rw-r--r--hunt/hunt/hunt.c17
-rw-r--r--hunt/hunt/hunt_private.h97
-rw-r--r--hunt/hunt/otto.c9
-rw-r--r--hunt/hunt/playit.c9
6 files changed, 132 insertions, 17 deletions
diff --git a/hunt/hunt/Makefile b/hunt/hunt/Makefile
index 72c34768..2279cc19 100644
--- a/hunt/hunt/Makefile
+++ b/hunt/hunt/Makefile
@@ -1,14 +1,12 @@
-# $NetBSD: Makefile,v 1.7 2010/02/06 23:45:25 he Exp $
+# $NetBSD: Makefile,v 1.8 2014/03/29 21:24:26 dholland Exp $
PROG= hunt
-SRCS= connect.c hunt.c otto.c playit.c pathname.c
+SRCS= connect.c hunt.c otto.c playit.c
MAN= hunt.6
LDADD= -lcurses -lterminfo
DPADD= ${LIBCURSES} ${LIBTERMINFO}
HIDEGAME=hidegame
-CPPFLAGS+=-I${.CURDIR}/../huntd
-
-.PATH: ${.CURDIR}/../huntd
+CPPFLAGS+=-I${.CURDIR}/../include
.include <bsd.prog.mk>
diff --git a/hunt/hunt/connect.c b/hunt/hunt/connect.c
index 8f86bcd8..f1d35334 100644
--- a/hunt/hunt/connect.c
+++ b/hunt/hunt/connect.c
@@ -1,4 +1,4 @@
-/* $NetBSD: connect.c,v 1.8 2009/07/04 05:01:16 dholland Exp $ */
+/* $NetBSD: connect.c,v 1.9 2014/03/29 21:24:26 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,13 +32,16 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: connect.c,v 1.8 2009/07/04 05:01:16 dholland Exp $");
+__RCSID("$NetBSD: connect.c,v 1.9 2014/03/29 21:24:26 dholland Exp $");
#endif /* not lint */
-#include "hunt.h"
+#include <string.h>
#include <signal.h>
#include <unistd.h>
+#include "hunt_common.h"
+#include "hunt_private.h"
+
void
do_connect(char *name, char team, long enter_status)
{
diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c
index 6f1cab08..61838fdf 100644
--- a/hunt/hunt/hunt.c
+++ b/hunt/hunt/hunt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt.c,v 1.43 2014/03/29 20:53:55 dholland Exp $ */
+/* $NetBSD: hunt.c,v 1.44 2014/03/29 21:24:26 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: hunt.c,v 1.43 2014/03/29 20:53:55 dholland Exp $");
+__RCSID("$NetBSD: hunt.c,v 1.44 2014/03/29 21:24:26 dholland Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -49,12 +49,23 @@ __RCSID("$NetBSD: hunt.c,v 1.43 2014/03/29 20:53:55 dholland Exp $");
#include <unistd.h>
#include <ifaddrs.h>
-#include "hunt.h"
+#include "hunt_common.h"
+#include "hunt_private.h"
#define clear_eol() clrtoeol()
#define put_ch addch
#define put_str addstr
+#ifdef DEBUG
+char *Driver = "/home/socr/a/conrad/games/src/hunt/huntd.dbg";
+#else
+const char *Driver = HUNTD;
+#endif
+
+#ifdef INTERNET
+u_short Test_port = TEST_PORT;
+#endif
+
bool Last_player = false;
#ifdef MONITOR
bool Am_monitor = false;
diff --git a/hunt/hunt/hunt_private.h b/hunt/hunt/hunt_private.h
new file mode 100644
index 00000000..58a299c1
--- /dev/null
+++ b/hunt/hunt/hunt_private.h
@@ -0,0 +1,97 @@
+/* $NetBSD: hunt_private.h,v 1.1 2014/03/29 21:24:26 dholland Exp $ */
+
+/*
+ * Copyright (c) 1983-2003, 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:
+ *
+ * + Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * + 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.
+ * + Neither the name of the University of California, San Francisco 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 COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ */
+
+#include <stdbool.h>
+#include <stdio.h> /* for BUFSIZ */
+
+#ifdef INTERNET
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+#else
+#include <sys/un.h>
+#endif
+
+#ifdef MONITOR
+#define C_TESTMSG() (Query_driver ? C_MESSAGE :\
+ (Show_scores ? C_SCORES :\
+ (Am_monitor ? C_MONITOR :\
+ C_PLAYER)))
+#else
+#define C_TESTMSG() (Show_scores ? C_SCORES :\
+ (Query_driver ? C_MESSAGE :\
+ C_PLAYER))
+#endif
+
+/*
+ * external variables
+ */
+
+extern bool Last_player;
+
+extern const char *Driver;
+
+extern char Buf[BUFSIZ];
+extern int Socket;
+
+#ifdef INTERNET
+extern u_short Test_port;
+#else
+extern char *Sock_name;
+#endif
+
+#ifdef INTERNET
+extern char *Send_message;
+#endif
+
+#ifdef MONITOR
+extern bool Am_monitor;
+#endif
+
+extern char map_key[256];
+extern bool no_beep;
+
+/*
+ * function types
+ */
+
+void bad_con(void) __dead;
+void bad_ver(void) __dead;
+void clear_the_screen(void);
+void do_connect(char *, char, long);
+void do_message(void);
+void otto(int, int, char);
+void playit(void);
+int quit(int);
+void intr(int);
diff --git a/hunt/hunt/otto.c b/hunt/hunt/otto.c
index 09032346..de5ef41b 100644
--- a/hunt/hunt/otto.c
+++ b/hunt/hunt/otto.c
@@ -1,4 +1,4 @@
-/* $NetBSD: otto.c,v 1.16 2014/03/29 20:52:13 dholland Exp $ */
+/* $NetBSD: otto.c,v 1.17 2014/03/29 21:24:26 dholland Exp $ */
#ifdef OTTO
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@@ -45,7 +45,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: otto.c,v 1.16 2014/03/29 20:52:13 dholland Exp $");
+__RCSID("$NetBSD: otto.c,v 1.17 2014/03/29 21:24:26 dholland Exp $");
#endif /* not lint */
#include <sys/time.h>
@@ -53,8 +53,11 @@ __RCSID("$NetBSD: otto.c,v 1.16 2014/03/29 20:52:13 dholland Exp $");
#include <ctype.h>
#include <signal.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-#include "hunt.h"
+
+#include "hunt_common.h"
+#include "hunt_private.h"
#undef WALL
#undef NORTH
diff --git a/hunt/hunt/playit.c b/hunt/hunt/playit.c
index 80c46324..4f52131c 100644
--- a/hunt/hunt/playit.c
+++ b/hunt/hunt/playit.c
@@ -1,4 +1,4 @@
-/* $NetBSD: playit.c,v 1.17 2014/03/29 20:52:13 dholland Exp $ */
+/* $NetBSD: playit.c,v 1.18 2014/03/29 21:24:26 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: playit.c,v 1.17 2014/03/29 20:52:13 dholland Exp $");
+__RCSID("$NetBSD: playit.c,v 1.18 2014/03/29 21:24:26 dholland Exp $");
#endif /* not lint */
#include <sys/file.h>
@@ -42,9 +42,12 @@ __RCSID("$NetBSD: playit.c,v 1.17 2014/03/29 20:52:13 dholland Exp $");
#include <curses.h>
#include <ctype.h>
#include <signal.h>
+#include <string.h>
#include <termios.h>
#include <unistd.h>
-#include "hunt.h"
+
+#include "hunt_common.h"
+#include "hunt_private.h"
#ifndef FREAD
#define FREAD 1