mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Add a Config * argument to ldisc_create(), and use it in place of the global
cfg throughout ldisc.c. Not tested other than on Mac, but all other ports just pass &cfg as this argument for now. [originally from svn r2250]
This commit is contained in:
parent
c0b887a0a2
commit
d60ea36673
31
ldisc.c
31
ldisc.c
@ -12,12 +12,12 @@
|
|||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "ldisc.h"
|
#include "ldisc.h"
|
||||||
|
|
||||||
#define ECHOING (cfg.localecho == LD_YES || \
|
#define ECHOING (ldisc->cfg->localecho == LD_YES || \
|
||||||
(cfg.localecho == LD_BACKEND && \
|
(ldisc->cfg->localecho == LD_BACKEND && \
|
||||||
(ldisc->back->ldisc(ldisc->backhandle, LD_ECHO) || \
|
(ldisc->back->ldisc(ldisc->backhandle, LD_ECHO) || \
|
||||||
term_ldisc(ldisc->term, LD_ECHO))))
|
term_ldisc(ldisc->term, LD_ECHO))))
|
||||||
#define EDITING (cfg.localedit == LD_YES || \
|
#define EDITING (ldisc->cfg->localedit == LD_YES || \
|
||||||
(cfg.localedit == LD_BACKEND && \
|
(ldisc->cfg->localedit == LD_BACKEND && \
|
||||||
(ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \
|
(ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \
|
||||||
term_ldisc(ldisc->term, LD_EDIT))))
|
term_ldisc(ldisc->term, LD_EDIT))))
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ static int plen(Ldisc ldisc, unsigned char c)
|
|||||||
static void pwrite(Ldisc ldisc, unsigned char c)
|
static void pwrite(Ldisc ldisc, unsigned char c)
|
||||||
{
|
{
|
||||||
if ((c >= 32 && c <= 126) || (c >= 160 && !in_utf(ldisc->term))) {
|
if ((c >= 32 && c <= 126) || (c >= 160 && !in_utf(ldisc->term))) {
|
||||||
c_write(ldisc, &c, 1);
|
c_write(ldisc, (char *)&c, 1);
|
||||||
} else if (c < 128) {
|
} else if (c < 128) {
|
||||||
char cc[2];
|
char cc[2];
|
||||||
cc[1] = (c == 127 ? '?' : c + 0x40);
|
cc[1] = (c == 127 ? '?' : c + 0x40);
|
||||||
@ -61,7 +61,7 @@ static void bsb(Ldisc ldisc, int n)
|
|||||||
#define CTRL(x) (x^'@')
|
#define CTRL(x) (x^'@')
|
||||||
#define KCTRL(x) ((x^'@') | 0x100)
|
#define KCTRL(x) ((x^'@') | 0x100)
|
||||||
|
|
||||||
void *ldisc_create(Terminal *term,
|
void *ldisc_create(Config *mycfg, Terminal *term,
|
||||||
Backend *back, void *backhandle,
|
Backend *back, void *backhandle,
|
||||||
void *frontend)
|
void *frontend)
|
||||||
{
|
{
|
||||||
@ -72,6 +72,7 @@ void *ldisc_create(Terminal *term,
|
|||||||
ldisc->bufsiz = 0;
|
ldisc->bufsiz = 0;
|
||||||
ldisc->quotenext = 0;
|
ldisc->quotenext = 0;
|
||||||
|
|
||||||
|
ldisc->cfg = mycfg;
|
||||||
ldisc->back = back;
|
ldisc->back = back;
|
||||||
ldisc->backhandle = backhandle;
|
ldisc->backhandle = backhandle;
|
||||||
ldisc->term = term;
|
ldisc->term = term;
|
||||||
@ -170,7 +171,7 @@ void ldisc_send(void *handle, char *buf, int len, int interactive)
|
|||||||
* configured telnet specials off! This breaks
|
* configured telnet specials off! This breaks
|
||||||
* talkers otherwise.
|
* talkers otherwise.
|
||||||
*/
|
*/
|
||||||
if (!cfg.telnet_keyboard)
|
if (!ldisc->cfg->telnet_keyboard)
|
||||||
goto default_case;
|
goto default_case;
|
||||||
if (c == CTRL('C'))
|
if (c == CTRL('C'))
|
||||||
ldisc->back->special(ldisc->backhandle, TS_IP);
|
ldisc->back->special(ldisc->backhandle, TS_IP);
|
||||||
@ -222,7 +223,7 @@ void ldisc_send(void *handle, char *buf, int len, int interactive)
|
|||||||
* default clause because of the break.
|
* default clause because of the break.
|
||||||
*/
|
*/
|
||||||
case CTRL('J'):
|
case CTRL('J'):
|
||||||
if (cfg.protocol == PROT_RAW &&
|
if (ldisc->cfg->protocol == PROT_RAW &&
|
||||||
ldisc->buflen > 0 && ldisc->buf[ldisc->buflen - 1] == '\r') {
|
ldisc->buflen > 0 && ldisc->buf[ldisc->buflen - 1] == '\r') {
|
||||||
if (ECHOING)
|
if (ECHOING)
|
||||||
bsb(ldisc, plen(ldisc, ldisc->buf[ldisc->buflen - 1]));
|
bsb(ldisc, plen(ldisc, ldisc->buf[ldisc->buflen - 1]));
|
||||||
@ -231,9 +232,9 @@ void ldisc_send(void *handle, char *buf, int len, int interactive)
|
|||||||
case KCTRL('M'): /* send with newline */
|
case KCTRL('M'): /* send with newline */
|
||||||
if (ldisc->buflen > 0)
|
if (ldisc->buflen > 0)
|
||||||
ldisc->back->send(ldisc->backhandle, ldisc->buf, ldisc->buflen);
|
ldisc->back->send(ldisc->backhandle, ldisc->buf, ldisc->buflen);
|
||||||
if (cfg.protocol == PROT_RAW)
|
if (ldisc->cfg->protocol == PROT_RAW)
|
||||||
ldisc->back->send(ldisc->backhandle, "\r\n", 2);
|
ldisc->back->send(ldisc->backhandle, "\r\n", 2);
|
||||||
else if (cfg.protocol == PROT_TELNET && cfg.telnet_newline)
|
else if (ldisc->cfg->protocol == PROT_TELNET && ldisc->cfg->telnet_newline)
|
||||||
ldisc->back->special(ldisc->backhandle, TS_EOL);
|
ldisc->back->special(ldisc->backhandle, TS_EOL);
|
||||||
else
|
else
|
||||||
ldisc->back->send(ldisc->backhandle, "\r", 1);
|
ldisc->back->send(ldisc->backhandle, "\r", 1);
|
||||||
@ -267,27 +268,27 @@ void ldisc_send(void *handle, char *buf, int len, int interactive)
|
|||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
if (ECHOING)
|
if (ECHOING)
|
||||||
c_write(ldisc, buf, len);
|
c_write(ldisc, buf, len);
|
||||||
if (keyflag && cfg.protocol == PROT_TELNET && len == 1) {
|
if (keyflag && ldisc->cfg->protocol == PROT_TELNET && len == 1) {
|
||||||
switch (buf[0]) {
|
switch (buf[0]) {
|
||||||
case CTRL('M'):
|
case CTRL('M'):
|
||||||
if (cfg.protocol == PROT_TELNET && cfg.telnet_newline)
|
if (ldisc->cfg->protocol == PROT_TELNET && ldisc->cfg->telnet_newline)
|
||||||
ldisc->back->special(ldisc->backhandle, TS_EOL);
|
ldisc->back->special(ldisc->backhandle, TS_EOL);
|
||||||
else
|
else
|
||||||
ldisc->back->send(ldisc->backhandle, "\r", 1);
|
ldisc->back->send(ldisc->backhandle, "\r", 1);
|
||||||
break;
|
break;
|
||||||
case CTRL('?'):
|
case CTRL('?'):
|
||||||
case CTRL('H'):
|
case CTRL('H'):
|
||||||
if (cfg.telnet_keyboard) {
|
if (ldisc->cfg->telnet_keyboard) {
|
||||||
ldisc->back->special(ldisc->backhandle, TS_EC);
|
ldisc->back->special(ldisc->backhandle, TS_EC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTRL('C'):
|
case CTRL('C'):
|
||||||
if (cfg.telnet_keyboard) {
|
if (ldisc->cfg->telnet_keyboard) {
|
||||||
ldisc->back->special(ldisc->backhandle, TS_IP);
|
ldisc->back->special(ldisc->backhandle, TS_IP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CTRL('Z'):
|
case CTRL('Z'):
|
||||||
if (cfg.telnet_keyboard) {
|
if (ldisc->cfg->telnet_keyboard) {
|
||||||
ldisc->back->special(ldisc->backhandle, TS_SUSP);
|
ldisc->back->special(ldisc->backhandle, TS_SUSP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
1
ldisc.h
1
ldisc.h
@ -11,6 +11,7 @@
|
|||||||
typedef struct ldisc_tag {
|
typedef struct ldisc_tag {
|
||||||
Terminal *term;
|
Terminal *term;
|
||||||
Backend *back;
|
Backend *back;
|
||||||
|
Config *cfg;
|
||||||
void *backhandle;
|
void *backhandle;
|
||||||
void *frontend;
|
void *frontend;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: macterm.c,v 1.8 2002/11/23 19:01:01 ben Exp $ */
|
/* $Id: macterm.c,v 1.9 2002/11/23 20:02:38 ben Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Simon Tatham
|
* Copyright (c) 1999 Simon Tatham
|
||||||
* Copyright (c) 1999, 2002 Ben Harris
|
* Copyright (c) 1999, 2002 Ben Harris
|
||||||
@ -165,7 +165,7 @@ void mac_newsession(void) {
|
|||||||
mac_adjustsize(s, s->cfg.height, s->cfg.width);
|
mac_adjustsize(s, s->cfg.height, s->cfg.width);
|
||||||
term_size(s->term, s->cfg.height, s->cfg.width, s->cfg.savelines);
|
term_size(s->term, s->cfg.height, s->cfg.width, s->cfg.savelines);
|
||||||
|
|
||||||
s->ldisc = ldisc_create(s->term, s->back, s->backhandle, s);
|
s->ldisc = ldisc_create(&s->cfg, s->term, s->back, s->backhandle, s);
|
||||||
ldisc_send(s->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */
|
ldisc_send(s->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */
|
||||||
|
|
||||||
mac_initfont(s);
|
mac_initfont(s);
|
||||||
|
2
putty.h
2
putty.h
@ -544,7 +544,7 @@ extern Backend ssh_backend;
|
|||||||
/*
|
/*
|
||||||
* Exports from ldisc.c.
|
* Exports from ldisc.c.
|
||||||
*/
|
*/
|
||||||
void *ldisc_create(Terminal *, Backend *, void *, void *);
|
void *ldisc_create(Config *, Terminal *, Backend *, void *, void *);
|
||||||
void ldisc_send(void *handle, char *buf, int len, int interactive);
|
void ldisc_send(void *handle, char *buf, int len, int interactive);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2113,7 +2113,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
term_size(inst->term, cfg.height, cfg.width, cfg.savelines);
|
term_size(inst->term, cfg.height, cfg.width, cfg.savelines);
|
||||||
|
|
||||||
inst->ldisc = ldisc_create(inst->term, inst->back, inst->backhandle, inst);
|
inst->ldisc =
|
||||||
|
ldisc_create(&cfg, inst->term, inst->back, inst->backhandle, inst);
|
||||||
ldisc_send(inst->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */
|
ldisc_send(inst->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */
|
||||||
|
|
||||||
inst->master_fd = pty_master_fd;
|
inst->master_fd = pty_master_fd;
|
||||||
|
@ -475,7 +475,7 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
back->provide_logctx(backhandle, logctx);
|
back->provide_logctx(backhandle, logctx);
|
||||||
ldisc = ldisc_create(NULL, back, backhandle, NULL);
|
ldisc = ldisc_create(&cfg, NULL, back, backhandle, NULL);
|
||||||
sfree(realhost);
|
sfree(realhost);
|
||||||
}
|
}
|
||||||
connopen = 1;
|
connopen = 1;
|
||||||
|
2
window.c
2
window.c
@ -644,7 +644,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|||||||
/*
|
/*
|
||||||
* Set up a line discipline.
|
* Set up a line discipline.
|
||||||
*/
|
*/
|
||||||
ldisc = ldisc_create(term, back, backhandle, NULL);
|
ldisc = ldisc_create(&cfg, term, back, backhandle, NULL);
|
||||||
|
|
||||||
session_closed = FALSE;
|
session_closed = FALSE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user