зеркало из https://github.com/github/putty.git
Expose the Ldisc structure tag throughout the code.
That's one fewer anonymous 'void *' which might be accidentally confused with some other pointer type if I misremember the order of function arguments. While I'm here, I've made its pointer-nature explicit - that is, 'Ldisc' is now a typedef for the structure type itself rather than a pointer to it. A stylistic change only, but it feels more natural to me these days for a thing you're going to eventually pass to a 'free' function.
This commit is contained in:
Родитель
566d4826f4
Коммит
e72e8ebe59
2
defs.h
2
defs.h
|
@ -44,6 +44,8 @@ typedef struct SockAddr_tag *SockAddr;
|
|||
typedef struct Socket_vtable Socket_vtable;
|
||||
typedef struct Plug_vtable Plug_vtable;
|
||||
|
||||
typedef struct Ldisc_tag Ldisc;
|
||||
|
||||
/* Note indirection: for historical reasons (it used to be closer to
|
||||
* the OS socket type), the type that most code uses for a socket is
|
||||
* 'Socket', not 'Socket *'. So an implementation of Socket or Plug
|
||||
|
|
|
@ -71,8 +71,8 @@ void set_title(void *frontend, char *t) { }
|
|||
void set_icon(void *frontend, char *t) { }
|
||||
void set_sbar(void *frontend, int a, int b, int c) { }
|
||||
|
||||
void ldisc_send(void *handle, const void *buf, int len, int interactive) {}
|
||||
void ldisc_echoedit_update(void *handle) {}
|
||||
void ldisc_send(Ldisc *ldisc, const void *buf, int len, int interactive) {}
|
||||
void ldisc_echoedit_update(Ldisc *ldisc) {}
|
||||
Context get_ctx(void *frontend) {
|
||||
static char x;
|
||||
|
||||
|
|
28
ldisc.c
28
ldisc.c
|
@ -22,12 +22,12 @@
|
|||
(ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \
|
||||
term_ldisc(ldisc->term, LD_EDIT))))
|
||||
|
||||
static void c_write(Ldisc ldisc, const void *buf, int len)
|
||||
static void c_write(Ldisc *ldisc, const void *buf, int len)
|
||||
{
|
||||
from_backend(ldisc->frontend, 0, buf, len);
|
||||
}
|
||||
|
||||
static int plen(Ldisc ldisc, unsigned char c)
|
||||
static int plen(Ldisc *ldisc, unsigned char c)
|
||||
{
|
||||
if ((c >= 32 && c <= 126) || (c >= 160 && !in_utf(ldisc->term)))
|
||||
return 1;
|
||||
|
@ -42,7 +42,7 @@ static int plen(Ldisc ldisc, unsigned char c)
|
|||
return 4; /* <XY> hex representation */
|
||||
}
|
||||
|
||||
static void pwrite(Ldisc ldisc, unsigned char c)
|
||||
static void pwrite(Ldisc *ldisc, unsigned char c)
|
||||
{
|
||||
if ((c >= 32 && c <= 126) ||
|
||||
(!in_utf(ldisc->term) && c >= 0xA0) ||
|
||||
|
@ -60,7 +60,7 @@ static void pwrite(Ldisc ldisc, unsigned char c)
|
|||
}
|
||||
}
|
||||
|
||||
static int char_start(Ldisc ldisc, unsigned char c)
|
||||
static int char_start(Ldisc *ldisc, unsigned char c)
|
||||
{
|
||||
if (in_utf(ldisc->term))
|
||||
return (c < 0x80 || c >= 0xC0);
|
||||
|
@ -68,7 +68,7 @@ static int char_start(Ldisc ldisc, unsigned char c)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void bsb(Ldisc ldisc, int n)
|
||||
static void bsb(Ldisc *ldisc, int n)
|
||||
{
|
||||
while (n--)
|
||||
c_write(ldisc, "\010 \010", 3);
|
||||
|
@ -77,11 +77,11 @@ static void bsb(Ldisc ldisc, int n)
|
|||
#define CTRL(x) (x^'@')
|
||||
#define KCTRL(x) ((x^'@') | 0x100)
|
||||
|
||||
void *ldisc_create(Conf *conf, Terminal *term,
|
||||
Ldisc *ldisc_create(Conf *conf, Terminal *term,
|
||||
Backend *back, void *backhandle,
|
||||
void *frontend)
|
||||
{
|
||||
Ldisc ldisc = snew(struct ldisc_tag);
|
||||
Ldisc *ldisc = snew(Ldisc);
|
||||
|
||||
ldisc->buf = NULL;
|
||||
ldisc->buflen = 0;
|
||||
|
@ -104,10 +104,8 @@ void *ldisc_create(Conf *conf, Terminal *term,
|
|||
return ldisc;
|
||||
}
|
||||
|
||||
void ldisc_configure(void *handle, Conf *conf)
|
||||
void ldisc_configure(Ldisc *ldisc, Conf *conf)
|
||||
{
|
||||
Ldisc ldisc = (Ldisc) handle;
|
||||
|
||||
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);
|
||||
|
@ -115,10 +113,8 @@ void ldisc_configure(void *handle, Conf *conf)
|
|||
ldisc->localedit = conf_get_int(conf, CONF_localedit);
|
||||
}
|
||||
|
||||
void ldisc_free(void *handle)
|
||||
void ldisc_free(Ldisc *ldisc)
|
||||
{
|
||||
Ldisc ldisc = (Ldisc) handle;
|
||||
|
||||
if (ldisc->term)
|
||||
ldisc->term->ldisc = NULL;
|
||||
if (ldisc->back)
|
||||
|
@ -128,16 +124,14 @@ void ldisc_free(void *handle)
|
|||
sfree(ldisc);
|
||||
}
|
||||
|
||||
void ldisc_echoedit_update(void *handle)
|
||||
void ldisc_echoedit_update(Ldisc *ldisc)
|
||||
{
|
||||
Ldisc ldisc = (Ldisc) handle;
|
||||
frontend_echoedit_update(ldisc->frontend, ECHOING, EDITING);
|
||||
}
|
||||
|
||||
void ldisc_send(void *handle, const void *vbuf, int len, int interactive)
|
||||
void ldisc_send(Ldisc *ldisc, const void *vbuf, int len, int interactive)
|
||||
{
|
||||
const char *buf = (const char *)vbuf;
|
||||
Ldisc ldisc = (Ldisc) handle;
|
||||
int keyflag = 0;
|
||||
|
||||
assert(ldisc->term);
|
||||
|
|
4
ldisc.h
4
ldisc.h
|
@ -8,7 +8,7 @@
|
|||
#ifndef PUTTY_LDISC_H
|
||||
#define PUTTY_LDISC_H
|
||||
|
||||
typedef struct ldisc_tag {
|
||||
struct Ldisc_tag {
|
||||
Terminal *term;
|
||||
Backend *back;
|
||||
void *backhandle;
|
||||
|
@ -21,6 +21,6 @@ typedef struct ldisc_tag {
|
|||
|
||||
char *buf;
|
||||
int buflen, bufsiz, quotenext;
|
||||
} *Ldisc;
|
||||
};
|
||||
|
||||
#endif /* PUTTY_LDISC_H */
|
||||
|
|
|
@ -12,10 +12,9 @@
|
|||
#include "terminal.h"
|
||||
#include "ldisc.h"
|
||||
|
||||
void lpage_send(void *handle,
|
||||
void lpage_send(Ldisc *ldisc,
|
||||
int codepage, const char *buf, int len, int interactive)
|
||||
{
|
||||
Ldisc ldisc = (Ldisc)handle;
|
||||
wchar_t *widebuffer = 0;
|
||||
int widesize = 0;
|
||||
int wclen;
|
||||
|
@ -34,9 +33,8 @@ void lpage_send(void *handle,
|
|||
sfree(widebuffer);
|
||||
}
|
||||
|
||||
void luni_send(void *handle, const wchar_t *widebuf, int len, int interactive)
|
||||
void luni_send(Ldisc *ldisc, const wchar_t *widebuf, int len, int interactive)
|
||||
{
|
||||
Ldisc ldisc = (Ldisc)handle;
|
||||
int ratio = (in_utf(ldisc->term))?3:1;
|
||||
char *linebuffer;
|
||||
int linesize;
|
||||
|
|
2
pscp.c
2
pscp.c
|
@ -60,7 +60,7 @@ const char *const appname = "PSCP";
|
|||
*/
|
||||
#define MAX_SCP_BUFSIZE 16384
|
||||
|
||||
void ldisc_echoedit_update(void *handle) { }
|
||||
void ldisc_echoedit_update(Ldisc *ldisc) { }
|
||||
|
||||
static void tell_char(FILE *stream, char c)
|
||||
{
|
||||
|
|
2
psftp.c
2
psftp.c
|
@ -2483,7 +2483,7 @@ void connection_fatal(void *frontend, const char *fmt, ...)
|
|||
cleanup_exit(1);
|
||||
}
|
||||
|
||||
void ldisc_echoedit_update(void *handle) { }
|
||||
void ldisc_echoedit_update(Ldisc *ldisc) { }
|
||||
|
||||
/*
|
||||
* In psftp, all agent requests should be synchronous, so this is a
|
||||
|
|
16
putty.h
16
putty.h
|
@ -461,7 +461,7 @@ struct backend_tag {
|
|||
* may be lost. */
|
||||
int (*sendok) (void *handle);
|
||||
int (*ldisc) (void *handle, int);
|
||||
void (*provide_ldisc) (void *handle, void *ldisc);
|
||||
void (*provide_ldisc) (void *handle, Ldisc *ldisc);
|
||||
void (*provide_logctx) (void *handle, void *logctx);
|
||||
/*
|
||||
* back->unthrottle() tells the back end that the front end
|
||||
|
@ -1174,18 +1174,18 @@ extern Backend ssh_backend;
|
|||
/*
|
||||
* Exports from ldisc.c.
|
||||
*/
|
||||
void *ldisc_create(Conf *, Terminal *, Backend *, void *, void *);
|
||||
void ldisc_configure(void *, Conf *);
|
||||
void ldisc_free(void *);
|
||||
void ldisc_send(void *handle, const void *buf, int len, int interactive);
|
||||
void ldisc_echoedit_update(void *handle);
|
||||
Ldisc *ldisc_create(Conf *, Terminal *, Backend *, void *, void *);
|
||||
void ldisc_configure(Ldisc *, Conf *);
|
||||
void ldisc_free(Ldisc *);
|
||||
void ldisc_send(Ldisc *, const void *buf, int len, int interactive);
|
||||
void ldisc_echoedit_update(Ldisc *);
|
||||
|
||||
/*
|
||||
* Exports from ldiscucs.c.
|
||||
*/
|
||||
void lpage_send(void *, int codepage, const char *buf, int len,
|
||||
void lpage_send(Ldisc *, int codepage, const char *buf, int len,
|
||||
int interactive);
|
||||
void luni_send(void *, const wchar_t * widebuf, int len, int interactive);
|
||||
void luni_send(Ldisc *, const wchar_t * widebuf, int len, int interactive);
|
||||
|
||||
/*
|
||||
* Exports from sshrand.c.
|
||||
|
|
2
raw.c
2
raw.c
|
@ -274,7 +274,7 @@ static int raw_ldisc(void *handle, int option)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void raw_provide_ldisc(void *handle, void *ldisc)
|
||||
static void raw_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
|
2
rlogin.c
2
rlogin.c
|
@ -366,7 +366,7 @@ static int rlogin_ldisc(void *handle, int option)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void rlogin_provide_ldisc(void *handle, void *ldisc)
|
||||
static void rlogin_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
|
4
ssh.c
4
ssh.c
|
@ -700,7 +700,7 @@ struct ssh_tag {
|
|||
|
||||
const Plug_vtable *plugvt;
|
||||
|
||||
void *ldisc;
|
||||
Ldisc *ldisc;
|
||||
void *logctx;
|
||||
|
||||
unsigned char session_key[32];
|
||||
|
@ -11428,7 +11428,7 @@ static int ssh_ldisc(void *handle, int option)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void ssh_provide_ldisc(void *handle, void *ldisc)
|
||||
static void ssh_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
{
|
||||
Ssh ssh = (Ssh) handle;
|
||||
ssh->ldisc = ldisc;
|
||||
|
|
4
telnet.c
4
telnet.c
|
@ -175,7 +175,7 @@ typedef struct telnet_tag {
|
|||
int closed_on_socket_error;
|
||||
|
||||
void *frontend;
|
||||
void *ldisc;
|
||||
Ldisc *ldisc;
|
||||
int term_width, term_height;
|
||||
|
||||
int opt_states[NUM_OPTS];
|
||||
|
@ -1059,7 +1059,7 @@ static int telnet_ldisc(void *handle, int option)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void telnet_provide_ldisc(void *handle, void *ldisc)
|
||||
static void telnet_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
{
|
||||
Telnet telnet = (Telnet) handle;
|
||||
telnet->ldisc = ldisc;
|
||||
|
|
|
@ -230,7 +230,7 @@ struct terminal_tag {
|
|||
void (*resize_fn)(void *, int, int);
|
||||
void *resize_ctx;
|
||||
|
||||
void *ldisc;
|
||||
Ldisc *ldisc;
|
||||
|
||||
void *frontend;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ static int null_connected(void *);
|
|||
static int null_exitcode(void *);
|
||||
static int null_sendok(void *);
|
||||
static int null_ldisc(void *, int);
|
||||
static void null_provide_ldisc(void *, void *);
|
||||
static void null_provide_ldisc(void *, Ldisc *);
|
||||
static void null_provide_logctx(void *, void *);
|
||||
static void null_unthrottle(void *, int);
|
||||
static int null_cfg_info(void *);
|
||||
|
@ -157,7 +157,7 @@ static int null_ldisc(void *handle, int option) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void null_provide_ldisc (void *handle, void *ldisc) {
|
||||
static void null_provide_ldisc (void *handle, Ldisc *ldisc) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ struct gui_data {
|
|||
char *wintitle;
|
||||
char *icontitle;
|
||||
int master_fd, master_func_id;
|
||||
void *ldisc;
|
||||
Ldisc *ldisc;
|
||||
Backend *back;
|
||||
void *backhandle;
|
||||
Terminal *term;
|
||||
|
|
|
@ -1206,7 +1206,7 @@ static int pty_ldisc(void *handle, int option)
|
|||
return 0; /* neither editing nor echoing */
|
||||
}
|
||||
|
||||
static void pty_provide_ldisc(void *handle, void *ldisc)
|
||||
static void pty_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
{
|
||||
/* Pty pty = (Pty)handle; */
|
||||
/* This is a stub. */
|
||||
|
|
|
@ -544,7 +544,7 @@ static int serial_ldisc(void *handle, int option)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void serial_provide_ldisc(void *handle, void *ldisc)
|
||||
static void serial_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ static int caret_x = -1, caret_y = -1;
|
|||
|
||||
static int kbd_codepage;
|
||||
|
||||
static void *ldisc;
|
||||
static Ldisc *ldisc;
|
||||
static Backend *back;
|
||||
static void *backhandle;
|
||||
|
||||
|
|
|
@ -409,7 +409,7 @@ static int serial_ldisc(void *handle, int option)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void serial_provide_ldisc(void *handle, void *ldisc)
|
||||
static void serial_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче