From c26df524baa361cedefd86bcc34e5c479948d386 Mon Sep 17 00:00:00 2001 From: dholland Date: Sun, 30 Mar 2014 02:58:25 +0000 Subject: unexpose some globals that server.c previously required --- hunt/hunt/hunt.c | 17 ++++++++++------- hunt/hunt/hunt_private.h | 6 ++---- hunt/hunt/server.c | 18 +++++++++--------- 3 files changed, 21 insertions(+), 20 deletions(-) (limited to 'hunt') 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 #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 @@ -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 -__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 #include @@ -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, -- cgit v1.2.3-56-ge451