Get rid of "s_char", "register" and 0 used instead of NULL in the
client source. No functional changes.
This commit is contained in:
parent
3e7d57a8c9
commit
6a99690e4e
14 changed files with 117 additions and 126 deletions
|
@ -46,14 +46,14 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
expect(int s, int match, s_char *buf)
|
expect(int s, int match, char *buf)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
s_char *p;
|
char *p;
|
||||||
int n;
|
int n;
|
||||||
int code;
|
int code;
|
||||||
int newline;
|
int newline;
|
||||||
s_char *ptr;
|
char *ptr;
|
||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
size = 1024;
|
size = 1024;
|
||||||
|
@ -72,7 +72,7 @@ expect(int s, int match, s_char *buf)
|
||||||
}
|
}
|
||||||
size -= n;
|
size -= n;
|
||||||
buf[n] = '\0';
|
buf[n] = '\0';
|
||||||
if ((p = strchr(ptr, '\n')) == 0) {
|
if ((p = strchr(ptr, '\n')) == NULL) {
|
||||||
do {
|
do {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
cc = read(s, ptr, n);
|
cc = read(s, ptr, n);
|
||||||
|
@ -140,13 +140,13 @@ expect(int s, int match, s_char *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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 cc;
|
||||||
int len;
|
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);
|
len = strlen(buf);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
cc = write(s, buf, len);
|
cc = write(s, buf, len);
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
struct fn {
|
struct fn {
|
||||||
int (*func)(void);
|
int (*func)(void);
|
||||||
s_char *name;
|
char *name;
|
||||||
int value;
|
int value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,11 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
hostaddr(s_char *name, struct sockaddr_in *addr)
|
hostaddr(char *name, struct sockaddr_in *addr)
|
||||||
{
|
{
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
|
|
||||||
if (name == 0 || *name == 0)
|
if (name == NULL || *name == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (isdigit(*name)) {
|
if (isdigit(*name)) {
|
||||||
addr->sin_addr.s_addr = inet_addr(name);
|
addr->sin_addr.s_addr = inet_addr(name);
|
||||||
|
@ -74,11 +74,11 @@ hostaddr(s_char *name, struct sockaddr_in *addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
hostport(s_char *name, struct sockaddr_in *addr)
|
hostport(char *name, struct sockaddr_in *addr)
|
||||||
{
|
{
|
||||||
struct servent *sp;
|
struct servent *sp;
|
||||||
|
|
||||||
if (name == 0 || *name == 0)
|
if (name == NULL || *name == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (isdigit(*name)) {
|
if (isdigit(*name)) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
|
|
@ -39,9 +39,9 @@
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "ioqueue.h"
|
#include "ioqueue.h"
|
||||||
|
|
||||||
static int ioqtobuf(register struct ioqueue *ioq, s_char *buf, int cc);
|
static int ioqtobuf(struct ioqueue *ioq, char *buf, int cc);
|
||||||
static void enqueuecc(struct ioqueue *ioq, s_char *buf, int cc);
|
static void enqueuecc(struct ioqueue *ioq, char *buf, int cc);
|
||||||
static int dequeuecc(register struct ioqueue *ioq, register int cc);
|
static int dequeuecc(struct ioqueue *ioq, int cc);
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -59,7 +59,7 @@ ioq_init(struct ioqueue *ioq, int bsize)
|
||||||
* number of bytes actually found.
|
* number of bytes actually found.
|
||||||
*/
|
*/
|
||||||
int
|
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);
|
return ioqtobuf(ioq, buf, cc);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ ioq_dequeue(struct ioqueue *ioq, int cc)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ioq_read(struct ioqueue *ioq, s_char *buf, int cc)
|
ioq_read(struct ioqueue *ioq, char *buf, int cc)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ ioq_read(struct ioqueue *ioq, s_char *buf, int cc)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ioq_write(struct ioqueue *ioq, s_char *buf, int cc)
|
ioq_write(struct ioqueue *ioq, char *buf, int cc)
|
||||||
{
|
{
|
||||||
enqueuecc(ioq, buf, cc);
|
enqueuecc(ioq, buf, cc);
|
||||||
}
|
}
|
||||||
|
@ -110,11 +110,11 @@ ioq_drain(struct ioqueue *ioq)
|
||||||
ioq->cc = 0;
|
ioq->cc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_char *
|
char *
|
||||||
ioq_gets(struct ioqueue *ioq, s_char *buf, int cc)
|
ioq_gets(struct ioqueue *ioq, char *buf, int cc)
|
||||||
{
|
{
|
||||||
register s_char *p;
|
char *p;
|
||||||
register s_char *end;
|
char *end;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
|
||||||
nbytes = ioqtobuf(ioq, buf, cc);
|
nbytes = ioqtobuf(ioq, buf, cc);
|
||||||
|
@ -128,7 +128,7 @@ ioq_gets(struct ioqueue *ioq, s_char *buf, int cc)
|
||||||
return buf;
|
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.
|
* left for a higher level.
|
||||||
*/
|
*/
|
||||||
static int
|
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;
|
struct qelem *qp;
|
||||||
s_char *offset;
|
char *offset;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
int nleft;
|
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.
|
* append a buffer to the end of the ioq.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
enqueuecc(struct ioqueue *ioq, s_char *buf, int cc)
|
enqueuecc(struct ioqueue *ioq, char *buf, int cc)
|
||||||
{
|
{
|
||||||
struct io *io;
|
struct io *io;
|
||||||
|
|
||||||
|
@ -192,12 +192,12 @@ enqueuecc(struct ioqueue *ioq, s_char *buf, int cc)
|
||||||
* which are no longer used.
|
* which are no longer used.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
dequeuecc(register struct ioqueue *ioq, register int cc)
|
dequeuecc(struct ioqueue *ioq, int cc)
|
||||||
{
|
{
|
||||||
register struct io *io;
|
struct io *io;
|
||||||
register struct qelem *qp;
|
struct qelem *qp;
|
||||||
register int nbytes;
|
int nbytes;
|
||||||
register int there;
|
int there;
|
||||||
|
|
||||||
nbytes = 0;
|
nbytes = 0;
|
||||||
while ((qp = ioq->queue.q_forw) != &ioq->queue) {
|
while ((qp = ioq->queue.q_forw) != &ioq->queue) {
|
||||||
|
|
|
@ -44,14 +44,14 @@ struct io {
|
||||||
struct qelem queue; /* list of ioqueue elements */
|
struct qelem queue; /* list of ioqueue elements */
|
||||||
int nbytes; /* number of data bytes present */
|
int nbytes; /* number of data bytes present */
|
||||||
int offset; /* offset into current entry */
|
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);
|
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_dequeue(struct ioqueue *ioq, int cc);
|
||||||
int ioq_read(struct ioqueue *ioq, s_char *buf, int cc);
|
int ioq_read(struct ioqueue *ioq, char *buf, int cc);
|
||||||
void ioq_write(struct ioqueue *ioq, s_char *buf, int cc);
|
void ioq_write(struct ioqueue *ioq, char *buf, int cc);
|
||||||
int ioq_qsize(struct ioqueue *ioq);
|
int ioq_qsize(struct ioqueue *ioq);
|
||||||
void ioq_drain(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);
|
||||||
|
|
|
@ -44,12 +44,12 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int
|
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];
|
char tmp[128];
|
||||||
s_char buf[1024];
|
char buf[1024];
|
||||||
s_char *ptr;
|
char *ptr;
|
||||||
s_char *p;
|
char *p;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!expect(s, C_INIT, buf))
|
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);
|
(void)sendcmd(s, USER, uname);
|
||||||
if (!expect(s, C_CMDOK, buf))
|
if (!expect(s, C_CMDOK, buf))
|
||||||
return 0;
|
return 0;
|
||||||
if (cname == 0) {
|
if (cname == NULL) {
|
||||||
(void)printf("Country name? ");
|
(void)printf("Country name? ");
|
||||||
cname = fgets(tmp, sizeof(tmp), stdin);
|
cname = fgets(tmp, sizeof(tmp), stdin);
|
||||||
if (cname == 0 || *cname == 0)
|
if (cname == NULL || *cname == 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
len = strlen(cname);
|
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");
|
(void)fprintf(stderr, "empire: no such country\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (cpass == 0) {
|
if (cpass == NULL) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
cpass = (s_char *)getpass("Your name? ");
|
cpass = (char *)getpass("Your name? ");
|
||||||
if (cpass == 0 || *cpass == 0)
|
if (cpass == NULL || *cpass == 0)
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
printf("Note: This is echoed to the screen\n");
|
printf("Note: This is echoed to the screen\n");
|
||||||
printf("Your name? ");
|
printf("Your name? ");
|
||||||
cpass = fgets(tmp, sizeof(tmp), stdin);
|
cpass = fgets(tmp, sizeof(tmp), stdin);
|
||||||
if (cpass == 0 || *cpass == 0)
|
if (cpass == NULL || *cpass == 0)
|
||||||
return 0;
|
return 0;
|
||||||
len = strlen(cpass);
|
len = strlen(cpass);
|
||||||
if (cname[len-1] == '\n')
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
if (kill_proc) {
|
if (kill_proc) {
|
||||||
(void)sendcmd(s, KILL, (s_char *)0);
|
(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, (s_char *)0);
|
(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);
|
||||||
|
@ -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++) ;
|
for (ptr = buf; !isspace(*ptr); ptr++) ;
|
||||||
ptr++;
|
ptr++;
|
||||||
p = strchr(ptr, '\n');
|
p = strchr(ptr, '\n');
|
||||||
if (p != 0)
|
if (p != NULL)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
if (atoi(ptr) != CLIENTPROTO) {
|
if (atoi(ptr) != CLIENTPROTO) {
|
||||||
printf("Empire client out of date; get new version!\n");
|
printf("Empire client out of date; get new version!\n");
|
||||||
|
|
|
@ -77,7 +77,7 @@ static void intr(int sig);
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int ac, s_char **av)
|
main(int ac, char **av)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA WsaData;
|
WSADATA WsaData;
|
||||||
|
@ -94,16 +94,16 @@ main(int ac, s_char **av)
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
#endif
|
#endif
|
||||||
struct ioqueue server;
|
struct ioqueue server;
|
||||||
s_char *argv[128];
|
char *argv[128];
|
||||||
int i, j;
|
int i, j;
|
||||||
s_char *ptr;
|
char *ptr;
|
||||||
s_char *auxout_fname;
|
char *auxout_fname;
|
||||||
FILE *auxout_fp;
|
FILE *auxout_fp;
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
int n;
|
int n;
|
||||||
s_char *cname;
|
char *cname;
|
||||||
s_char *pname;
|
char *pname;
|
||||||
s_char *uname;
|
char *uname;
|
||||||
int send_kill = 0;
|
int send_kill = 0;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -118,11 +118,11 @@ main(int ac, s_char **av)
|
||||||
#endif
|
#endif
|
||||||
memset(argv, 0, sizeof(argv));
|
memset(argv, 0, sizeof(argv));
|
||||||
saveargv(ac, av, argv);
|
saveargv(ac, av, argv);
|
||||||
auxout_fname = 0;
|
auxout_fname = NULL;
|
||||||
auxout_fp = 0;
|
auxout_fp = NULL;
|
||||||
for (i = j = 1; i < ac; ++i) {
|
for (i = j = 1; i < ac; ++i) {
|
||||||
ptr = argv[i];
|
ptr = argv[i];
|
||||||
if (strcmp(ptr, "-2") == 0) {
|
if (strcmp(ptr, "-2") == NULL) {
|
||||||
if (i + 1 >= ac) {
|
if (i + 1 >= ac) {
|
||||||
fprintf(stderr, "-2: Missing filename!\n");
|
fprintf(stderr, "-2: Missing filename!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -130,7 +130,7 @@ main(int ac, s_char **av)
|
||||||
auxout_fname = argv[i + 1];
|
auxout_fname = argv[i + 1];
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
} else if (strcmp(ptr, "-k") == 0) {
|
} else if (strcmp(ptr, "-k") == NULL) {
|
||||||
send_kill = 1;
|
send_kill = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -200,8 +200,7 @@ main(int ac, s_char **av)
|
||||||
(void)signal(SIGPIPE, SIG_IGN);
|
(void)signal(SIGPIPE, SIG_IGN);
|
||||||
while (FD_ISSET(sock, &savemask)) {
|
while (FD_ISSET(sock, &savemask)) {
|
||||||
mask = savemask;
|
mask = savemask;
|
||||||
n = select(sock + 1, &mask, (fd_set *)0, (fd_set *)0,
|
n = select(sock + 1, &mask, NULL, NULL, NULL);
|
||||||
(struct timeval *)0);
|
|
||||||
if (interrupt) {
|
if (interrupt) {
|
||||||
if (!handleintr(sock))
|
if (!handleintr(sock))
|
||||||
break;
|
break;
|
||||||
|
@ -271,8 +270,7 @@ main(int ac, s_char **av)
|
||||||
while (1) {
|
while (1) {
|
||||||
FD_ZERO(&readfds);
|
FD_ZERO(&readfds);
|
||||||
FD_SET(sock, &readfds);
|
FD_SET(sock, &readfds);
|
||||||
n = select(sock + 1, &readfds, (fd_set *) 0, (fd_set *) 0,
|
n = select(sock + 1, &readfds, NULL, NULL, (struct timeval *)&tm);
|
||||||
(struct timeval *)&tm);
|
|
||||||
if (interrupt) {
|
if (interrupt) {
|
||||||
if (!handleintr(sock))
|
if (!handleintr(sock))
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -44,38 +44,31 @@
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#endif
|
#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 */
|
typedef short coord; /* also change NSC_COORD in nsc.h */
|
||||||
|
|
||||||
struct ioqueue;
|
struct ioqueue;
|
||||||
|
|
||||||
extern s_char empirehost[];
|
extern char empirehost[];
|
||||||
extern s_char empireport[];
|
extern char empireport[];
|
||||||
extern int interrupt;
|
extern int interrupt;
|
||||||
extern s_char num_teles[];
|
extern char num_teles[];
|
||||||
extern int sock;
|
extern int sock;
|
||||||
extern s_char *SO;
|
extern char *SO;
|
||||||
extern s_char *SE;
|
extern char *SE;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE hStdIn;
|
HANDLE hStdIn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void getsose(void);
|
void getsose(void);
|
||||||
int expect(int s, int match, s_char *buf);
|
int expect(int s, int match, char *buf);
|
||||||
int handleintr(int);
|
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 hostconnect(struct sockaddr_in *addr);
|
||||||
int hostport(s_char *name, struct sockaddr_in *addr);
|
int hostport(char *name, struct sockaddr_in *addr);
|
||||||
int login(int s, s_char *uname, s_char *cname, s_char *cpass, int kill_proc);
|
int login(int s, char *uname, char *cname, char *cpass, int kill_proc);
|
||||||
void saveargv(int ac, s_char **src, s_char **dst);
|
void saveargv(int ac, char **src, char **dst);
|
||||||
void sendcmd(int s, int cmd, s_char *arg);
|
void sendcmd(int s, int 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);
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
saveargv(int ac, s_char **src, s_char **dst)
|
saveargv(int ac, char **src, char **dst)
|
||||||
{
|
{
|
||||||
register s_char *ptr;
|
char *ptr;
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < ac; i++) {
|
for (i = 0; i < ac; i++) {
|
||||||
dst[i] = strcpy(malloc(strlen(src[i]) + 1), src[i]);
|
dst[i] = strcpy(malloc(strlen(src[i]) + 1), src[i]);
|
||||||
|
|
|
@ -49,8 +49,8 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_char num_teles[64];
|
char num_teles[64];
|
||||||
static s_char the_prompt[1024];
|
static char the_prompt[1024];
|
||||||
static int mode;
|
static int mode;
|
||||||
static int nbtu;
|
static int nbtu;
|
||||||
static int nmin;
|
static int nmin;
|
||||||
|
@ -59,17 +59,17 @@ FILE *pipe_fp;
|
||||||
int exec_fd;
|
int exec_fd;
|
||||||
|
|
||||||
static void prompt(FILE *auxfi);
|
static void prompt(FILE *auxfi);
|
||||||
static void doredir(s_char *p);
|
static void doredir(char *p);
|
||||||
static void dopipe(s_char *p);
|
static void dopipe(char *p);
|
||||||
static void doexecute(s_char *p, FILE *auxfi);
|
static void doexecute(char *p, FILE *auxfi);
|
||||||
static void output(int code, s_char *buf, FILE *auxfi);
|
static void output(int code, char *buf, FILE *auxfi);
|
||||||
static void screen(register s_char *buf);
|
static void screen(char *buf);
|
||||||
|
|
||||||
void
|
void
|
||||||
servercmd(struct ioqueue *ioq, FILE *auxfi)
|
servercmd(struct ioqueue *ioq, FILE *auxfi)
|
||||||
{
|
{
|
||||||
s_char buf[1024];
|
char buf[1024];
|
||||||
s_char *p;
|
char *p;
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
while (ioq_gets(ioq, buf, sizeof(buf))) {
|
while (ioq_gets(ioq, buf, sizeof(buf))) {
|
||||||
|
@ -110,7 +110,7 @@ servercmd(struct ioqueue *ioq, FILE *auxfi)
|
||||||
sprintf(num_teles, "(%s) ", p + 1);
|
sprintf(num_teles, "(%s) ", p + 1);
|
||||||
if (!redir_fp && !pipe_fp && !exec_fd) {
|
if (!redir_fp && !pipe_fp && !exec_fd) {
|
||||||
putchar('\07');
|
putchar('\07');
|
||||||
prompt(0);
|
prompt(NULL);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
*num_teles = '\0';
|
*num_teles = '\0';
|
||||||
|
@ -128,12 +128,12 @@ prompt(FILE *auxfi)
|
||||||
if (mode == C_PROMPT) {
|
if (mode == C_PROMPT) {
|
||||||
if (redir_fp) {
|
if (redir_fp) {
|
||||||
(void)fclose(redir_fp);
|
(void)fclose(redir_fp);
|
||||||
redir_fp = 0;
|
redir_fp = NULL;
|
||||||
} else if (pipe_fp) {
|
} else if (pipe_fp) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
(void)pclose(pipe_fp);
|
(void)pclose(pipe_fp);
|
||||||
#endif
|
#endif
|
||||||
pipe_fp = 0;
|
pipe_fp = NULL;
|
||||||
} else if (exec_fd > 0) {
|
} else if (exec_fd > 0) {
|
||||||
close(exec_fd);
|
close(exec_fd);
|
||||||
close(0);
|
close(0);
|
||||||
|
@ -155,17 +155,17 @@ prompt(FILE *auxfi)
|
||||||
* opens redir_fp if successful
|
* opens redir_fp if successful
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
doredir(s_char *p)
|
doredir(char *p)
|
||||||
{
|
{
|
||||||
s_char *how;
|
char *how;
|
||||||
s_char *name;
|
char *name;
|
||||||
s_char *tag;
|
char *tag;
|
||||||
int mode;
|
int mode;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (redir_fp) {
|
if (redir_fp) {
|
||||||
(void)fclose(redir_fp);
|
(void)fclose(redir_fp);
|
||||||
redir_fp = 0;
|
redir_fp = NULL;
|
||||||
}
|
}
|
||||||
how = p++;
|
how = p++;
|
||||||
if (*p && ((*p == '>') || (*p == '!')))
|
if (*p && ((*p == '>') || (*p == '!')))
|
||||||
|
@ -207,9 +207,9 @@ doredir(s_char *p)
|
||||||
* opens "pipe_fp" if successful
|
* opens "pipe_fp" if successful
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
dopipe(s_char *p)
|
dopipe(char *p)
|
||||||
{
|
{
|
||||||
s_char *tag;
|
char *tag;
|
||||||
|
|
||||||
if (*p == '|')
|
if (*p == '|')
|
||||||
p++;
|
p++;
|
||||||
|
@ -226,7 +226,7 @@ dopipe(s_char *p)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if ((pipe_fp = popen(p, "w")) == 0) {
|
if ((pipe_fp = popen(p, "w")) == NULL) {
|
||||||
#else
|
#else
|
||||||
if (1) {
|
if (1) {
|
||||||
#endif
|
#endif
|
||||||
|
@ -237,10 +237,10 @@ dopipe(s_char *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
doexecute(s_char *p, FILE *auxfi)
|
doexecute(char *p, FILE *auxfi)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
s_char *tag;
|
char *tag;
|
||||||
|
|
||||||
tag = gettag(p);
|
tag = gettag(p);
|
||||||
while (*p && isspace(*p))
|
while (*p && isspace(*p))
|
||||||
|
@ -251,7 +251,7 @@ doexecute(s_char *p, FILE *auxfi)
|
||||||
p);
|
p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (p == 0) {
|
if (p == NULL) {
|
||||||
fprintf(stderr, "Null file to execute\n");
|
fprintf(stderr, "Null file to execute\n");
|
||||||
free(tag);
|
free(tag);
|
||||||
return;
|
return;
|
||||||
|
@ -280,7 +280,7 @@ doexecute(s_char *p, FILE *auxfi)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
output(int code, s_char *buf, FILE *auxfi)
|
output(int code, char *buf, FILE *auxfi)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case C_NOECHO:
|
case C_NOECHO:
|
||||||
|
@ -338,10 +338,10 @@ output(int code, s_char *buf, FILE *auxfi)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
screen(register s_char *buf)
|
screen(char *buf)
|
||||||
{
|
{
|
||||||
register s_char *sop;
|
char *sop;
|
||||||
register s_char c;
|
char c;
|
||||||
|
|
||||||
while ((c = *buf++)) {
|
while ((c = *buf++)) {
|
||||||
if (c & 0x80) {
|
if (c & 0x80) {
|
||||||
|
|
|
@ -49,10 +49,10 @@
|
||||||
int
|
int
|
||||||
serverio(int s, struct ioqueue *ioq)
|
serverio(int s, struct ioqueue *ioq)
|
||||||
{
|
{
|
||||||
s_char *buf;
|
char *buf;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if ((buf = malloc(ioq->bsize)) == 0) {
|
if ((buf = malloc(ioq->bsize)) == NULL) {
|
||||||
fprintf(stderr, "malloc server i/o failed\n");
|
fprintf(stderr, "malloc server i/o failed\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ serverio(int s, struct ioqueue *ioq)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (n != ioq->bsize)
|
if (n != ioq->bsize)
|
||||||
buf = (s_char *)realloc(buf, n);
|
buf = (char *)realloc(buf, n);
|
||||||
ioq_write(ioq, buf, n);
|
ioq_write(ioq, buf, n);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ io_init(void)
|
||||||
taglist = NULL;
|
taglist = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
s_char *
|
char *
|
||||||
gettag(s_char *p)
|
gettag(char *p)
|
||||||
{
|
{
|
||||||
struct tagstruct *tag1, *tag2;
|
struct tagstruct *tag1, *tag2;
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,13 @@
|
||||||
#define _TAGS_H_
|
#define _TAGS_H_
|
||||||
|
|
||||||
struct tagstruct {
|
struct tagstruct {
|
||||||
s_char *item;
|
char *item;
|
||||||
struct tagstruct *next;
|
struct tagstruct *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct tagstruct *taglist;
|
extern struct tagstruct *taglist;
|
||||||
|
|
||||||
void io_init(void);
|
void io_init(void);
|
||||||
s_char *gettag(s_char *p);
|
char *gettag(char *p);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -49,10 +49,10 @@ termio(int fd, int sock, FILE *auxfi)
|
||||||
{
|
{
|
||||||
static char exec[] = "execute";
|
static char exec[] = "execute";
|
||||||
static char buf[4096];
|
static char buf[4096];
|
||||||
s_char out[4096];
|
char out[4096];
|
||||||
int i, n;
|
int i, n;
|
||||||
s_char *ptr;
|
char *ptr;
|
||||||
s_char *p, *q, *r, *s, *t;
|
char *p, *q, *r, *s, *t;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
int prespace, exec_com, inarg, quoted, tagging;
|
int prespace, exec_com, inarg, quoted, tagging;
|
||||||
struct tagstruct *tag;
|
struct tagstruct *tag;
|
||||||
|
@ -88,7 +88,7 @@ termio(int fd, int sock, FILE *auxfi)
|
||||||
p[0] = c;
|
p[0] = c;
|
||||||
p[1] = '\0';
|
p[1] = '\0';
|
||||||
if (c != 10)
|
if (c != 10)
|
||||||
ReadConsole(hStdIn, &p[0], sizeof(buf) - i, &n, NULL);
|
ReadConsole(hStdIn, p, sizeof(buf) - i, &n, NULL);
|
||||||
else
|
else
|
||||||
putchar(c);
|
putchar(c);
|
||||||
/* Strip off the CRLF to just LF */
|
/* Strip off the CRLF to just LF */
|
||||||
|
@ -134,7 +134,7 @@ termio(int fd, int sock, FILE *auxfi)
|
||||||
if (*p == '\n') {
|
if (*p == '\n') {
|
||||||
if (tagging) {
|
if (tagging) {
|
||||||
tag = (struct tagstruct *)malloc(sizeof(struct tagstruct));
|
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;
|
tag->next = taglist;
|
||||||
taglist = tag;
|
taglist = tag;
|
||||||
t = tag->item;
|
t = tag->item;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue