diff --git a/defs.h b/defs.h index bfdf345d..f1d73fb5 100644 --- a/defs.h +++ b/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 diff --git a/fuzzterm.c b/fuzzterm.c index 21246069..cdefb0d9 100644 --- a/fuzzterm.c +++ b/fuzzterm.c @@ -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; diff --git a/ldisc.c b/ldisc.c index 06c5e90f..ba90e1d0 100644 --- a/ldisc.c +++ b/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; /* 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); diff --git a/ldisc.h b/ldisc.h index 5dbe2a76..44f5772f 100644 --- a/ldisc.h +++ b/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 */ diff --git a/ldiscucs.c b/ldiscucs.c index 1634bc43..6c943a09 100644 --- a/ldiscucs.c +++ b/ldiscucs.c @@ -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; diff --git a/pscp.c b/pscp.c index 22cbf57e..964e2443 100644 --- a/pscp.c +++ b/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) { diff --git a/psftp.c b/psftp.c index 46eeeb40..b28c0976 100644 --- a/psftp.c +++ b/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 diff --git a/putty.h b/putty.h index 844c6fa1..042f66c5 100644 --- a/putty.h +++ b/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. diff --git a/raw.c b/raw.c index 67d34601..58a500c7 100644 --- a/raw.c +++ b/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. */ } diff --git a/rlogin.c b/rlogin.c index 9156340c..7f9093e4 100644 --- a/rlogin.c +++ b/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. */ } diff --git a/ssh.c b/ssh.c index 4c237e31..d02b7321 100644 --- a/ssh.c +++ b/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; diff --git a/telnet.c b/telnet.c index 6fe509dc..0f958b50 100644 --- a/telnet.c +++ b/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; diff --git a/terminal.h b/terminal.h index ba4a07f6..3eb60939 100644 --- a/terminal.h +++ b/terminal.h @@ -230,7 +230,7 @@ struct terminal_tag { void (*resize_fn)(void *, int, int); void *resize_ctx; - void *ldisc; + Ldisc *ldisc; void *frontend; diff --git a/testback.c b/testback.c index a84caee0..d84c77db 100644 --- a/testback.c +++ b/testback.c @@ -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) { } diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 5b84c7c9..e28146b4 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -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; diff --git a/unix/uxpty.c b/unix/uxpty.c index 7aaad8ac..9df61532 100644 --- a/unix/uxpty.c +++ b/unix/uxpty.c @@ -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. */ diff --git a/unix/uxser.c b/unix/uxser.c index e77f797a..558cf015 100644 --- a/unix/uxser.c +++ b/unix/uxser.c @@ -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. */ } diff --git a/windows/window.c b/windows/window.c index 1a7bb472..80b94201 100644 --- a/windows/window.c +++ b/windows/window.c @@ -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; diff --git a/windows/winser.c b/windows/winser.c index 976f8955..2dd45fac 100644 --- a/windows/winser.c +++ b/windows/winser.c @@ -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. */ }