From: Marc Olzheim Date: Tue, 15 Mar 2005 21:47:41 +0000 (+0000) Subject: Get rid of "s_char", "register" and 0 used instead of NULL in the X-Git-Tag: v4.2.20~31 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=6a99690e4e9e1dcae6d6ac2ec784f8f921826edc Get rid of "s_char", "register" and 0 used instead of NULL in the client source. No functional changes. --- diff --git a/src/client/expect.c b/src/client/expect.c index 4a4649559..57d8d18ef 100644 --- a/src/client/expect.c +++ b/src/client/expect.c @@ -46,14 +46,14 @@ #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; @@ -72,7 +72,7 @@ expect(int s, int match, s_char *buf) } 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); @@ -140,13 +140,13 @@ expect(int s, int match, s_char *buf) } 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); diff --git a/src/client/fnlist.h b/src/client/fnlist.h index 40b516509..3ecbff50c 100644 --- a/src/client/fnlist.h +++ b/src/client/fnlist.h @@ -37,7 +37,7 @@ struct fn { int (*func)(void); - s_char *name; + char *name; int value; }; diff --git a/src/client/host.c b/src/client/host.c index 90cabab0f..603ed81bb 100644 --- a/src/client/host.c +++ b/src/client/host.c @@ -50,11 +50,11 @@ #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); @@ -74,11 +74,11 @@ hostaddr(s_char *name, struct sockaddr_in *addr) } 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 diff --git a/src/client/ioqueue.c b/src/client/ioqueue.c index cfff85d32..e6647be64 100644 --- a/src/client/ioqueue.c +++ b/src/client/ioqueue.c @@ -39,9 +39,9 @@ #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 @@ -59,7 +59,7 @@ ioq_init(struct ioqueue *ioq, int bsize) * 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); } @@ -73,7 +73,7 @@ ioq_dequeue(struct ioqueue *ioq, int cc) } int -ioq_read(struct ioqueue *ioq, s_char *buf, int cc) +ioq_read(struct ioqueue *ioq, char *buf, int cc) { int n; @@ -84,7 +84,7 @@ ioq_read(struct ioqueue *ioq, s_char *buf, int cc) } void -ioq_write(struct ioqueue *ioq, s_char *buf, int cc) +ioq_write(struct ioqueue *ioq, char *buf, int cc) { enqueuecc(ioq, buf, cc); } @@ -110,11 +110,11 @@ ioq_drain(struct ioqueue *ioq) 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); @@ -128,7 +128,7 @@ ioq_gets(struct ioqueue *ioq, s_char *buf, int cc) return buf; } } - return 0; + return NULL; } /* @@ -142,11 +142,11 @@ ioq_gets(struct ioqueue *ioq, s_char *buf, int cc) * 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; @@ -174,7 +174,7 @@ ioqtobuf(register struct ioqueue *ioq, s_char *buf, int cc) * 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; @@ -192,12 +192,12 @@ enqueuecc(struct ioqueue *ioq, s_char *buf, int cc) * 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) { diff --git a/src/client/ioqueue.h b/src/client/ioqueue.h index 4ddd8c4c8..489e4058d 100644 --- a/src/client/ioqueue.h +++ b/src/client/ioqueue.h @@ -44,14 +44,14 @@ struct io { 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); diff --git a/src/client/login.c b/src/client/login.c index 74ac3623f..2789abce5 100644 --- a/src/client/login.c +++ b/src/client/login.c @@ -44,12 +44,12 @@ #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)) @@ -57,10 +57,10 @@ login(int s, s_char *uname, s_char *cname, s_char *cpass, int kill_proc) (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); @@ -71,16 +71,16 @@ login(int s, s_char *uname, s_char *cname, s_char *cpass, int kill_proc) (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') @@ -95,13 +95,13 @@ login(int s, s_char *uname, s_char *cname, s_char *cpass, int kill_proc) 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); @@ -110,7 +110,7 @@ login(int s, s_char *uname, s_char *cname, s_char *cpass, int kill_proc) 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"); diff --git a/src/client/main.c b/src/client/main.c index b88155b86..e87200327 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -77,7 +77,7 @@ static void intr(int sig); int -main(int ac, s_char **av) +main(int ac, char **av) { #ifdef _WIN32 WSADATA WsaData; @@ -94,16 +94,16 @@ main(int ac, s_char **av) 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 @@ -118,11 +118,11 @@ main(int ac, s_char **av) #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); @@ -130,7 +130,7 @@ main(int ac, s_char **av) auxout_fname = argv[i + 1]; ++i; continue; - } else if (strcmp(ptr, "-k") == 0) { + } else if (strcmp(ptr, "-k") == NULL) { send_kill = 1; continue; } @@ -200,8 +200,7 @@ main(int ac, s_char **av) (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; @@ -271,8 +270,7 @@ main(int ac, s_char **av) 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; diff --git a/src/client/misc.h b/src/client/misc.h index a75184e27..ec0f21fe0 100644 --- a/src/client/misc.h +++ b/src/client/misc.h @@ -44,38 +44,31 @@ #include #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); diff --git a/src/client/saveargv.c b/src/client/saveargv.c index cd47c627a..0968cb624 100644 --- a/src/client/saveargv.c +++ b/src/client/saveargv.c @@ -36,10 +36,10 @@ #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]); diff --git a/src/client/servcmd.c b/src/client/servcmd.c index 7dbe50ebe..788af0ca8 100644 --- a/src/client/servcmd.c +++ b/src/client/servcmd.c @@ -49,8 +49,8 @@ #include #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; @@ -59,17 +59,17 @@ FILE *pipe_fp; 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))) { @@ -110,7 +110,7 @@ servercmd(struct ioqueue *ioq, FILE *auxfi) sprintf(num_teles, "(%s) ", p + 1); if (!redir_fp && !pipe_fp && !exec_fd) { putchar('\07'); - prompt(0); + prompt(NULL); } } else *num_teles = '\0'; @@ -128,12 +128,12 @@ prompt(FILE *auxfi) 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); @@ -155,17 +155,17 @@ prompt(FILE *auxfi) * 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 == '!'))) @@ -207,9 +207,9 @@ doredir(s_char *p) * opens "pipe_fp" if successful */ static void -dopipe(s_char *p) +dopipe(char *p) { - s_char *tag; + char *tag; if (*p == '|') p++; @@ -226,7 +226,7 @@ dopipe(s_char *p) return; } #ifndef _WIN32 - if ((pipe_fp = popen(p, "w")) == 0) { + if ((pipe_fp = popen(p, "w")) == NULL) { #else if (1) { #endif @@ -237,10 +237,10 @@ dopipe(s_char *p) } 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)) @@ -251,7 +251,7 @@ doexecute(s_char *p, FILE *auxfi) p); return; } - if (p == 0) { + if (p == NULL) { fprintf(stderr, "Null file to execute\n"); free(tag); return; @@ -280,7 +280,7 @@ doexecute(s_char *p, FILE *auxfi) } static void -output(int code, s_char *buf, FILE *auxfi) +output(int code, char *buf, FILE *auxfi) { switch (code) { case C_NOECHO: @@ -338,10 +338,10 @@ output(int code, s_char *buf, FILE *auxfi) } 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) { diff --git a/src/client/serverio.c b/src/client/serverio.c index c01012685..96a609c22 100644 --- a/src/client/serverio.c +++ b/src/client/serverio.c @@ -49,10 +49,10 @@ 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; } @@ -75,7 +75,7 @@ serverio(int s, struct ioqueue *ioq) return 0; } if (n != ioq->bsize) - buf = (s_char *)realloc(buf, n); + buf = (char *)realloc(buf, n); ioq_write(ioq, buf, n); return 1; } diff --git a/src/client/tags.c b/src/client/tags.c index 3531ca9eb..73f87713c 100644 --- a/src/client/tags.c +++ b/src/client/tags.c @@ -50,8 +50,8 @@ io_init(void) taglist = NULL; } -s_char * -gettag(s_char *p) +char * +gettag(char *p) { struct tagstruct *tag1, *tag2; diff --git a/src/client/tags.h b/src/client/tags.h index b437c9f00..a46b92a9f 100644 --- a/src/client/tags.h +++ b/src/client/tags.h @@ -35,13 +35,13 @@ #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 diff --git a/src/client/termio.c b/src/client/termio.c index 31b6c694d..ec7232e9e 100644 --- a/src/client/termio.c +++ b/src/client/termio.c @@ -49,10 +49,10 @@ termio(int fd, int sock, FILE *auxfi) { 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; @@ -88,7 +88,7 @@ termio(int fd, int sock, FILE *auxfi) 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 */ @@ -134,7 +134,7 @@ termio(int fd, int sock, FILE *auxfi) 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;