Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/hunt Split hunt and huntd's includes, instead of inces...



details:   https://anonhg.NetBSD.org/src/rev/8164a4a99605
branches:  trunk
changeset: 794983:8164a4a99605
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Mar 29 21:24:26 2014 +0000

description:
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:

 games/hunt/hunt/Makefile         |    8 +-
 games/hunt/hunt/connect.c        |    9 +-
 games/hunt/hunt/hunt.c           |   17 ++-
 games/hunt/hunt/hunt_private.h   |   97 +++++++++++++++
 games/hunt/hunt/otto.c           |    9 +-
 games/hunt/hunt/playit.c         |    9 +-
 games/hunt/huntd/Makefile        |    4 +-
 games/hunt/huntd/hunt.h          |  235 +--------------------------------------
 games/hunt/huntd/pathname.c      |   12 +-
 games/hunt/include/hunt_common.h |  238 +++++++++++++++++++++++++++++++++++++++
 10 files changed, 381 insertions(+), 257 deletions(-)

diffs (truncated from 865 to 300 lines):

diff -r e000c3d8fd0f -r 8164a4a99605 games/hunt/hunt/Makefile
--- a/games/hunt/hunt/Makefile  Sat Mar 29 20:53:55 2014 +0000
+++ b/games/hunt/hunt/Makefile  Sat Mar 29 21:24:26 2014 +0000
@@ -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 -r e000c3d8fd0f -r 8164a4a99605 games/hunt/hunt/connect.c
--- a/games/hunt/hunt/connect.c Sat Mar 29 20:53:55 2014 +0000
+++ b/games/hunt/hunt/connect.c Sat Mar 29 21:24:26 2014 +0000
@@ -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 -r e000c3d8fd0f -r 8164a4a99605 games/hunt/hunt/hunt.c
--- a/games/hunt/hunt/hunt.c    Sat Mar 29 20:53:55 2014 +0000
+++ b/games/hunt/hunt/hunt.c    Sat Mar 29 21:24:26 2014 +0000
@@ -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 @@
 #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 -r e000c3d8fd0f -r 8164a4a99605 games/hunt/hunt/hunt_private.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/games/hunt/hunt/hunt_private.h    Sat Mar 29 21:24:26 2014 +0000
@@ -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 -r e000c3d8fd0f -r 8164a4a99605 games/hunt/hunt/otto.c
--- a/games/hunt/hunt/otto.c    Sat Mar 29 20:53:55 2014 +0000
+++ b/games/hunt/hunt/otto.c    Sat Mar 29 21:24:26 2014 +0000
@@ -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 @@
 #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 -r e000c3d8fd0f -r 8164a4a99605 games/hunt/hunt/playit.c
--- a/games/hunt/hunt/playit.c  Sat Mar 29 20:53:55 2014 +0000
+++ b/games/hunt/hunt/playit.c  Sat Mar 29 21:24:26 2014 +0000
@@ -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 @@
 #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
diff -r e000c3d8fd0f -r 8164a4a99605 games/hunt/huntd/Makefile
--- a/games/hunt/huntd/Makefile Sat Mar 29 20:53:55 2014 +0000
+++ b/games/hunt/huntd/Makefile Sat Mar 29 21:24:26 2014 +0000
@@ -1,8 +1,10 @@
-#      $NetBSD: Makefile,v 1.3 2014/03/29 20:35:30 dholland Exp $
+#      $NetBSD: Makefile,v 1.4 2014/03/29 21:24:26 dholland Exp $
 
 PROG=  huntd
 SRCS=  answer.c draw.c driver.c execute.c expl.c \
        extern.c makemaze.c pathname.c shots.c terminal.c
 MAN=   huntd.6
 
+CPPFLAGS+=-I${.CURDIR}/../include
+
 .include <bsd.prog.mk>
diff -r e000c3d8fd0f -r 8164a4a99605 games/hunt/huntd/hunt.h
--- a/games/hunt/huntd/hunt.h   Sat Mar 29 20:53:55 2014 +0000
+++ b/games/hunt/huntd/hunt.h   Sat Mar 29 21:24:26 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hunt.h,v 1.22 2014/03/29 20:16:09 dholland Exp $       */
+/*     $NetBSD: hunt.h,v 1.23 2014/03/29 21:24:26 dholland Exp $       */
 
 /*
  * Copyright (c) 1983-2003, Regents of the University of California.
@@ -53,225 +53,16 @@
 #include <sys/un.h>
 #endif
 
-#ifdef INTERNET
-#define SOCK_FAMILY    AF_INET
-#else
-#define SOCK_FAMILY    AF_UNIX
-#define AF_UNIX_HACK                   /* 4.2 hack; leaves files around */
-#endif
-
-/*
- * Preprocessor define dependencies
- */
-#if defined(VOLCANO) && !defined(OOZE)
-#define OOZE
-#endif
-#if defined(BOOTS) && !defined(FLY)
-#define FLY
-#endif



Home | Main Index | Thread Index | Old Index