(sendcmd): Change argument cmd to string. Callers changed.

(fnlist, fn, USER, COUN, QUIT, PASS, PLAY, LIST, CMD, CTLD, KILL):
Unused, remove.
This commit is contained in:
Markus Armbruster 2005-05-26 13:18:58 +00:00
parent 44b11ab597
commit 801d32783d
9 changed files with 15 additions and 134 deletions

View file

@ -36,16 +36,6 @@
#define CLIENTPROTO 2 /* if new things are added, bump this */ #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_CMDOK 0x0
#define C_DATA 0x1 #define C_DATA 0x1
#define C_INIT 0x2 #define C_INIT 0x2

View file

@ -32,13 +32,13 @@ include ../../build.conf
include ../make.src include ../make.src
include ../make.defs 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 \ ioqueue.c ipglob.c login.c main.c queue.c saveargv.c \
servcmd.c serverio.c tags.c termio.c termlib.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 \ ioqueue.o ipglob.o login.o main.o queue.o saveargv.o \
servcmd.o serverio.o tags.o termio.o termlib.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 \ ioqueue.obj ipglob.obj login.obj main.obj queue.obj saveargv.obj \
servcmd.obj serverio.obj tags.obj termio.obj termlib.obj servcmd.obj serverio.obj tags.obj termio.obj termlib.obj

View file

@ -28,13 +28,13 @@
# (standalone mode) # (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 \ ioqueue.c ipglob.c login.c main.c queue.c saveargv.c \
servcmd.c serverio.c tags.c termio.c termlib.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 \ ioqueue.o ipglob.o login.o main.o queue.o saveargv.o \
servcmd.o serverio.o tags.o termio.o termlib.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 \ ioqueue.obj ipglob.obj login.obj main.obj queue.obj saveargv.obj \
servcmd.obj serverio.obj tags.obj termio.obj termlib.obj servcmd.obj serverio.obj tags.obj termio.obj termlib.obj
@ -69,8 +69,7 @@ clean:
-(del /q $(OBJFILES)) -(del /q $(OBJFILES))
-(del /q empire.exe) -(del /q empire.exe)
expect.o: misc.h fnlist.h expect.o: misc.h
globals.o: misc.h fnlist.h proto.h
handle.o: misc.h handle.o: misc.h
host.o: misc.h host.o: misc.h
ioqueue.o: misc.h queue.h ioqueue.h ioqueue.o: misc.h queue.h ioqueue.h

View file

@ -32,7 +32,6 @@
*/ */
#include "misc.h" #include "misc.h"
#include "fnlist.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -140,13 +139,13 @@ expect(int s, int match, char *buf)
} }
void void
sendcmd(int s, int cmd, char *arg) sendcmd(int s, char *cmd, char *arg)
{ {
char buf[128]; char buf[128];
int cc; int cc;
int len; 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); len = strlen(buf);
#ifndef _WIN32 #ifndef _WIN32
cc = write(s, buf, len); cc = write(s, buf, len);

View file

@ -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_ */

View file

@ -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 <stdio.h>
#include <setjmp.h>
#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,},
};

View file

@ -54,7 +54,7 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc)
if (!expect(s, C_INIT, buf)) if (!expect(s, C_INIT, buf))
return 0; return 0;
(void)sendcmd(s, USER, uname); (void)sendcmd(s, "user", uname);
if (!expect(s, C_CMDOK, buf)) if (!expect(s, C_CMDOK, buf))
return 0; return 0;
if (cname == NULL) { if (cname == NULL) {
@ -66,7 +66,7 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc)
len = strlen(cname); len = strlen(cname);
if (cname[len-1] == '\n') if (cname[len-1] == '\n')
cname[len-1] = 0; cname[len-1] = 0;
(void)sendcmd(s, COUN, cname); (void)sendcmd(s, "coun", cname);
if (!expect(s, C_CMDOK, buf)) { if (!expect(s, C_CMDOK, buf)) {
(void)fprintf(stderr, "empire: no such country\n"); (void)fprintf(stderr, "empire: no such country\n");
return 0; return 0;
@ -88,20 +88,20 @@ login(int s, char *uname, char *cname, char *cpass, int kill_proc)
#endif #endif
} }
(void)printf("\n"); (void)printf("\n");
(void)sendcmd(s, PASS, cpass); (void)sendcmd(s, "pass", cpass);
memset(cpass, 0, strlen(cpass)); /* for core dumps */ memset(cpass, 0, strlen(cpass)); /* for core dumps */
if (!expect(s, C_CMDOK, buf)) { if (!expect(s, C_CMDOK, buf)) {
(void)fprintf(stderr, "Bad password\n"); (void)fprintf(stderr, "Bad password\n");
return 0; return 0;
} }
if (kill_proc) { if (kill_proc) {
(void)sendcmd(s, KILL, NULL); (void)sendcmd(s, "kill", NULL);
(void)printf("\n\t-=O=-\n"); (void)printf("\n\t-=O=-\n");
(void)expect(s, C_EXIT, buf); (void)expect(s, C_EXIT, buf);
fprintf(stderr, "%s\n", buf); fprintf(stderr, "%s\n", buf);
return 0; return 0;
} }
(void)sendcmd(s, PLAY, NULL); (void)sendcmd(s, "play", NULL);
(void)printf("\n\t-=O=-\n"); (void)printf("\n\t-=O=-\n");
if (!expect(s, C_INIT, buf)) { if (!expect(s, C_INIT, buf)) {
fprintf(stderr, "%s\n", buf); fprintf(stderr, "%s\n", buf);

View file

@ -68,7 +68,7 @@ int hostconnect(struct sockaddr_in *addr);
int hostport(char *name, 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); int login(int s, char *uname, char *cname, char *cpass, int kill_proc);
void saveargv(int ac, char **src, char **dst); 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); int sendeof(int sock);
void servercmd(struct ioqueue *ioq, FILE *auxfi); void servercmd(struct ioqueue *ioq, FILE *auxfi);
int serverio(int s, struct ioqueue *ioq); int serverio(int s, struct ioqueue *ioq);

View file

@ -38,16 +38,6 @@
#define CLIENTPROTO 2 /* if new things are added, bump this */ #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_CMDOK 0x0
#define C_DATA 0x1 #define C_DATA 0x1
#define C_INIT 0x2 #define C_INIT 0x2