From 801d32783dda0325a00cb9ec3397d706dbfa5c08 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 26 May 2005 13:18:58 +0000 Subject: [PATCH] (sendcmd): Change argument cmd to string. Callers changed. (fnlist, fn, USER, COUN, QUIT, PASS, PLAY, LIST, CMD, CTLD, KILL): Unused, remove. --- include/proto.h | 10 ------- src/client/Makefile | 6 ++-- src/client/Makefile.standalone | 9 +++--- src/client/expect.c | 5 ++-- src/client/fnlist.h | 46 ------------------------------ src/client/globals.c | 51 ---------------------------------- src/client/login.c | 10 +++---- src/client/misc.h | 2 +- src/client/proto.h | 10 ------- 9 files changed, 15 insertions(+), 134 deletions(-) delete mode 100644 src/client/fnlist.h delete mode 100644 src/client/globals.c diff --git a/include/proto.h b/include/proto.h index f4fca5c1..59f37468 100644 --- a/include/proto.h +++ b/include/proto.h @@ -36,16 +36,6 @@ #define CLIENTPROTO 2 /* if new things are added, bump this */ -#define USER 0 -#define COUN 1 -#define QUIT 2 -#define PASS 3 -#define PLAY 4 -#define LIST 5 -#define CMD 6 -#define CTLD 7 -#define KILL 8 - #define C_CMDOK 0x0 #define C_DATA 0x1 #define C_INIT 0x2 diff --git a/src/client/Makefile b/src/client/Makefile index c33c1270..9621f2fc 100644 --- a/src/client/Makefile +++ b/src/client/Makefile @@ -32,13 +32,13 @@ include ../../build.conf include ../make.src include ../make.defs -CFILES = expect.c globals.c handle.c host.c \ +CFILES = expect.c handle.c host.c \ ioqueue.c ipglob.c login.c main.c queue.c saveargv.c \ servcmd.c serverio.c tags.c termio.c termlib.c -OFILES = expect.o globals.o handle.o host.o \ +OFILES = expect.o handle.o host.o \ ioqueue.o ipglob.o login.o main.o queue.o saveargv.o \ servcmd.o serverio.o tags.o termio.o termlib.o -OBJFILES = expect.obj globals.obj handle.obj host.obj \ +OBJFILES = expect.obj handle.obj host.obj \ ioqueue.obj ipglob.obj login.obj main.obj queue.obj saveargv.obj \ servcmd.obj serverio.obj tags.obj termio.obj termlib.obj diff --git a/src/client/Makefile.standalone b/src/client/Makefile.standalone index 8ad519c2..bb9971af 100644 --- a/src/client/Makefile.standalone +++ b/src/client/Makefile.standalone @@ -28,13 +28,13 @@ # (standalone mode) # -CFILES = expect.c globals.c handle.c host.c \ +CFILES = expect.c handle.c host.c \ ioqueue.c ipglob.c login.c main.c queue.c saveargv.c \ servcmd.c serverio.c tags.c termio.c termlib.c -OFILES = expect.o globals.o handle.o host.o \ +OFILES = expect.o handle.o host.o \ ioqueue.o ipglob.o login.o main.o queue.o saveargv.o \ servcmd.o serverio.o tags.o termio.o termlib.o -OBJFILES = expect.obj globals.obj handle.obj host.obj \ +OBJFILES = expect.obj handle.obj host.obj \ ioqueue.obj ipglob.obj login.obj main.obj queue.obj saveargv.obj \ servcmd.obj serverio.obj tags.obj termio.obj termlib.obj @@ -69,8 +69,7 @@ clean: -(del /q $(OBJFILES)) -(del /q empire.exe) -expect.o: misc.h fnlist.h -globals.o: misc.h fnlist.h proto.h +expect.o: misc.h handle.o: misc.h host.o: misc.h ioqueue.o: misc.h queue.h ioqueue.h diff --git a/src/client/expect.c b/src/client/expect.c index cc51a966..6a82a8da 100644 --- a/src/client/expect.c +++ b/src/client/expect.c @@ -32,7 +32,6 @@ */ #include "misc.h" -#include "fnlist.h" #include #include @@ -140,13 +139,13 @@ expect(int s, int match, char *buf) } void -sendcmd(int s, int cmd, char *arg) +sendcmd(int s, char *cmd, char *arg) { char buf[128]; int cc; int len; - (void)sprintf(buf, "%s %s\n", fnlist[cmd].name, arg != NULL ? arg : ""); + (void)sprintf(buf, "%s %s\n", cmd, arg != NULL ? arg : ""); len = strlen(buf); #ifndef _WIN32 cc = write(s, buf, len); diff --git a/src/client/fnlist.h b/src/client/fnlist.h deleted file mode 100644 index c1155624..00000000 --- a/src/client/fnlist.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Empire - A multi-player, client/server Internet based war game. - * Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak, - * Ken Stevens, Steve McClure - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * --- - * - * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the - * related information and legal notices. It is expected that any future - * projects/authors will amend these files as needed. - * - * --- - * - * fnlist.h: function list structure - * - * Known contributors to this file: - * Dave Pare, 1986 - * Steve McClure, 1998 - */ - -#ifndef _FNLIST_H_ -#define _FNLIST_H_ - -struct fn { - int (*func)(void); - char *name; - int value; -}; - -extern struct fn fnlist[]; - -#endif /* _FNLIST_H_ */ diff --git a/src/client/globals.c b/src/client/globals.c deleted file mode 100644 index 3e518184..00000000 --- a/src/client/globals.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Empire - A multi-player, client/server Internet based war game. - * Copyright (C) 1986-2005, Dave Pare, Jeff Bailey, Thomas Ruschak, - * Ken Stevens, Steve McClure - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * --- - * - * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the - * related information and legal notices. It is expected that any future - * projects/authors will amend these files as needed. - * - * --- - * - * globals.c: Globals for the client - * - * Known contributors to this file: - * Dave Pare, 1986 - */ - -#include -#include -#include "misc.h" -#include "fnlist.h" -#include "proto.h" - -struct fn fnlist[] = { - {NULL, "user", USER,}, - {NULL, "coun", COUN,}, - {NULL, "quit", QUIT,}, - {NULL, "pass", PASS,}, - {NULL, "play", PLAY,}, - {NULL, "list", LIST,}, - {NULL, "cmd", CMD,}, - {NULL, "ctld", CTLD,}, - {NULL, "kill", KILL,}, - {NULL, "", 0,}, -}; diff --git a/src/client/login.c b/src/client/login.c index 42fef09f..f888e06a 100644 --- a/src/client/login.c +++ b/src/client/login.c @@ -54,7 +54,7 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc) if (!expect(s, C_INIT, buf)) return 0; - (void)sendcmd(s, USER, uname); + (void)sendcmd(s, "user", uname); if (!expect(s, C_CMDOK, buf)) return 0; if (cname == NULL) { @@ -66,7 +66,7 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc) len = strlen(cname); if (cname[len-1] == '\n') cname[len-1] = 0; - (void)sendcmd(s, COUN, cname); + (void)sendcmd(s, "coun", cname); if (!expect(s, C_CMDOK, buf)) { (void)fprintf(stderr, "empire: no such country\n"); return 0; @@ -88,20 +88,20 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc) #endif } (void)printf("\n"); - (void)sendcmd(s, PASS, cpass); + (void)sendcmd(s, "pass", cpass); memset(cpass, 0, strlen(cpass)); /* for core dumps */ if (!expect(s, C_CMDOK, buf)) { (void)fprintf(stderr, "Bad password\n"); return 0; } if (kill_proc) { - (void)sendcmd(s, KILL, NULL); + (void)sendcmd(s, "kill", NULL); (void)printf("\n\t-=O=-\n"); (void)expect(s, C_EXIT, buf); fprintf(stderr, "%s\n", buf); return 0; } - (void)sendcmd(s, PLAY, NULL); + (void)sendcmd(s, "play", NULL); (void)printf("\n\t-=O=-\n"); if (!expect(s, C_INIT, buf)) { fprintf(stderr, "%s\n", buf); diff --git a/src/client/misc.h b/src/client/misc.h index 8df18e27..c908e559 100644 --- a/src/client/misc.h +++ b/src/client/misc.h @@ -68,7 +68,7 @@ int hostconnect(struct sockaddr_in *addr); int hostport(char *name, struct sockaddr_in *addr); int login(int s, char *uname, char *cname, char *cpass, int kill_proc); void saveargv(int ac, char **src, char **dst); -void sendcmd(int s, int cmd, char *arg); +void sendcmd(int s, char *cmd, char *arg); int sendeof(int sock); void servercmd(struct ioqueue *ioq, FILE *auxfi); int serverio(int s, struct ioqueue *ioq); diff --git a/src/client/proto.h b/src/client/proto.h index 89de5bfd..aefc493f 100644 --- a/src/client/proto.h +++ b/src/client/proto.h @@ -38,16 +38,6 @@ #define CLIENTPROTO 2 /* if new things are added, bump this */ -#define USER 0 -#define COUN 1 -#define QUIT 2 -#define PASS 3 -#define PLAY 4 -#define LIST 5 -#define CMD 6 -#define CTLD 7 -#define KILL 8 - #define C_CMDOK 0x0 #define C_DATA 0x1 #define C_INIT 0x2