2001-01-24 17:08:20 +03:00
|
|
|
/*
|
|
|
|
* ldisc.c: PuTTY line discipline. Sits between the input coming
|
|
|
|
* from keypresses in the window, and the output channel leading to
|
|
|
|
* the back end. Implements echo and/or local line editing,
|
|
|
|
* depending on what's currently configured.
|
|
|
|
*/
|
|
|
|
|
1999-11-09 15:05:34 +03:00
|
|
|
#include <stdio.h>
|
1999-11-22 13:07:24 +03:00
|
|
|
#include <ctype.h>
|
2014-11-22 13:37:14 +03:00
|
|
|
#include <assert.h>
|
1999-11-09 15:05:34 +03:00
|
|
|
|
|
|
|
#include "putty.h"
|
2002-10-22 20:11:33 +04:00
|
|
|
#include "terminal.h"
|
2002-10-26 15:08:59 +04:00
|
|
|
#include "ldisc.h"
|
2002-10-26 14:16:19 +04:00
|
|
|
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
#define ECHOING (ldisc->localecho == FORCE_ON || \
|
|
|
|
(ldisc->localecho == AUTO && \
|
2018-09-11 18:23:38 +03:00
|
|
|
(backend_ldisc_option_state(ldisc->backend, LD_ECHO) || \
|
2002-10-26 14:16:19 +04:00
|
|
|
term_ldisc(ldisc->term, LD_ECHO))))
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
#define EDITING (ldisc->localedit == FORCE_ON || \
|
|
|
|
(ldisc->localedit == AUTO && \
|
2018-09-11 18:23:38 +03:00
|
|
|
(backend_ldisc_option_state(ldisc->backend, LD_EDIT) || \
|
2002-10-26 14:16:19 +04:00
|
|
|
term_ldisc(ldisc->term, LD_EDIT))))
|
1999-11-09 15:05:34 +03:00
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
static void c_write(Ldisc *ldisc, const void *buf, int len)
|
2001-05-06 18:35:20 +04:00
|
|
|
{
|
2003-04-12 13:19:09 +04:00
|
|
|
from_backend(ldisc->frontend, 0, buf, len);
|
2000-10-20 17:51:46 +04:00
|
|
|
}
|
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
static int plen(Ldisc *ldisc, unsigned char c)
|
2001-05-06 18:35:20 +04:00
|
|
|
{
|
2002-10-26 14:16:19 +04:00
|
|
|
if ((c >= 32 && c <= 126) || (c >= 160 && !in_utf(ldisc->term)))
|
2001-05-06 18:35:20 +04:00
|
|
|
return 1;
|
1999-11-09 15:05:34 +03:00
|
|
|
else if (c < 128)
|
2001-05-06 18:35:20 +04:00
|
|
|
return 2; /* ^x for some x */
|
2004-05-22 14:36:50 +04:00
|
|
|
else if (in_utf(ldisc->term) && c >= 0xC0)
|
|
|
|
return 1; /* UTF-8 introducer character
|
|
|
|
* (FIXME: combining / wide chars) */
|
|
|
|
else if (in_utf(ldisc->term) && c >= 0x80 && c < 0xC0)
|
|
|
|
return 0; /* UTF-8 followup character */
|
1999-11-09 15:05:34 +03:00
|
|
|
else
|
2004-05-22 14:36:50 +04:00
|
|
|
return 4; /* <XY> hex representation */
|
1999-11-09 15:05:34 +03:00
|
|
|
}
|
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
static void pwrite(Ldisc *ldisc, unsigned char c)
|
2001-05-06 18:35:20 +04:00
|
|
|
{
|
2004-05-22 14:36:50 +04:00
|
|
|
if ((c >= 32 && c <= 126) ||
|
|
|
|
(!in_utf(ldisc->term) && c >= 0xA0) ||
|
|
|
|
(in_utf(ldisc->term) && c >= 0x80)) {
|
2018-05-26 10:31:34 +03:00
|
|
|
c_write(ldisc, &c, 1);
|
1999-11-09 15:05:34 +03:00
|
|
|
} else if (c < 128) {
|
2001-05-06 18:35:20 +04:00
|
|
|
char cc[2];
|
|
|
|
cc[1] = (c == 127 ? '?' : c + 0x40);
|
|
|
|
cc[0] = '^';
|
2002-10-26 14:16:19 +04:00
|
|
|
c_write(ldisc, cc, 2);
|
1999-11-09 15:05:34 +03:00
|
|
|
} else {
|
2001-05-06 18:35:20 +04:00
|
|
|
char cc[5];
|
|
|
|
sprintf(cc, "<%02X>", c);
|
2002-10-26 14:16:19 +04:00
|
|
|
c_write(ldisc, cc, 4);
|
1999-11-09 15:05:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
static int char_start(Ldisc *ldisc, unsigned char c)
|
2004-05-22 14:36:50 +04:00
|
|
|
{
|
|
|
|
if (in_utf(ldisc->term))
|
|
|
|
return (c < 0x80 || c >= 0xC0);
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
static void bsb(Ldisc *ldisc, int n)
|
2001-05-06 18:35:20 +04:00
|
|
|
{
|
1999-11-09 15:05:34 +03:00
|
|
|
while (n--)
|
2002-10-26 14:16:19 +04:00
|
|
|
c_write(ldisc, "\010 \010", 3);
|
1999-11-09 15:05:34 +03:00
|
|
|
}
|
|
|
|
|
2000-03-11 17:03:04 +03:00
|
|
|
#define CTRL(x) (x^'@')
|
2001-05-09 19:12:26 +04:00
|
|
|
#define KCTRL(x) ((x^'@') | 0x100)
|
2000-03-11 17:03:04 +03:00
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
Ldisc *ldisc_create(Conf *conf, Terminal *term,
|
2018-09-12 11:10:51 +03:00
|
|
|
Backend *backend, Frontend *frontend)
|
2001-05-06 18:35:20 +04:00
|
|
|
{
|
2018-09-11 17:02:59 +03:00
|
|
|
Ldisc *ldisc = snew(Ldisc);
|
2002-10-26 14:16:19 +04:00
|
|
|
|
|
|
|
ldisc->buf = NULL;
|
|
|
|
ldisc->buflen = 0;
|
|
|
|
ldisc->bufsiz = 0;
|
|
|
|
ldisc->quotenext = 0;
|
|
|
|
|
2018-09-11 18:23:38 +03:00
|
|
|
ldisc->backend = backend;
|
2002-10-26 14:16:19 +04:00
|
|
|
ldisc->term = term;
|
|
|
|
ldisc->frontend = frontend;
|
|
|
|
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
ldisc_configure(ldisc, conf);
|
|
|
|
|
2002-10-26 14:16:19 +04:00
|
|
|
/* Link ourselves into the backend and the terminal */
|
|
|
|
if (term)
|
|
|
|
term->ldisc = ldisc;
|
2018-09-11 18:23:38 +03:00
|
|
|
if (backend)
|
|
|
|
backend_provide_ldisc(backend, ldisc);
|
2002-10-26 14:16:19 +04:00
|
|
|
|
|
|
|
return ldisc;
|
|
|
|
}
|
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
void ldisc_configure(Ldisc *ldisc, Conf *conf)
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
{
|
|
|
|
ldisc->telnet_keyboard = conf_get_int(conf, CONF_telnet_keyboard);
|
|
|
|
ldisc->telnet_newline = conf_get_int(conf, CONF_telnet_newline);
|
|
|
|
ldisc->protocol = conf_get_int(conf, CONF_protocol);
|
|
|
|
ldisc->localecho = conf_get_int(conf, CONF_localecho);
|
|
|
|
ldisc->localedit = conf_get_int(conf, CONF_localedit);
|
|
|
|
}
|
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
void ldisc_free(Ldisc *ldisc)
|
2003-01-16 02:30:21 +03:00
|
|
|
{
|
|
|
|
if (ldisc->term)
|
|
|
|
ldisc->term->ldisc = NULL;
|
2018-09-11 18:23:38 +03:00
|
|
|
if (ldisc->backend)
|
|
|
|
backend_provide_ldisc(ldisc->backend, NULL);
|
2003-01-16 02:30:21 +03:00
|
|
|
if (ldisc->buf)
|
|
|
|
sfree(ldisc->buf);
|
|
|
|
sfree(ldisc);
|
|
|
|
}
|
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
void ldisc_echoedit_update(Ldisc *ldisc)
|
Move echo/edit state change functionality out of ldisc_send.
I'm not actually sure why we've always had back ends notify ldisc of
changes to echo/edit settings by giving ldisc_send(ldisc,NULL,0,0) a
special meaning, instead of by having a separate dedicated notify
function with its own prototype and parameter set. Coverity's recent
observation that the two kinds of call don't even have the same
requirements on the ldisc (particularly, whether ldisc->term can be
NULL) makes me realise that it's really high time I separated the two
conceptually different operations into actually different functions.
While I'm here, I've renamed the confusing ldisc_update() function
which that special operation ends up feeding to, because it's not
actually a function applying to an ldisc - it applies to a front end.
So ldisc_send(ldisc,NULL,0,0) is now ldisc_echoedit_update(ldisc), and
that in turn figures out the current echo/edit settings before passing
them on to frontend_echoedit_update(). I think that should be clearer.
2014-11-22 19:12:47 +03:00
|
|
|
{
|
|
|
|
frontend_echoedit_update(ldisc->frontend, ECHOING, EDITING);
|
|
|
|
}
|
|
|
|
|
2018-09-11 17:02:59 +03:00
|
|
|
void ldisc_send(Ldisc *ldisc, const void *vbuf, int len, int interactive)
|
2002-10-26 14:16:19 +04:00
|
|
|
{
|
2018-05-26 10:31:34 +03:00
|
|
|
const char *buf = (const char *)vbuf;
|
2001-05-09 19:12:26 +04:00
|
|
|
int keyflag = 0;
|
2014-11-22 13:37:14 +03:00
|
|
|
|
|
|
|
assert(ldisc->term);
|
Move echo/edit state change functionality out of ldisc_send.
I'm not actually sure why we've always had back ends notify ldisc of
changes to echo/edit settings by giving ldisc_send(ldisc,NULL,0,0) a
special meaning, instead of by having a separate dedicated notify
function with its own prototype and parameter set. Coverity's recent
observation that the two kinds of call don't even have the same
requirements on the ldisc (particularly, whether ldisc->term can be
NULL) makes me realise that it's really high time I separated the two
conceptually different operations into actually different functions.
While I'm here, I've renamed the confusing ldisc_update() function
which that special operation ends up feeding to, because it's not
actually a function applying to an ldisc - it applies to a front end.
So ldisc_send(ldisc,NULL,0,0) is now ldisc_echoedit_update(ldisc), and
that in turn figures out the current echo/edit settings before passing
them on to frontend_echoedit_update(). I think that should be clearer.
2014-11-22 19:12:47 +03:00
|
|
|
assert(len);
|
2014-11-22 13:37:14 +03:00
|
|
|
|
|
|
|
if (interactive) {
|
2013-08-17 20:06:40 +04:00
|
|
|
/*
|
|
|
|
* Interrupt a paste from the clipboard, if one was in
|
|
|
|
* progress when the user pressed a key. This is easier than
|
|
|
|
* buffering the current piece of data and saving it until the
|
|
|
|
* terminal has finished pasting, and has the potential side
|
|
|
|
* benefit of permitting a user to cancel an accidental huge
|
|
|
|
* paste.
|
|
|
|
*/
|
|
|
|
term_nopaste(ldisc->term);
|
|
|
|
}
|
|
|
|
|
2001-05-09 19:12:26 +04:00
|
|
|
/*
|
|
|
|
* Less than zero means null terminated special string.
|
|
|
|
*/
|
|
|
|
if (len < 0) {
|
|
|
|
len = strlen(buf);
|
|
|
|
keyflag = KCTRL('@');
|
|
|
|
}
|
2001-01-24 17:08:20 +03:00
|
|
|
/*
|
|
|
|
* Either perform local editing, or just send characters.
|
|
|
|
*/
|
|
|
|
if (EDITING) {
|
2001-05-06 18:35:20 +04:00
|
|
|
while (len--) {
|
2001-05-09 19:12:26 +04:00
|
|
|
int c;
|
2010-09-09 18:32:25 +04:00
|
|
|
c = (unsigned char)(*buf++) + keyflag;
|
2001-09-20 00:07:15 +04:00
|
|
|
if (!interactive && c == '\r')
|
|
|
|
c += KCTRL('@');
|
2002-10-26 14:16:19 +04:00
|
|
|
switch (ldisc->quotenext ? ' ' : c) {
|
2001-05-06 18:35:20 +04:00
|
|
|
/*
|
2004-05-22 14:36:50 +04:00
|
|
|
* ^h/^?: delete, and output BSBs, to return to
|
|
|
|
* last character boundary (in UTF-8 mode this may
|
|
|
|
* be more than one byte)
|
2001-05-06 18:35:20 +04:00
|
|
|
* ^w: delete, and output BSBs, to return to last
|
|
|
|
* space/nonspace boundary
|
|
|
|
* ^u: delete, and output BSBs, to return to BOL
|
|
|
|
* ^c: Do a ^u then send a telnet IP
|
|
|
|
* ^z: Do a ^u then send a telnet SUSP
|
|
|
|
* ^\: Do a ^u then send a telnet ABORT
|
|
|
|
* ^r: echo "^R\n" and redraw line
|
|
|
|
* ^v: quote next char
|
|
|
|
* ^d: if at BOL, end of file and close connection,
|
|
|
|
* else send line and reset to BOL
|
|
|
|
* ^m: send line-plus-\r\n and reset to BOL
|
|
|
|
*/
|
2001-05-09 19:12:26 +04:00
|
|
|
case KCTRL('H'):
|
|
|
|
case KCTRL('?'): /* backspace/delete */
|
2002-10-26 14:16:19 +04:00
|
|
|
if (ldisc->buflen > 0) {
|
2004-05-22 14:36:50 +04:00
|
|
|
do {
|
|
|
|
if (ECHOING)
|
|
|
|
bsb(ldisc, plen(ldisc, ldisc->buf[ldisc->buflen - 1]));
|
|
|
|
ldisc->buflen--;
|
|
|
|
} while (!char_start(ldisc, ldisc->buf[ldisc->buflen]));
|
2001-05-06 18:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CTRL('W'): /* delete word */
|
2002-10-26 14:16:19 +04:00
|
|
|
while (ldisc->buflen > 0) {
|
2001-05-06 18:35:20 +04:00
|
|
|
if (ECHOING)
|
2002-10-26 14:16:19 +04:00
|
|
|
bsb(ldisc, plen(ldisc, ldisc->buf[ldisc->buflen - 1]));
|
|
|
|
ldisc->buflen--;
|
|
|
|
if (ldisc->buflen > 0 &&
|
2003-03-11 12:30:31 +03:00
|
|
|
isspace((unsigned char)ldisc->buf[ldisc->buflen-1]) &&
|
|
|
|
!isspace((unsigned char)ldisc->buf[ldisc->buflen]))
|
2001-05-06 18:35:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CTRL('U'): /* delete line */
|
|
|
|
case CTRL('C'): /* Send IP */
|
|
|
|
case CTRL('\\'): /* Quit */
|
|
|
|
case CTRL('Z'): /* Suspend */
|
2002-10-26 14:16:19 +04:00
|
|
|
while (ldisc->buflen > 0) {
|
2001-05-06 18:35:20 +04:00
|
|
|
if (ECHOING)
|
2002-10-26 14:16:19 +04:00
|
|
|
bsb(ldisc, plen(ldisc, ldisc->buf[ldisc->buflen - 1]));
|
|
|
|
ldisc->buflen--;
|
2001-05-06 18:35:20 +04:00
|
|
|
}
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_EL, 0);
|
2001-10-24 15:50:07 +04:00
|
|
|
/*
|
|
|
|
* We don't send IP, SUSP or ABORT if the user has
|
|
|
|
* configured telnet specials off! This breaks
|
|
|
|
* talkers otherwise.
|
|
|
|
*/
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
if (!ldisc->telnet_keyboard)
|
2001-10-24 15:50:07 +04:00
|
|
|
goto default_case;
|
2001-05-06 18:35:20 +04:00
|
|
|
if (c == CTRL('C'))
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_IP, 0);
|
2001-05-06 18:35:20 +04:00
|
|
|
if (c == CTRL('Z'))
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_SUSP, 0);
|
2001-05-06 18:35:20 +04:00
|
|
|
if (c == CTRL('\\'))
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_ABORT, 0);
|
2001-05-06 18:35:20 +04:00
|
|
|
break;
|
|
|
|
case CTRL('R'): /* redraw line */
|
|
|
|
if (ECHOING) {
|
|
|
|
int i;
|
2002-10-26 14:16:19 +04:00
|
|
|
c_write(ldisc, "^R\r\n", 4);
|
|
|
|
for (i = 0; i < ldisc->buflen; i++)
|
|
|
|
pwrite(ldisc, ldisc->buf[i]);
|
2001-05-06 18:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CTRL('V'): /* quote next char */
|
2002-10-26 14:16:19 +04:00
|
|
|
ldisc->quotenext = TRUE;
|
2001-05-06 18:35:20 +04:00
|
|
|
break;
|
|
|
|
case CTRL('D'): /* logout or send */
|
2002-10-26 14:16:19 +04:00
|
|
|
if (ldisc->buflen == 0) {
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_EOF, 0);
|
2001-05-06 18:35:20 +04:00
|
|
|
} else {
|
2018-09-11 18:23:38 +03:00
|
|
|
backend_send(ldisc->backend, ldisc->buf, ldisc->buflen);
|
2002-10-26 14:16:19 +04:00
|
|
|
ldisc->buflen = 0;
|
2001-05-06 18:35:20 +04:00
|
|
|
}
|
|
|
|
break;
|
2001-05-09 19:12:26 +04:00
|
|
|
/*
|
|
|
|
* This particularly hideous bit of code from RDB
|
|
|
|
* allows ordinary ^M^J to do the same thing as
|
|
|
|
* magic-^M when in Raw protocol. The line `case
|
|
|
|
* KCTRL('M'):' is _inside_ the if block. Thus:
|
|
|
|
*
|
|
|
|
* - receiving regular ^M goes straight to the
|
|
|
|
* default clause and inserts as a literal ^M.
|
|
|
|
* - receiving regular ^J _not_ directly after a
|
|
|
|
* literal ^M (or not in Raw protocol) fails the
|
|
|
|
* if condition, leaps to the bottom of the if,
|
|
|
|
* and falls through into the default clause
|
|
|
|
* again.
|
|
|
|
* - receiving regular ^J just after a literal ^M
|
|
|
|
* in Raw protocol passes the if condition,
|
|
|
|
* deletes the literal ^M, and falls through
|
|
|
|
* into the magic-^M code
|
|
|
|
* - receiving a magic-^M empties the line buffer,
|
|
|
|
* signals end-of-line in one of the various
|
|
|
|
* entertaining ways, and _doesn't_ fall out of
|
|
|
|
* the bottom of the if and through to the
|
|
|
|
* default clause because of the break.
|
|
|
|
*/
|
|
|
|
case CTRL('J'):
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
if (ldisc->protocol == PROT_RAW &&
|
2002-10-26 14:16:19 +04:00
|
|
|
ldisc->buflen > 0 && ldisc->buf[ldisc->buflen - 1] == '\r') {
|
2001-05-09 19:12:26 +04:00
|
|
|
if (ECHOING)
|
2002-10-26 14:16:19 +04:00
|
|
|
bsb(ldisc, plen(ldisc, ldisc->buf[ldisc->buflen - 1]));
|
|
|
|
ldisc->buflen--;
|
2001-05-09 19:12:26 +04:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
case KCTRL('M'): /* send with newline */
|
2002-10-26 14:16:19 +04:00
|
|
|
if (ldisc->buflen > 0)
|
2018-09-11 18:23:38 +03:00
|
|
|
backend_send(ldisc->backend,
|
|
|
|
ldisc->buf, ldisc->buflen);
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
if (ldisc->protocol == PROT_RAW)
|
2018-09-11 18:23:38 +03:00
|
|
|
backend_send(ldisc->backend, "\r\n", 2);
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
else if (ldisc->protocol == PROT_TELNET && ldisc->telnet_newline)
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_EOL, 0);
|
2001-05-09 19:12:26 +04:00
|
|
|
else
|
2018-09-11 18:23:38 +03:00
|
|
|
backend_send(ldisc->backend, "\r", 1);
|
2001-05-09 19:12:26 +04:00
|
|
|
if (ECHOING)
|
2002-10-26 14:16:19 +04:00
|
|
|
c_write(ldisc, "\r\n", 2);
|
|
|
|
ldisc->buflen = 0;
|
2001-05-09 19:12:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* FALLTHROUGH */
|
2001-05-06 18:35:20 +04:00
|
|
|
default: /* get to this label from ^V handler */
|
2001-10-24 15:50:07 +04:00
|
|
|
default_case:
|
2002-10-26 14:16:19 +04:00
|
|
|
if (ldisc->buflen >= ldisc->bufsiz) {
|
|
|
|
ldisc->bufsiz = ldisc->buflen + 256;
|
2003-03-29 19:14:26 +03:00
|
|
|
ldisc->buf = sresize(ldisc->buf, ldisc->bufsiz, char);
|
2001-05-06 18:35:20 +04:00
|
|
|
}
|
2002-10-26 14:16:19 +04:00
|
|
|
ldisc->buf[ldisc->buflen++] = c;
|
2001-05-06 18:35:20 +04:00
|
|
|
if (ECHOING)
|
2002-10-26 14:16:19 +04:00
|
|
|
pwrite(ldisc, (unsigned char) c);
|
|
|
|
ldisc->quotenext = FALSE;
|
2001-05-06 18:35:20 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-01-24 17:08:20 +03:00
|
|
|
} else {
|
2002-10-26 14:16:19 +04:00
|
|
|
if (ldisc->buflen != 0) {
|
2018-09-11 18:23:38 +03:00
|
|
|
backend_send(ldisc->backend, ldisc->buf, ldisc->buflen);
|
2002-10-26 14:16:19 +04:00
|
|
|
while (ldisc->buflen > 0) {
|
|
|
|
bsb(ldisc, plen(ldisc, ldisc->buf[ldisc->buflen - 1]));
|
|
|
|
ldisc->buflen--;
|
2001-05-06 18:35:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (len > 0) {
|
|
|
|
if (ECHOING)
|
2002-10-26 14:16:19 +04:00
|
|
|
c_write(ldisc, buf, len);
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
if (keyflag && ldisc->protocol == PROT_TELNET && len == 1) {
|
2001-05-09 19:12:26 +04:00
|
|
|
switch (buf[0]) {
|
|
|
|
case CTRL('M'):
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
if (ldisc->protocol == PROT_TELNET && ldisc->telnet_newline)
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_EOL, 0);
|
2001-12-29 20:21:26 +03:00
|
|
|
else
|
2018-09-11 18:23:38 +03:00
|
|
|
backend_send(ldisc->backend, "\r", 1);
|
2001-05-09 19:12:26 +04:00
|
|
|
break;
|
|
|
|
case CTRL('?'):
|
|
|
|
case CTRL('H'):
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
if (ldisc->telnet_keyboard) {
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_EC, 0);
|
2001-05-09 19:12:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CTRL('C'):
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
if (ldisc->telnet_keyboard) {
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_IP, 0);
|
2001-05-09 19:12:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CTRL('Z'):
|
Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.
User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).
One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.
[originally from svn r9214]
2011-07-14 22:52:21 +04:00
|
|
|
if (ldisc->telnet_keyboard) {
|
Rework special-commands system to add an integer argument.
In order to list cross-certifiable host keys in the GUI specials menu,
the SSH backend has been inventing new values on the end of the
Telnet_Special enumeration, starting from the value TS_LOCALSTART.
This is inelegant, and also makes it awkward to break up special
handlers (e.g. to dispatch different specials to different SSH
layers), since if all you know about a special is that it's somewhere
in the TS_LOCALSTART+n space, you can't tell what _general kind_ of
thing it is. Also, if I ever need another open-ended set of specials
in future, I'll have to remember which TS_LOCALSTART+n codes are in
which set.
So here's a revamp that causes every special to take an extra integer
argument. For all previously numbered specials, this argument is
passed as zero and ignored, but there's a new main special code for
SSH host key cross-certification, in which the integer argument is an
index into the backend's list of available keys. TS_LOCALSTART is now
a thing of the past: if I need any other open-ended sets of specials
in future, I can add a new top-level code with a nicely separated
space of arguments.
While I'm at it, I've removed the legacy misnomer 'Telnet_Special'
from the code completely; the enum is now SessionSpecialCode, the
struct containing full details of a menu entry is SessionSpecial, and
the enum values now start SS_ rather than TS_.
2018-09-24 11:35:52 +03:00
|
|
|
backend_special(ldisc->backend, SS_SUSP, 0);
|
2001-05-09 19:12:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2018-09-11 18:23:38 +03:00
|
|
|
backend_send(ldisc->backend, buf, len);
|
2001-05-09 19:12:26 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else
|
2018-09-11 18:23:38 +03:00
|
|
|
backend_send(ldisc->backend, buf, len);
|
2001-05-06 18:35:20 +04:00
|
|
|
}
|
2000-03-11 17:03:04 +03:00
|
|
|
}
|
1999-11-09 15:05:34 +03:00
|
|
|
}
|