client source. No functional changes.
#endif
int
-expect(int s, int match, s_char *buf)
+expect(int s, int match, char *buf)
{
int size;
- s_char *p;
+ char *p;
int n;
int code;
int newline;
- s_char *ptr;
+ char *ptr;
int cc;
size = 1024;
}
size -= n;
buf[n] = '\0';
- if ((p = strchr(ptr, '\n')) == 0) {
+ if ((p = strchr(ptr, '\n')) == NULL) {
do {
#ifndef _WIN32
cc = read(s, ptr, n);
}
void
-sendcmd(int s, int cmd, s_char *arg)
+sendcmd(int s, int cmd, char *arg)
{
- s_char buf[128];
+ char buf[128];
int cc;
int len;
- (void)sprintf(buf, "%s %s\n", fnlist[cmd].name, arg != 0 ? arg : "");
+ (void)sprintf(buf, "%s %s\n", fnlist[cmd].name, arg != NULL ? arg : "");
len = strlen(buf);
#ifndef _WIN32
cc = write(s, buf, len);
struct fn {
int (*func)(void);
- s_char *name;
+ char *name;
int value;
};
#include "misc.h"
int
-hostaddr(s_char *name, struct sockaddr_in *addr)
+hostaddr(char *name, struct sockaddr_in *addr)
{
struct hostent *hp;
- if (name == 0 || *name == 0)
+ if (name == NULL || *name == 0)
return 0;
if (isdigit(*name)) {
addr->sin_addr.s_addr = inet_addr(name);
}
int
-hostport(s_char *name, struct sockaddr_in *addr)
+hostport(char *name, struct sockaddr_in *addr)
{
struct servent *sp;
- if (name == 0 || *name == 0)
+ if (name == NULL || *name == 0)
return 0;
if (isdigit(*name)) {
#ifndef _WIN32
#include "queue.h"
#include "ioqueue.h"
-static int ioqtobuf(register struct ioqueue *ioq, s_char *buf, int cc);
-static void enqueuecc(struct ioqueue *ioq, s_char *buf, int cc);
-static int dequeuecc(register struct ioqueue *ioq, register int cc);
+static int ioqtobuf(struct ioqueue *ioq, char *buf, int cc);
+static void enqueuecc(struct ioqueue *ioq, char *buf, int cc);
+static int dequeuecc(struct ioqueue *ioq, int cc);
void
* number of bytes actually found.
*/
int
-ioq_peek(struct ioqueue *ioq, s_char *buf, int cc)
+ioq_peek(struct ioqueue *ioq, char *buf, int cc)
{
return ioqtobuf(ioq, buf, cc);
}
}
int
-ioq_read(struct ioqueue *ioq, s_char *buf, int cc)
+ioq_read(struct ioqueue *ioq, char *buf, int cc)
{
int n;
}
void
-ioq_write(struct ioqueue *ioq, s_char *buf, int cc)
+ioq_write(struct ioqueue *ioq, char *buf, int cc)
{
enqueuecc(ioq, buf, cc);
}
ioq->cc = 0;
}
-s_char *
-ioq_gets(struct ioqueue *ioq, s_char *buf, int cc)
+char *
+ioq_gets(struct ioqueue *ioq, char *buf, int cc)
{
- register s_char *p;
- register s_char *end;
+ char *p;
+ char *end;
int nbytes;
nbytes = ioqtobuf(ioq, buf, cc);
return buf;
}
}
- return 0;
+ return NULL;
}
/*
* left for a higher level.
*/
static int
-ioqtobuf(register struct ioqueue *ioq, s_char *buf, int cc)
+ioqtobuf(struct ioqueue *ioq, char *buf, int cc)
{
- register struct io *io;
+ struct io *io;
struct qelem *qp;
- s_char *offset;
+ char *offset;
int nbytes;
int nleft;
* append a buffer to the end of the ioq.
*/
static void
-enqueuecc(struct ioqueue *ioq, s_char *buf, int cc)
+enqueuecc(struct ioqueue *ioq, char *buf, int cc)
{
struct io *io;
* which are no longer used.
*/
static int
-dequeuecc(register struct ioqueue *ioq, register int cc)
+dequeuecc(struct ioqueue *ioq, int cc)
{
- register struct io *io;
- register struct qelem *qp;
- register int nbytes;
- register int there;
+ struct io *io;
+ struct qelem *qp;
+ int nbytes;
+ int there;
nbytes = 0;
while ((qp = ioq->queue.q_forw) != &ioq->queue) {
struct qelem queue; /* list of ioqueue elements */
int nbytes; /* number of data bytes present */
int offset; /* offset into current entry */
- s_char *data; /* pointer to start */
+ char *data; /* pointer to start */
};
void ioq_init(struct ioqueue *ioq, int bsize);
-int ioq_peek(struct ioqueue *ioq, s_char *buf, int cc);
+int ioq_peek(struct ioqueue *ioq, char *buf, int cc);
int ioq_dequeue(struct ioqueue *ioq, int cc);
-int ioq_read(struct ioqueue *ioq, s_char *buf, int cc);
-void ioq_write(struct ioqueue *ioq, s_char *buf, int cc);
+int ioq_read(struct ioqueue *ioq, char *buf, int cc);
+void ioq_write(struct ioqueue *ioq, char *buf, int cc);
int ioq_qsize(struct ioqueue *ioq);
void ioq_drain(struct ioqueue *ioq);
-s_char *ioq_gets(struct ioqueue *ioq, s_char *buf, int cc);
+char *ioq_gets(struct ioqueue *ioq, char *buf, int cc);
#endif
int
-login(int s, s_char *uname, s_char *cname, s_char *cpass, int kill_proc)
+login(int s, char *uname, char *cname, char *cpass, int kill_proc)
{
- s_char tmp[128];
- s_char buf[1024];
- s_char *ptr;
- s_char *p;
+ char tmp[128];
+ char buf[1024];
+ char *ptr;
+ char *p;
int len;
if (!expect(s, C_INIT, buf))
(void)sendcmd(s, USER, uname);
if (!expect(s, C_CMDOK, buf))
return 0;
- if (cname == 0) {
+ if (cname == NULL) {
(void)printf("Country name? ");
cname = fgets(tmp, sizeof(tmp), stdin);
- if (cname == 0 || *cname == 0)
+ if (cname == NULL || *cname == 0)
return 0;
}
len = strlen(cname);
(void)fprintf(stderr, "empire: no such country\n");
return 0;
}
- if (cpass == 0) {
+ if (cpass == NULL) {
#ifndef _WIN32
- cpass = (s_char *)getpass("Your name? ");
- if (cpass == 0 || *cpass == 0)
+ cpass = (char *)getpass("Your name? ");
+ if (cpass == NULL || *cpass == 0)
return 0;
#else
printf("Note: This is echoed to the screen\n");
printf("Your name? ");
cpass = fgets(tmp, sizeof(tmp), stdin);
- if (cpass == 0 || *cpass == 0)
+ if (cpass == NULL || *cpass == 0)
return 0;
len = strlen(cpass);
if (cname[len-1] == '\n')
return 0;
}
if (kill_proc) {
- (void)sendcmd(s, KILL, (s_char *)0);
+ (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, (s_char *)0);
+ (void)sendcmd(s, PLAY, NULL);
(void)printf("\n\t-=O=-\n");
if (!expect(s, C_INIT, buf)) {
fprintf(stderr, "%s\n", buf);
for (ptr = buf; !isspace(*ptr); ptr++) ;
ptr++;
p = strchr(ptr, '\n');
- if (p != 0)
+ if (p != NULL)
*p = 0;
if (atoi(ptr) != CLIENTPROTO) {
printf("Empire client out of date; get new version!\n");
int
-main(int ac, s_char **av)
+main(int ac, char **av)
{
#ifdef _WIN32
WSADATA WsaData;
int retry = 0;
#endif
struct ioqueue server;
- s_char *argv[128];
+ char *argv[128];
int i, j;
- s_char *ptr;
- s_char *auxout_fname;
+ char *ptr;
+ char *auxout_fname;
FILE *auxout_fp;
struct sockaddr_in sin;
int n;
- s_char *cname;
- s_char *pname;
- s_char *uname;
+ char *cname;
+ char *pname;
+ char *uname;
int send_kill = 0;
#ifdef _WIN32
#endif
memset(argv, 0, sizeof(argv));
saveargv(ac, av, argv);
- auxout_fname = 0;
- auxout_fp = 0;
+ auxout_fname = NULL;
+ auxout_fp = NULL;
for (i = j = 1; i < ac; ++i) {
ptr = argv[i];
- if (strcmp(ptr, "-2") == 0) {
+ if (strcmp(ptr, "-2") == NULL) {
if (i + 1 >= ac) {
fprintf(stderr, "-2: Missing filename!\n");
exit(1);
auxout_fname = argv[i + 1];
++i;
continue;
- } else if (strcmp(ptr, "-k") == 0) {
+ } else if (strcmp(ptr, "-k") == NULL) {
send_kill = 1;
continue;
}
(void)signal(SIGPIPE, SIG_IGN);
while (FD_ISSET(sock, &savemask)) {
mask = savemask;
- n = select(sock + 1, &mask, (fd_set *)0, (fd_set *)0,
- (struct timeval *)0);
+ n = select(sock + 1, &mask, NULL, NULL, NULL);
if (interrupt) {
if (!handleintr(sock))
break;
while (1) {
FD_ZERO(&readfds);
FD_SET(sock, &readfds);
- n = select(sock + 1, &readfds, (fd_set *) 0, (fd_set *) 0,
- (struct timeval *)&tm);
+ n = select(sock + 1, &readfds, NULL, NULL, (struct timeval *)&tm);
if (interrupt) {
if (!handleintr(sock))
break;
#include <netinet/in.h>
#endif
-#if !defined(aix) && !defined(sgi)
-#ifndef ultrix /* already defined in ultrix */
-typedef char s_char; /* change to signed char for aix */
-#endif /* ultrix */
-#else
-typedef signed char s_char;
-#endif /* !aix && !sgi */
typedef short coord; /* also change NSC_COORD in nsc.h */
struct ioqueue;
-extern s_char empirehost[];
-extern s_char empireport[];
+extern char empirehost[];
+extern char empireport[];
extern int interrupt;
-extern s_char num_teles[];
+extern char num_teles[];
extern int sock;
-extern s_char *SO;
-extern s_char *SE;
+extern char *SO;
+extern char *SE;
#ifdef _WIN32
HANDLE hStdIn;
#endif
void getsose(void);
-int expect(int s, int match, s_char *buf);
+int expect(int s, int match, char *buf);
int handleintr(int);
-int hostaddr(s_char *name, struct sockaddr_in *addr);
+int hostaddr(char *name, struct sockaddr_in *addr);
int hostconnect(struct sockaddr_in *addr);
-int hostport(s_char *name, struct sockaddr_in *addr);
-int login(int s, s_char *uname, s_char *cname, s_char *cpass, int kill_proc);
-void saveargv(int ac, s_char **src, s_char **dst);
-void sendcmd(int s, int cmd, s_char *arg);
+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);
int sendeof(int sock);
void servercmd(struct ioqueue *ioq, FILE *auxfi);
int serverio(int s, struct ioqueue *ioq);
#include "misc.h"
void
-saveargv(int ac, s_char **src, s_char **dst)
+saveargv(int ac, char **src, char **dst)
{
- register s_char *ptr;
- register int i;
+ char *ptr;
+ int i;
for (i = 0; i < ac; i++) {
dst[i] = strcpy(malloc(strlen(src[i]) + 1), src[i]);
#include <io.h>
#endif
-s_char num_teles[64];
-static s_char the_prompt[1024];
+char num_teles[64];
+static char the_prompt[1024];
static int mode;
static int nbtu;
static int nmin;
int exec_fd;
static void prompt(FILE *auxfi);
-static void doredir(s_char *p);
-static void dopipe(s_char *p);
-static void doexecute(s_char *p, FILE *auxfi);
-static void output(int code, s_char *buf, FILE *auxfi);
-static void screen(register s_char *buf);
+static void doredir(char *p);
+static void dopipe(char *p);
+static void doexecute(char *p, FILE *auxfi);
+static void output(int code, char *buf, FILE *auxfi);
+static void screen(char *buf);
void
servercmd(struct ioqueue *ioq, FILE *auxfi)
{
- s_char buf[1024];
- s_char *p;
+ char buf[1024];
+ char *p;
int code;
while (ioq_gets(ioq, buf, sizeof(buf))) {
sprintf(num_teles, "(%s) ", p + 1);
if (!redir_fp && !pipe_fp && !exec_fd) {
putchar('\07');
- prompt(0);
+ prompt(NULL);
}
} else
*num_teles = '\0';
if (mode == C_PROMPT) {
if (redir_fp) {
(void)fclose(redir_fp);
- redir_fp = 0;
+ redir_fp = NULL;
} else if (pipe_fp) {
#ifndef _WIN32
(void)pclose(pipe_fp);
#endif
- pipe_fp = 0;
+ pipe_fp = NULL;
} else if (exec_fd > 0) {
close(exec_fd);
close(0);
* opens redir_fp if successful
*/
static void
-doredir(s_char *p)
+doredir(char *p)
{
- s_char *how;
- s_char *name;
- s_char *tag;
+ char *how;
+ char *name;
+ char *tag;
int mode;
int fd;
if (redir_fp) {
(void)fclose(redir_fp);
- redir_fp = 0;
+ redir_fp = NULL;
}
how = p++;
if (*p && ((*p == '>') || (*p == '!')))
* opens "pipe_fp" if successful
*/
static void
-dopipe(s_char *p)
+dopipe(char *p)
{
- s_char *tag;
+ char *tag;
if (*p == '|')
p++;
return;
}
#ifndef _WIN32
- if ((pipe_fp = popen(p, "w")) == 0) {
+ if ((pipe_fp = popen(p, "w")) == NULL) {
#else
if (1) {
#endif
}
static void
-doexecute(s_char *p, FILE *auxfi)
+doexecute(char *p, FILE *auxfi)
{
int fd;
- s_char *tag;
+ char *tag;
tag = gettag(p);
while (*p && isspace(*p))
p);
return;
}
- if (p == 0) {
+ if (p == NULL) {
fprintf(stderr, "Null file to execute\n");
free(tag);
return;
}
static void
-output(int code, s_char *buf, FILE *auxfi)
+output(int code, char *buf, FILE *auxfi)
{
switch (code) {
case C_NOECHO:
}
static void
-screen(register s_char *buf)
+screen(char *buf)
{
- register s_char *sop;
- register s_char c;
+ char *sop;
+ char c;
while ((c = *buf++)) {
if (c & 0x80) {
int
serverio(int s, struct ioqueue *ioq)
{
- s_char *buf;
+ char *buf;
int n;
- if ((buf = malloc(ioq->bsize)) == 0) {
+ if ((buf = malloc(ioq->bsize)) == NULL) {
fprintf(stderr, "malloc server i/o failed\n");
return 0;
}
return 0;
}
if (n != ioq->bsize)
- buf = (s_char *)realloc(buf, n);
+ buf = (char *)realloc(buf, n);
ioq_write(ioq, buf, n);
return 1;
}
taglist = NULL;
}
-s_char *
-gettag(s_char *p)
+char *
+gettag(char *p)
{
struct tagstruct *tag1, *tag2;
#define _TAGS_H_
struct tagstruct {
- s_char *item;
+ char *item;
struct tagstruct *next;
};
extern struct tagstruct *taglist;
void io_init(void);
-s_char *gettag(s_char *p);
+char *gettag(char *p);
#endif
{
static char exec[] = "execute";
static char buf[4096];
- s_char out[4096];
+ char out[4096];
int i, n;
- s_char *ptr;
- s_char *p, *q, *r, *s, *t;
+ char *ptr;
+ char *p, *q, *r, *s, *t;
int nbytes;
int prespace, exec_com, inarg, quoted, tagging;
struct tagstruct *tag;
p[0] = c;
p[1] = '\0';
if (c != 10)
- ReadConsole(hStdIn, &p[0], sizeof(buf) - i, &n, NULL);
+ ReadConsole(hStdIn, p, sizeof(buf) - i, &n, NULL);
else
putchar(c);
/* Strip off the CRLF to just LF */
if (*p == '\n') {
if (tagging) {
tag = (struct tagstruct *)malloc(sizeof(struct tagstruct));
- tag->item = (s_char *)malloc((1 + p - s) * sizeof(s_char));
+ tag->item = (char *)malloc((1 + p - s) * sizeof(char));
tag->next = taglist;
taglist = tag;
t = tag->item;