mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
First crack at an implementation of TELOPT_BINARY, which apparently
RFC 1123 (host requirements) says is compulsory. [originally from svn r2358]
This commit is contained in:
parent
7f7e3f539c
commit
6adef8429a
18
telnet.c
18
telnet.c
@ -86,7 +86,9 @@
|
|||||||
#define LF 10
|
#define LF 10
|
||||||
#define NUL 0
|
#define NUL 0
|
||||||
|
|
||||||
#define iswritable(x) ( (x) != IAC && (x) != CR )
|
#define iswritable(x) \
|
||||||
|
( (x) != IAC && \
|
||||||
|
(telnet->opt_states[o_we_bin.index] == ACTIVE || (x) != CR))
|
||||||
|
|
||||||
static char *telopt(int opt)
|
static char *telopt(int opt)
|
||||||
{
|
{
|
||||||
@ -157,6 +159,8 @@ enum {
|
|||||||
OPTINDEX_ECHO,
|
OPTINDEX_ECHO,
|
||||||
OPTINDEX_WE_SGA,
|
OPTINDEX_WE_SGA,
|
||||||
OPTINDEX_THEY_SGA,
|
OPTINDEX_THEY_SGA,
|
||||||
|
OPTINDEX_WE_BIN,
|
||||||
|
OPTINDEX_THEY_BIN,
|
||||||
NUM_OPTS
|
NUM_OPTS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -178,10 +182,14 @@ static const struct Opt o_we_sga =
|
|||||||
{ WILL, WONT, DO, DONT, TELOPT_SGA, OPTINDEX_WE_SGA, REQUESTED };
|
{ WILL, WONT, DO, DONT, TELOPT_SGA, OPTINDEX_WE_SGA, REQUESTED };
|
||||||
static const struct Opt o_they_sga =
|
static const struct Opt o_they_sga =
|
||||||
{ DO, DONT, WILL, WONT, TELOPT_SGA, OPTINDEX_THEY_SGA, REQUESTED };
|
{ DO, DONT, WILL, WONT, TELOPT_SGA, OPTINDEX_THEY_SGA, REQUESTED };
|
||||||
|
static const struct Opt o_we_bin =
|
||||||
|
{ WILL, WONT, DO, DONT, TELOPT_BINARY, OPTINDEX_WE_BIN, INACTIVE };
|
||||||
|
static const struct Opt o_they_bin =
|
||||||
|
{ DO, DONT, WILL, WONT, TELOPT_BINARY, OPTINDEX_THEY_BIN, INACTIVE };
|
||||||
|
|
||||||
static const struct Opt *const opts[] = {
|
static const struct Opt *const opts[] = {
|
||||||
&o_naws, &o_tspeed, &o_ttype, &o_oenv, &o_nenv, &o_echo,
|
&o_naws, &o_tspeed, &o_ttype, &o_oenv, &o_nenv, &o_echo,
|
||||||
&o_we_sga, &o_they_sga, NULL
|
&o_we_sga, &o_they_sga, &o_we_bin, &o_they_bin, NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct telnet_tag {
|
typedef struct telnet_tag {
|
||||||
@ -521,7 +529,7 @@ static void do_telnet_read(Telnet telnet, char *buf, int len)
|
|||||||
else if (c == DM)
|
else if (c == DM)
|
||||||
telnet->in_synch = 0;
|
telnet->in_synch = 0;
|
||||||
#endif
|
#endif
|
||||||
if (c == CR)
|
if (c == CR && telnet->opt_states[o_they_bin.index] != ACTIVE)
|
||||||
telnet->state = SEENCR;
|
telnet->state = SEENCR;
|
||||||
else
|
else
|
||||||
telnet->state = TOP_LEVEL;
|
telnet->state = TOP_LEVEL;
|
||||||
@ -865,6 +873,10 @@ static void telnet_special(void *handle, Telnet_Special code)
|
|||||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||||
break;
|
break;
|
||||||
case TS_EOL:
|
case TS_EOL:
|
||||||
|
/* In BINARY mode, CR-LF becomes just CR. */
|
||||||
|
if (telnet->opt_states[o_we_bin.index] == ACTIVE)
|
||||||
|
telnet->bufsize = sk_write(telnet->s, "\r", 2);
|
||||||
|
else
|
||||||
telnet->bufsize = sk_write(telnet->s, "\r\n", 2);
|
telnet->bufsize = sk_write(telnet->s, "\r\n", 2);
|
||||||
break;
|
break;
|
||||||
case TS_SYNCH:
|
case TS_SYNCH:
|
||||||
|
Loading…
Reference in New Issue
Block a user