Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/hunt/hunt unexpose some globals that server.c previous...
details: https://anonhg.NetBSD.org/src/rev/024a5f6427e5
branches: trunk
changeset: 328278:024a5f6427e5
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Mar 30 02:58:25 2014 +0000
description:
unexpose some globals that server.c previously required
diffstat:
games/hunt/hunt/hunt.c | 17 ++++++++++-------
games/hunt/hunt/hunt_private.h | 6 ++----
games/hunt/hunt/server.c | 18 +++++++++---------
3 files changed, 21 insertions(+), 20 deletions(-)
diffs (150 lines):
diff -r 39c852831223 -r 024a5f6427e5 games/hunt/hunt/hunt.c
--- a/games/hunt/hunt/hunt.c Sun Mar 30 02:53:11 2014 +0000
+++ b/games/hunt/hunt/hunt.c Sun Mar 30 02:58:25 2014 +0000
@@ -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 @@
#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 @@
#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 @@
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 -r 39c852831223 -r 024a5f6427e5 games/hunt/hunt/hunt_private.h
--- a/games/hunt/hunt/hunt_private.h Sun Mar 30 02:53:11 2014 +0000
+++ b/games/hunt/hunt/hunt_private.h Sun Mar 30 02:58:25 2014 +0000
@@ -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 SOCKET Daemon;
extern uint16_t Test_port;
extern char *Sock_host;
-extern bool Query_driver;
-extern bool Show_scores;
#endif
/*
@@ -108,5 +106,5 @@
/* in server.c */
#ifdef INTERNET
-SOCKET *list_drivers(void);
+SOCKET *list_drivers(unsigned short msg);
#endif
diff -r 39c852831223 -r 024a5f6427e5 games/hunt/hunt/server.c
--- a/games/hunt/hunt/server.c Sun Mar 30 02:53:11 2014 +0000
+++ b/games/hunt/hunt/server.c Sun Mar 30 02:58:25 2014 +0000
@@ -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 @@
}
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 @@
}
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 @@
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 @@
#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,
Home |
Main Index |
Thread Index |
Old Index