Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/hunt/hunt Naming reform for socket pieces, akin to wha...
details: https://anonhg.NetBSD.org/src/rev/473370f5d5b5
branches: trunk
changeset: 795025:473370f5d5b5
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Mar 30 05:14:47 2014 +0000
description:
Naming reform for socket pieces, akin to what I did in huntd earlier.
(but not as comprehensive)
diffstat:
games/hunt/hunt/connect.c | 16 +++++-----
games/hunt/hunt/hunt.c | 67 +++++++++++++++++++++--------------------
games/hunt/hunt/hunt_private.h | 6 +-
games/hunt/hunt/otto.c | 6 +-
games/hunt/hunt/playit.c | 20 ++++++------
5 files changed, 58 insertions(+), 57 deletions(-)
diffs (truncated from 382 to 300 lines):
diff -r 073ed6a7c81f -r 473370f5d5b5 games/hunt/hunt/connect.c
--- a/games/hunt/hunt/connect.c Sun Mar 30 04:57:37 2014 +0000
+++ b/games/hunt/hunt/connect.c Sun Mar 30 05:14:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: connect.c,v 1.9 2014/03/29 21:24:26 dholland Exp $ */
+/* $NetBSD: connect.c,v 1.10 2014/03/30 05:14:47 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: connect.c,v 1.9 2014/03/29 21:24:26 dholland Exp $");
+__RCSID("$NetBSD: connect.c,v 1.10 2014/03/30 05:14:47 dholland Exp $");
#endif /* not lint */
#include <string.h>
@@ -50,13 +50,13 @@
if (uid == 0)
uid = htonl(getuid());
- (void) write(Socket, &uid, LONGLEN);
- (void) write(Socket, name, NAMELEN);
- (void) write(Socket, &team, 1);
+ (void) write(huntsocket, &uid, LONGLEN);
+ (void) write(huntsocket, name, NAMELEN);
+ (void) write(huntsocket, &team, 1);
enter_status = htonl(enter_status);
- (void) write(Socket, &enter_status, LONGLEN);
+ (void) write(huntsocket, &enter_status, LONGLEN);
(void) strcpy(Buf, ttyname(fileno(stderr)));
- (void) write(Socket, Buf, NAMELEN);
+ (void) write(huntsocket, Buf, NAMELEN);
#ifdef INTERNET
if (Send_message != NULL)
mode = C_MESSAGE;
@@ -69,5 +69,5 @@
#endif
mode = C_PLAYER;
mode = htonl(mode);
- (void) write(Socket, &mode, sizeof mode);
+ (void) write(huntsocket, &mode, sizeof mode);
}
diff -r 073ed6a7c81f -r 473370f5d5b5 games/hunt/hunt/hunt.c
--- a/games/hunt/hunt/hunt.c Sun Mar 30 04:57:37 2014 +0000
+++ b/games/hunt/hunt/hunt.c Sun Mar 30 05:14:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt.c,v 1.53 2014/03/30 04:57:37 dholland Exp $ */
+/* $NetBSD: hunt.c,v 1.54 2014/03/30 05:14:47 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.53 2014/03/30 04:57:37 dholland Exp $");
+__RCSID("$NetBSD: hunt.c,v 1.54 2014/03/30 05:14:47 dholland Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -64,9 +64,11 @@
#endif
#ifdef INTERNET
-static uint16_t Test_port = TEST_PORT;
+static const char *contactportstr;
+static uint16_t contactport = TEST_PORT;
+static const char *contacthost;
#else
-static const char Sock_name[] = PATH_HUNTSOCKET;
+static const char huntsockpath[] = PATH_HUNTSOCKET;
#endif
@@ -77,10 +79,8 @@
char Buf[BUFSIZ];
-/*static*/ int Socket;
+/*static*/ int huntsocket;
#ifdef INTERNET
-static char *Sock_host;
-static char *use_port;
char *Send_message = NULL;
#endif
@@ -182,11 +182,11 @@
Send_message = optarg;
break;
case 'h':
- Sock_host = optarg;
+ contacthost = optarg;
break;
case 'p':
- use_port = optarg;
- Test_port = atoi(use_port);
+ contactportstr = optarg;
+ contactport = atoi(contactportstr);
break;
#else
case 'S':
@@ -225,14 +225,14 @@
if (optind + 1 < ac)
goto usage;
else if (optind + 1 == ac)
- Sock_host = av[ac - 1];
+ contacthost = av[ac - 1];
#else
if (optind < ac)
goto usage;
#endif
#ifdef INTERNET
- serverlist_setup(Sock_host, Test_port);
+ serverlist_setup(contacthost, contactport);
if (Show_scores) {
const struct sockaddr_storage *host;
@@ -300,15 +300,15 @@
do {
int option;
- Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0);
- if (Socket < 0)
+ huntsocket = socket(SOCK_FAMILY, SOCK_STREAM, 0);
+ if (huntsocket < 0)
err(1, "socket");
option = 1;
- if (setsockopt(Socket, SOL_SOCKET, SO_USELOOPBACK,
+ if (setsockopt(huntsocket, SOL_SOCKET, SO_USELOOPBACK,
&option, sizeof option) < 0)
warn("setsockopt loopback");
errno = 0;
- if (connect(Socket, (struct sockaddr *) &Daemon,
+ if (connect(huntsocket, (struct sockaddr *) &Daemon,
DAEMON_SIZE) < 0) {
if (errno != ECONNREFUSED) {
leave(1, "connect");
@@ -317,13 +317,13 @@
else
break;
sleep(1);
- } while (close(Socket) == 0);
+ } while (close(huntsocket) == 0);
#else /* !INTERNET */
/*
* set up a socket
*/
- if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0)
+ if ((huntsocket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0)
err(1, "socket");
/*
@@ -333,20 +333,20 @@
*/
Daemon.sun_family = SOCK_FAMILY;
- (void) strcpy(Daemon.sun_path, Sock_name);
- if (connect(Socket, &Daemon, DAEMON_SIZE) < 0) {
+ (void) strcpy(Daemon.sun_path, huntsockpath);
+ if (connect(huntsocket, &Daemon, DAEMON_SIZE) < 0) {
if (errno != ENOENT) {
leavex(1, "connect2");
}
start_driver();
do {
- (void) close(Socket);
- if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM,
+ (void) close(huntsocket);
+ if ((huntsocket = socket(SOCK_FAMILY, SOCK_STREAM,
0)) < 0)
err(1, "socket");
sleep(2);
- } while (connect(Socket, &Daemon, DAEMON_SIZE) < 0);
+ } while (connect(huntsocket, &Daemon, DAEMON_SIZE) < 0);
}
#endif
@@ -474,7 +474,7 @@
#endif
#ifdef INTERNET
- if (Sock_host != NULL) {
+ if (contacthost != NULL) {
sleep(3);
return;
}
@@ -490,14 +490,15 @@
if (procid == 0) {
(void) signal(SIGINT, SIG_IGN);
#ifndef INTERNET
- (void) close(Socket);
+ (void) close(huntsocket);
#else
- if (use_port == NULL)
+ if (contactportstr == NULL)
#endif
execl(Driver, "HUNT", (char *) NULL);
#ifdef INTERNET
else
- execl(Driver, "HUNT", "-p", use_port, (char *) NULL);
+ execl(Driver, "HUNT", "-p", contactportstr,
+ (char *) NULL);
#endif
/* only get here if exec failed */
(void) kill(getppid(), SIGUSR1); /* tell mom */
@@ -591,9 +592,9 @@
if (isupper(ch))
ch = tolower(ch);
if (ch == 'y') {
- if (Socket != 0) {
- (void) write(Socket, "q", 1);
- (void) close(Socket);
+ if (huntsocket != 0) {
+ (void) write(huntsocket, "q", 1);
+ (void) close(huntsocket);
}
leavex(0, NULL);
}
@@ -698,8 +699,8 @@
}
#ifdef INTERNET
else if (strncmp(envp, "port=", s - envp + 1) == 0) {
- use_port = s + 1;
- Test_port = atoi(use_port);
+ contactportstr = s + 1;
+ contactport = atoi(contactportstr);
if ((s = strchr(envp, ',')) == NULL) {
*envp = '\0';
break;
@@ -708,7 +709,7 @@
envp = s + 1;
}
else if (strncmp(envp, "host=", s - envp + 1) == 0) {
- Sock_host = s + 1;
+ contacthost = s + 1;
if ((s = strchr(envp, ',')) == NULL) {
*envp = '\0';
break;
diff -r 073ed6a7c81f -r 473370f5d5b5 games/hunt/hunt/hunt_private.h
--- a/games/hunt/hunt/hunt_private.h Sun Mar 30 04:57:37 2014 +0000
+++ b/games/hunt/hunt/hunt_private.h Sun Mar 30 05:14:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hunt_private.h,v 1.7 2014/03/30 04:31:21 dholland Exp $ */
+/* $NetBSD: hunt_private.h,v 1.8 2014/03/30 05:14:47 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
@@ -50,7 +50,7 @@
extern bool Last_player;
extern char Buf[BUFSIZ];
-extern int Socket;
+extern int huntsocket;
#ifdef INTERNET
extern char *Send_message;
@@ -64,7 +64,7 @@
extern bool no_beep;
#ifdef INTERNET
-/* XXX this pile had to be made public to split off server.c; fix them up */
+/* XXX this had to be made public to split off server.c; fix it up */
extern SOCKET Daemon;
#endif
diff -r 073ed6a7c81f -r 473370f5d5b5 games/hunt/hunt/otto.c
--- a/games/hunt/hunt/otto.c Sun Mar 30 04:57:37 2014 +0000
+++ b/games/hunt/hunt/otto.c Sun Mar 30 05:14:47 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: otto.c,v 1.17 2014/03/29 21:24:26 dholland Exp $ */
+/* $NetBSD: otto.c,v 1.18 2014/03/30 05:14:47 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.17 2014/03/29 21:24:26 dholland Exp $");
+__RCSID("$NetBSD: otto.c,v 1.18 2014/03/30 05:14:47 dholland Exp $");
#endif /* not lint */
#include <sys/time.h>
@@ -217,7 +217,7 @@
wander();
done:
- (void) write(Socket, command, comlen);
+ (void) write(huntsocket, command, comlen);
Otto_count += comlen;
#ifdef DEBUG
(void) fwrite(command, 1, comlen, debug);
diff -r 073ed6a7c81f -r 473370f5d5b5 games/hunt/hunt/playit.c
--- a/games/hunt/hunt/playit.c Sun Mar 30 04:57:37 2014 +0000
+++ b/games/hunt/hunt/playit.c Sun Mar 30 05:14:47 2014 +0000
Home |
Main Index |
Thread Index |
Old Index