summaryrefslogtreecommitdiffstats
path: root/hunt
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2014-03-30 02:58:25 +0000
committerdholland <dholland@NetBSD.org>2014-03-30 02:58:25 +0000
commitc26df524baa361cedefd86bcc34e5c479948d386 (patch)
treef0ad8a202804019436c1e25053572352d99af341 /hunt
parent62de2fd1e1a74efa4b03f0691147e349e8128329 (diff)
downloadbsdgames-darwin-c26df524baa361cedefd86bcc34e5c479948d386.tar.gz
bsdgames-darwin-c26df524baa361cedefd86bcc34e5c479948d386.tar.zst
bsdgames-darwin-c26df524baa361cedefd86bcc34e5c479948d386.zip
unexpose some globals that server.c previously required
Diffstat (limited to 'hunt')
-rw-r--r--hunt/hunt/hunt.c17
-rw-r--r--hunt/hunt/hunt_private.h6
-rw-r--r--hunt/hunt/server.c18
3 files changed, 21 insertions, 20 deletions
diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c
index 8f577b27..48edeb95 100644
--- a/hunt/hunt/hunt.c
+++ b/hunt/hunt/hunt.c
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt.c,v 1.48 2014/03/30 02:26:09 dholland Exp $ */
+/* $NetBSD: hunt.c,v 1.49 2014/03/30 02:58:25 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.48 2014/03/30 02:26:09 dholland Exp $");
+__RCSID("$NetBSD: hunt.c,v 1.49 2014/03/30 02:58:25 dholland Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -81,9 +81,9 @@ char Buf[BUFSIZ];
#ifdef INTERNET
char *Sock_host;
static char *use_port;
-bool Query_driver = false;
+static bool Query_driver = false;
char *Send_message = NULL;
-bool Show_scores = false;
+static bool Show_scores = false;
#endif
SOCKET Daemon;
@@ -217,15 +217,17 @@ main(int ac, char **av)
#ifdef INTERNET
if (Show_scores) {
SOCKET *hosts;
+ u_short msg = C_TESTMSG();
- for (hosts = list_drivers(); hosts->sin_port != 0; hosts += 1)
+ for (hosts = list_drivers(msg); hosts->sin_port != 0; hosts += 1)
dump_scores(*hosts);
exit(0);
}
if (Query_driver) {
SOCKET *hosts;
+ u_short msg = C_TESTMSG();
- for (hosts = list_drivers(); hosts->sin_port != 0; hosts += 1) {
+ for (hosts = list_drivers(msg); hosts->sin_port != 0; hosts += 1) {
struct hostent *hp;
int num_players;
@@ -349,8 +351,9 @@ static void
find_driver(bool do_startup)
{
SOCKET *hosts;
+ u_short msg = C_TESTMSG();
- hosts = list_drivers();
+ hosts = list_drivers(msg);
if (hosts[0].sin_port != htons(0)) {
int i, c;
diff --git a/hunt/hunt/hunt_private.h b/hunt/hunt/hunt_private.h
index 4f7b8693..4d2a14ed 100644
--- a/hunt/hunt/hunt_private.h
+++ b/hunt/hunt/hunt_private.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt_private.h,v 1.4 2014/03/30 02:26:09 dholland Exp $ */
+/* $NetBSD: hunt_private.h,v 1.5 2014/03/30 02:58:25 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@@ -79,8 +79,6 @@ extern bool no_beep;
extern SOCKET Daemon;
extern uint16_t Test_port;
extern char *Sock_host;
-extern bool Query_driver;
-extern bool Show_scores;
#endif
/*
@@ -108,5 +106,5 @@ void do_message(void);
/* in server.c */
#ifdef INTERNET
-SOCKET *list_drivers(void);
+SOCKET *list_drivers(unsigned short msg);
#endif
diff --git a/hunt/hunt/server.c b/hunt/hunt/server.c
index 2ab75bab..7a60af09 100644
--- a/hunt/hunt/server.c
+++ b/hunt/hunt/server.c
@@ -1,4 +1,4 @@
-/* $NetBSD: server.c,v 1.3 2014/03/30 02:53:11 dholland Exp $ */
+/* $NetBSD: server.c,v 1.4 2014/03/30 02:58:25 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: server.c,v 1.3 2014/03/30 02:53:11 dholland Exp $");
+__RCSID("$NetBSD: server.c,v 1.4 2014/03/30 02:58:25 dholland Exp $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -174,12 +174,12 @@ get_responses(int contactsock)
}
SOCKET *
-list_drivers(void)
+list_drivers(unsigned short msg)
{
struct hostent *hp;
struct sockaddr_in contactaddr;
int option;
- u_short msg;
+ uint16_t wiremsg;
int contactsock;
int i;
@@ -203,8 +203,8 @@ list_drivers(void)
}
memcpy(&contactaddr.sin_addr, hp->h_addr,
sizeof(contactaddr.sin_addr));
- msg = htons(C_TESTMSG());
- (void) sendto(contactsock, &msg, sizeof msg, 0,
+ wiremsg = htons(msg);
+ (void) sendto(contactsock, &wiremsg, sizeof(wiremsg), 0,
(struct sockaddr *)&contactaddr,
sizeof(contactaddr));
get_responses(contactsock);
@@ -214,8 +214,8 @@ list_drivers(void)
if (!initial) {
/* favor host of previous session by broadcasting to it first */
contactaddr.sin_addr = Daemon.sin_addr;
- msg = htons(C_PLAYER); /* Must be playing! */
- (void) sendto(contactsock, &msg, sizeof msg, 0,
+ wiremsg = htons(C_PLAYER); /* Must be playing! */
+ (void) sendto(contactsock, &wiremsg, sizeof(wiremsg), 0,
(struct sockaddr *)&contactaddr, sizeof(contactaddr));
}
@@ -233,7 +233,7 @@ list_drivers(void)
#endif
/* send broadcast packets on all interfaces */
- msg = htons(C_TESTMSG());
+ wiremsg = htons(msg);
for (i = 0; i < brdc; i++) {
contactaddr.sin_addr = brdv[i].sin_addr;
if (sendto(contactsock, &msg, sizeof msg, 0,