1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

New system for handling SSH terminal modes.

I've introduced a new POD struct type 'ssh_ttymodes' which stores an
encoding of everything you can specify in the "pty-req" packet or the
SSH-1 equivalent. This allows me to split up
write_ttymodes_to_packet_from_conf() into two separate functions, one
to parse all the ttymode data out of a Conf (and a Seat for fallback)
and return one of those structures, and the other to write it into an
SSH packet.

While I'm at it, I've moved the special case of terminal speeds into
the same mechanism, simplifying the call sites in both versions of the
SSH protocol.

The new master definition of all terminal modes lives in a header
file, with an ifdef around each item, so that later on I'll be able to
include it in a context that only enumerates the modes supported by
the particular target Unix platform.
This commit is contained in:
Simon Tatham
2018-10-12 19:25:59 +01:00
parent 431f92ade9
commit dead35dd0f
5 changed files with 292 additions and 128 deletions

View File

@ -28,7 +28,6 @@ struct ssh1_connection_state {
int got_pty;
int echoedit;
int ospeed, ispeed;
int stdout_throttling;
int session_ready;
int session_eof_pending, session_eof_sent, session_terminated;
@ -709,11 +708,6 @@ static void ssh1_connection_process_queue(PacketProtocolLayer *ppl)
s->portfwdmgr_configured = TRUE;
if (!conf_get_int(s->conf, CONF_nopty)) {
/* Unpick the terminal-speed string. */
/* XXX perhaps we should allow no speeds to be sent. */
s->ospeed = 38400; s->ispeed = 38400; /* last-resort defaults */
sscanf(conf_get_str(s->conf, CONF_termspeed), "%d,%d",
&s->ospeed, &s->ispeed);
/* Send the pty request. */
pktout = ssh_bpp_new_pktout(s->ppl.bpp, SSH1_CMSG_REQUEST_PTY);
put_stringz(pktout, conf_get_str(s->conf, CONF_termtype));
@ -723,14 +717,13 @@ static void ssh1_connection_process_queue(PacketProtocolLayer *ppl)
s->term_height_orig = s->term_height;
put_uint32(pktout, 0); /* width in pixels */
put_uint32(pktout, 0); /* height in pixels */
write_ttymodes_to_packet_from_conf(
BinarySink_UPCAST(pktout), s->ppl.seat, s->conf,
1, s->ospeed, s->ispeed);
write_ttymodes_to_packet(
BinarySink_UPCAST(pktout), 1,
get_ttymodes_from_conf(s->ppl.seat, s->conf));
pq_push(s->ppl.out_pq, pktout);
crMaybeWaitUntilV((pktin = ssh1_connection_pop(s)) != NULL);
if (pktin->type == SSH1_SMSG_SUCCESS) {
ppl_logevent(("Allocated pty (ospeed %dbps, ispeed %dbps)",
s->ospeed, s->ispeed));
ppl_logevent(("Allocated pty"));
s->got_pty = TRUE;
} else if (pktin->type == SSH1_SMSG_FAILURE) {
ppl_printf(("Server refused to allocate pty\r\n"));