git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@734 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1996-09-14 02:13:56 +00:00
parent 6ba7a91147
commit aface2fa24

View File

@@ -55,7 +55,7 @@ RCSID("$Id$");
#include "types.h" #include "types.h"
#include "general.h" #include "general.h"
#define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x)) #define strip(x) ((my_want_state_is_wont(TELOPT_BINARY)) ? ((x)&0x7f) : (x))
static unsigned char subbuffer[SUBBUFSIZE], static unsigned char subbuffer[SUBBUFSIZE],
@@ -143,25 +143,12 @@ int kludgelinemode = 1;
*/ */
Clocks clocks; Clocks clocks;
#ifdef notdef
Modelist modelist[] = {
{ "telnet command mode", COMMAND_LINE },
{ "character-at-a-time mode", 0 },
{ "character-at-a-time mode (local echo)", LOCAL_ECHO|LOCAL_CHARS },
{ "line-by-line mode (remote echo)", LINE | LOCAL_CHARS },
{ "line-by-line mode", LINE | LOCAL_ECHO | LOCAL_CHARS },
{ "line-by-line mode (local echoing suppressed)", LINE | LOCAL_CHARS },
{ "3270 mode", 0 },
};
#endif
/* /*
* Initialize telnet environment. * Initialize telnet environment.
*/ */
void void
init_telnet() init_telnet()
{ {
env_init(); env_init();
@@ -188,57 +175,7 @@ init_telnet()
flushline = 1; flushline = 1;
telrcv_state = TS_DATA; telrcv_state = TS_DATA;
} }
#ifdef notdef
#include <varargs.h>
/*VARARGS*/
static void
printring(va_alist)
va_dcl
{
va_list ap;
char buffer[100]; /* where things go */
char *ptr;
char *format;
char *string;
Ring *ring;
int i;
va_start(ap);
ring = va_arg(ap, Ring *);
format = va_arg(ap, char *);
ptr = buffer;
while ((i = *format++) != 0) {
if (i == '%') {
i = *format++;
switch (i) {
case 'c':
*ptr++ = va_arg(ap, int);
break;
case 's':
string = va_arg(ap, char *);
ring_supply_data(ring, buffer, ptr-buffer);
ring_supply_data(ring, string, strlen(string));
ptr = buffer;
break;
case 0:
ExitString("printring: trailing %%.\n", 1);
/*NOTREACHED*/
default:
ExitString("printring: unknown format character.\n", 1);
/*NOTREACHED*/
}
} else {
*ptr++ = i;
}
}
ring_supply_data(ring, buffer, ptr-buffer);
}
#endif
/* /*
* These routines are in charge of sending option negotiations * These routines are in charge of sending option negotiations
@@ -248,9 +185,8 @@ printring(va_alist)
* is in disagreement as to what the current state should be. * is in disagreement as to what the current state should be.
*/ */
void void
send_do(c, init) send_do(int c, int init)
register int c, init;
{ {
if (init) { if (init) {
if (((do_dont_resp[c] == 0) && my_state_is_do(c)) || if (((do_dont_resp[c] == 0) && my_state_is_do(c)) ||
@@ -264,9 +200,8 @@ send_do(c, init)
printoption("SENT", DO, c); printoption("SENT", DO, c);
} }
void void
send_dont(c, init) send_dont(int c, int init)
register int c, init;
{ {
if (init) { if (init) {
if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) || if (((do_dont_resp[c] == 0) && my_state_is_dont(c)) ||
@@ -280,9 +215,8 @@ send_dont(c, init)
printoption("SENT", DONT, c); printoption("SENT", DONT, c);
} }
void void
send_will(c, init) send_will(int c, int init)
register int c, init;
{ {
if (init) { if (init) {
if (((will_wont_resp[c] == 0) && my_state_is_will(c)) || if (((will_wont_resp[c] == 0) && my_state_is_will(c)) ||
@@ -296,9 +230,8 @@ send_will(c, init)
printoption("SENT", WILL, c); printoption("SENT", WILL, c);
} }
void void
send_wont(c, init) send_wont(int c, int init)
register int c, init;
{ {
if (init) { if (init) {
if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) || if (((will_wont_resp[c] == 0) && my_state_is_wont(c)) ||
@@ -313,9 +246,8 @@ send_wont(c, init)
} }
void void
willoption(option) willoption(int option)
int option;
{ {
int new_state_ok = 0; int new_state_ok = 0;
@@ -429,9 +361,8 @@ wontoption(int option)
set_my_state_dont(option); set_my_state_dont(option);
} }
static void static void
dooption(option) dooption(int option)
int option;
{ {
int new_state_ok = 0; int new_state_ok = 0;
@@ -591,12 +522,11 @@ dontoption(int option)
static char *name_unknown = "UNKNOWN"; static char *name_unknown = "UNKNOWN";
static char *unknown[] = { 0, 0 }; static char *unknown[] = { 0, 0 };
char ** char **
mklist(buf, name) mklist(char *buf, char *name)
char *buf, *name;
{ {
register int n; int n;
register char c, *cp, **argvp, *cp2, **argv, **avt; char c, *cp, **argvp, *cp2, **argv, **avt;
if (name) { if (name) {
if ((int)strlen(name) > 40) { if ((int)strlen(name) > 40) {
@@ -703,12 +633,11 @@ mklist(buf, name)
return(unknown); return(unknown);
} }
int int
is_unique(name, as, ae) is_unique(char *name, char **as, char **ae)
register char *name, **as, **ae;
{ {
register char **ap; char **ap;
register int n; int n;
n = strlen(name) + 1; n = strlen(name) + 1;
for (ap = as; ap < ae; ap++) for (ap = as; ap < ae; ap++)
@@ -783,7 +712,7 @@ gettermname()
* Linemode * Linemode
*/ */
static void static void
suboption() suboption()
{ {
unsigned char subchar; unsigned char subchar;
@@ -1041,10 +970,8 @@ suboption()
static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE }; static unsigned char str_lm[] = { IAC, SB, TELOPT_LINEMODE, 0, 0, IAC, SE };
void void
lm_will(cmd, len) lm_will(unsigned char *cmd, int len)
unsigned char *cmd;
int len;
{ {
if (len < 1) { if (len < 1) {
/*@*/ printf("lm_will: no command!!!\n"); /* Should not happen... */ /*@*/ printf("lm_will: no command!!!\n"); /* Should not happen... */
@@ -1064,10 +991,8 @@ lm_will(cmd, len)
} }
} }
void void
lm_wont(cmd, len) lm_wont(unsigned char *cmd, int len)
unsigned char *cmd;
int len;
{ {
if (len < 1) { if (len < 1) {
/*@*/ printf("lm_wont: no command!!!\n"); /* Should not happen... */ /*@*/ printf("lm_wont: no command!!!\n"); /* Should not happen... */
@@ -1081,10 +1006,8 @@ lm_wont(cmd, len)
} }
} }
void void
lm_do(cmd, len) lm_do(unsigned char *cmd, int len)
unsigned char *cmd;
int len;
{ {
if (len < 1) { if (len < 1) {
/*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */ /*@*/ printf("lm_do: no command!!!\n"); /* Should not happen... */
@@ -1104,10 +1027,8 @@ lm_do(cmd, len)
} }
} }
void void
lm_dont(cmd, len) lm_dont(unsigned char *cmd, int len)
unsigned char *cmd;
int len;
{ {
if (len < 1) { if (len < 1) {
/*@*/ printf("lm_dont: no command!!!\n"); /* Should not happen... */ /*@*/ printf("lm_dont: no command!!!\n"); /* Should not happen... */
@@ -1125,10 +1046,8 @@ static unsigned char str_lm_mode[] = {
IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE IAC, SB, TELOPT_LINEMODE, LM_MODE, 0, IAC, SE
}; };
void void
lm_mode(cmd, len, init) lm_mode(unsigned char *cmd, int len, int init)
unsigned char *cmd;
int len, init;
{ {
if (len != 1) if (len != 1)
return; return;
@@ -1148,7 +1067,7 @@ lm_mode(cmd, len, init)
setconnmode(0); /* set changed mode */ setconnmode(0); /* set changed mode */
} }
/* /*
* slc() * slc()
@@ -1167,10 +1086,10 @@ struct spc {
#define SLC_RVALUE 2 #define SLC_RVALUE 2
static int slc_mode = SLC_EXPORT; static int slc_mode = SLC_EXPORT;
void void
slc_init() slc_init()
{ {
register struct spc *spcp; struct spc *spcp;
localchars = 1; localchars = 1;
for (spcp = spc_data; spcp < &spc_data[NSLC+1]; spcp++) { for (spcp = spc_data; spcp < &spc_data[NSLC+1]; spcp++) {
@@ -1269,7 +1188,7 @@ slc_import(int def)
void void
slc_export() slc_export()
{ {
register struct spc *spcp; struct spc *spcp;
TerminalDefaultChars(); TerminalDefaultChars();
@@ -1293,8 +1212,8 @@ slc_export()
void void
slc(unsigned char *cp, int len) slc(unsigned char *cp, int len)
{ {
register struct spc *spcp; struct spc *spcp;
register int func,level; int func,level;
slc_start_reply(); slc_start_reply();
@@ -1361,7 +1280,7 @@ slc(unsigned char *cp, int len)
void void
slc_check() slc_check()
{ {
register struct spc *spcp; struct spc *spcp;
slc_start_reply(); slc_start_reply();
for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) { for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) {
@@ -1406,7 +1325,7 @@ slc_add_reply(unsigned char func, unsigned char flags, cc_t value)
void void
slc_end_reply() slc_end_reply()
{ {
register int len; int len;
*slc_replyp++ = IAC; *slc_replyp++ = IAC;
*slc_replyp++ = SE; *slc_replyp++ = SE;
@@ -1423,7 +1342,7 @@ slc_end_reply()
int int
slc_update() slc_update()
{ {
register struct spc *spcp; struct spc *spcp;
int need_update = 0; int need_update = 0;
for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) { for (spcp = &spc_data[1]; spcp < &spc_data[NSLC+1]; spcp++) {
@@ -1443,13 +1362,11 @@ slc_update()
# define old_env_value OLD_ENV_VALUE # define old_env_value OLD_ENV_VALUE
#endif #endif
void void
env_opt(buf, len) env_opt(unsigned char *buf, int len)
register unsigned char *buf;
register int len;
{ {
register unsigned char *ep = 0, *epc = 0; unsigned char *ep = 0, *epc = 0;
register int i; int i;
switch(buf[0]&0xff) { switch(buf[0]&0xff) {
case TELQUAL_SEND: case TELQUAL_SEND:
@@ -1508,7 +1425,7 @@ unsigned char *opt_reply;
unsigned char *opt_replyp; unsigned char *opt_replyp;
unsigned char *opt_replyend; unsigned char *opt_replyend;
void void
env_opt_start() env_opt_start()
{ {
if (opt_reply) if (opt_reply)
@@ -1528,7 +1445,7 @@ env_opt_start()
*opt_replyp++ = TELQUAL_IS; *opt_replyp++ = TELQUAL_IS;
} }
void void
env_opt_start_info() env_opt_start_info()
{ {
env_opt_start(); env_opt_start();
@@ -1536,11 +1453,10 @@ env_opt_start_info()
opt_replyp[-1] = TELQUAL_INFO; opt_replyp[-1] = TELQUAL_INFO;
} }
void void
env_opt_add(ep) env_opt_add(unsigned char *ep)
register unsigned char *ep;
{ {
register unsigned char *vp, c; unsigned char *vp, c;
if (opt_reply == NULL) /*XXX*/ if (opt_reply == NULL) /*XXX*/
return; /*XXX*/ return; /*XXX*/
@@ -1561,7 +1477,7 @@ env_opt_add(ep)
if (opt_replyp + (vp ? strlen((char *)vp) : 0) + if (opt_replyp + (vp ? strlen((char *)vp) : 0) +
strlen((char *)ep) + 6 > opt_replyend) strlen((char *)ep) + 6 > opt_replyend)
{ {
register int len; int len;
opt_replyend += OPT_REPLY_SIZE; opt_replyend += OPT_REPLY_SIZE;
len = opt_replyend - opt_reply; len = opt_replyend - opt_reply;
opt_reply = (unsigned char *)realloc(opt_reply, len); opt_reply = (unsigned char *)realloc(opt_reply, len);
@@ -1610,9 +1526,8 @@ env_opt_add(ep)
} }
} }
int int
opt_welldefined(ep) opt_welldefined(char *ep)
char *ep;
{ {
if ((strcmp(ep, "USER") == 0) || if ((strcmp(ep, "USER") == 0) ||
(strcmp(ep, "DISPLAY") == 0) || (strcmp(ep, "DISPLAY") == 0) ||
@@ -1623,11 +1538,11 @@ opt_welldefined(ep)
return(1); return(1);
return(0); return(0);
} }
void
env_opt_end(emptyok) void
register int emptyok; env_opt_end(int emptyok)
{ {
register int len; int len;
len = opt_replyp - opt_reply + 2; len = opt_replyp - opt_reply + 2;
if (emptyok || len > 6) { if (emptyok || len > 6) {
@@ -1645,14 +1560,14 @@ env_opt_end(emptyok)
} }
} }
int
int
telrcv() telrcv()
{ {
register int c; int c;
register int scc; int scc;
register unsigned char *sbp; unsigned char *sbp;
int count; int count;
int returnValue = 0; int returnValue = 0;
@@ -1879,7 +1794,7 @@ process_iac:
static int bol = 1, local = 0; static int bol = 1, local = 0;
int int
rlogin_susp() rlogin_susp()
{ {
if (local) { if (local) {
@@ -1891,7 +1806,7 @@ rlogin_susp()
return(0); return(0);
} }
static int static int
telsnd() telsnd()
{ {
int tcc; int tcc;
@@ -1902,8 +1817,8 @@ telsnd()
tcc = 0; tcc = 0;
count = 0; count = 0;
while (NETROOM() > 2) { while (NETROOM() > 2) {
register int sc; int sc;
register int c; int c;
if (tcc == 0) { if (tcc == 0) {
if (count) { if (count) {
@@ -2031,7 +1946,7 @@ telsnd()
ring_consumed(&ttyiring, count); ring_consumed(&ttyiring, count);
return returnValue||count; /* Non-zero if we did anything */ return returnValue||count; /* Non-zero if we did anything */
} }
/* /*
* Scheduler() * Scheduler()
* *
@@ -2042,9 +1957,8 @@ telsnd()
*/ */
int int
Scheduler(block) Scheduler(int block) /* should we block in the select ? */
int block; /* should we block in the select ? */
{ {
/* One wants to be a bit careful about setting returnValue /* One wants to be a bit careful about setting returnValue
* to one, since a one implies we did some useful work, * to one, since a one implies we did some useful work,
@@ -2089,13 +2003,12 @@ Scheduler(block)
} }
return returnValue; return returnValue;
} }
/* /*
* Select from tty and network... * Select from tty and network...
*/ */
void void
telnet(user) telnet(char *user)
char *user;
{ {
sys_telnet_init(); sys_telnet_init();
@@ -2150,49 +2063,6 @@ telnet(user)
} }
} }
} }
#if 0 /* XXX - this not being in is a bug */
/*
* nextitem()
*
* Return the address of the next "item" in the TELNET data
* stream. This will be the address of the next character if
* the current address is a user data character, or it will
* be the address of the character following the TELNET command
* if the current address is a TELNET IAC ("I Am a Command")
* character.
*/
static char *
nextitem(current)
char *current;
{
if ((*current&0xff) != IAC) {
return current+1;
}
switch (*(current+1)&0xff) {
case DO:
case DONT:
case WILL:
case WONT:
return current+3;
case SB: /* loop forever looking for the SE */
{
register char *look = current+2;
for (;;) {
if ((*look++&0xff) == IAC) {
if ((*look++&0xff) == SE) {
return look;
}
}
}
}
default:
return current+2;
}
}
#endif /* 0 */
/* /*
* netclear() * netclear()
@@ -2211,11 +2081,11 @@ nextitem(current)
* us in any case. * us in any case.
*/ */
static void static void
netclear() netclear()
{ {
#if 0 /* XXX */ #if 0 /* XXX */
register char *thisitem, *next; char *thisitem, *next;
char *good; char *good;
#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \ #define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL)) ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
@@ -2249,12 +2119,12 @@ netclear()
#endif /* 0 */ #endif /* 0 */
} }
/* /*
* These routines add various telnet commands to the data stream. * These routines add various telnet commands to the data stream.
*/ */
static void static void
doflush() doflush()
{ {
NET2ADD(IAC, DO); NET2ADD(IAC, DO);
@@ -2266,7 +2136,7 @@ doflush()
printoption("SENT", DO, TELOPT_TM); printoption("SENT", DO, TELOPT_TM);
} }
void void
xmitAO() xmitAO()
{ {
NET2ADD(IAC, AO); NET2ADD(IAC, AO);
@@ -2277,14 +2147,14 @@ xmitAO()
} }
void void
xmitEL() xmitEL()
{ {
NET2ADD(IAC, EL); NET2ADD(IAC, EL);
printoption("SENT", IAC, EL); printoption("SENT", IAC, EL);
} }
void void
xmitEC() xmitEC()
{ {
NET2ADD(IAC, EC); NET2ADD(IAC, EC);
@@ -2292,7 +2162,7 @@ xmitEC()
} }
int int
dosynch() dosynch()
{ {
netclear(); /* clear the path to the network */ netclear(); /* clear the path to the network */
@@ -2305,11 +2175,11 @@ dosynch()
int want_status_response = 0; int want_status_response = 0;
int int
get_status() get_status()
{ {
unsigned char tmp[16]; unsigned char tmp[16];
register unsigned char *cp; unsigned char *cp;
if (my_want_state_is_dont(TELOPT_STATUS)) { if (my_want_state_is_dont(TELOPT_STATUS)) {
printf("Remote side does not support STATUS option\n"); printf("Remote side does not support STATUS option\n");
@@ -2331,7 +2201,7 @@ get_status()
return 1; return 1;
} }
void void
intp() intp()
{ {
NET2ADD(IAC, IP); NET2ADD(IAC, IP);
@@ -2345,7 +2215,7 @@ intp()
} }
} }
void void
sendbrk() sendbrk()
{ {
NET2ADD(IAC, BREAK); NET2ADD(IAC, BREAK);
@@ -2359,7 +2229,7 @@ sendbrk()
} }
} }
void void
sendabort() sendabort()
{ {
NET2ADD(IAC, ABORT); NET2ADD(IAC, ABORT);
@@ -2373,7 +2243,7 @@ sendabort()
} }
} }
void void
sendsusp() sendsusp()
{ {
NET2ADD(IAC, SUSP); NET2ADD(IAC, SUSP);
@@ -2387,14 +2257,14 @@ sendsusp()
} }
} }
void void
sendeof() sendeof()
{ {
NET2ADD(IAC, xEOF); NET2ADD(IAC, xEOF);
printoption("SENT", IAC, xEOF); printoption("SENT", IAC, xEOF);
} }
void void
sendayt() sendayt()
{ {
NET2ADD(IAC, AYT); NET2ADD(IAC, AYT);
@@ -2405,12 +2275,12 @@ sendayt()
* Send a window size update to the remote system. * Send a window size update to the remote system.
*/ */
void void
sendnaws() sendnaws()
{ {
long rows, cols; long rows, cols;
unsigned char tmp[16]; unsigned char tmp[16];
register unsigned char *cp; unsigned char *cp;
if (my_state_is_wont(TELOPT_NAWS)) if (my_state_is_wont(TELOPT_NAWS))
return; return;
@@ -2437,9 +2307,8 @@ sendnaws()
} }
} }
void void
tel_enter_binary(rw) tel_enter_binary(int rw)
int rw;
{ {
if (rw&1) if (rw&1)
send_do(TELOPT_BINARY, 1); send_do(TELOPT_BINARY, 1);
@@ -2447,9 +2316,8 @@ tel_enter_binary(rw)
send_will(TELOPT_BINARY, 1); send_will(TELOPT_BINARY, 1);
} }
void void
tel_leave_binary(rw) tel_leave_binary(int rw)
int rw;
{ {
if (rw&1) if (rw&1)
send_dont(TELOPT_BINARY, 1); send_dont(TELOPT_BINARY, 1);