X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/2184a5d91ffbcf2de2f730c83dda2d9443035f50..f8255dcefee839825ac584a96dee34d03bc69677:/rlogin.c diff --git a/rlogin.c b/rlogin.c index 97699aea..74e8268b 100644 --- a/rlogin.c +++ b/rlogin.c @@ -16,12 +16,14 @@ static Socket s = NULL; static int rlogin_bufsize; +static int rlogin_term_width, rlogin_term_height; +static void *frontend; -static void rlogin_size(void); +static void rlogin_size(int width, int height); static void c_write(char *buf, int len) { - int backlog = from_backend(0, buf, len); + int backlog = from_backend(frontend, 0, buf, len); sk_set_frozen(s, backlog > RLOGIN_MAX_BACKLOG); } @@ -34,7 +36,8 @@ static int rlogin_closing(Plug plug, char *error_msg, int error_code, } if (error_msg) { /* A socket error has occurred. */ - connection_fatal(error_msg); + logevent(error_msg); + connection_fatal("%s", error_msg); } /* Otherwise, the remote side closed the connection normally. */ return 0; } @@ -47,7 +50,7 @@ static int rlogin_receive(Plug plug, int urgent, char *data, int len) c = *data++; len--; if (c == '\x80') - rlogin_size(); + rlogin_size(rlogin_term_width, rlogin_term_height); /* * We should flush everything (aka Telnet SYNCH) if we see * 0x02, and we should turn off and on _local_ flow control @@ -68,7 +71,8 @@ static int rlogin_receive(Plug plug, int urgent, char *data, int len) } firstbyte = 0; } - c_write(data, len); + if (len > 0) + c_write(data, len); } return 1; } @@ -86,7 +90,8 @@ static void rlogin_sent(Plug plug, int bufsize) * Also places the canonical host name into `realhost'. It must be * freed by the caller. */ -static char *rlogin_init(char *host, int port, char **realhost, int nodelay) +static char *rlogin_init(void *frontend_handle, + char *host, int port, char **realhost, int nodelay) { static struct plug_function_table fn_table = { rlogin_closing, @@ -97,6 +102,10 @@ static char *rlogin_init(char *host, int port, char **realhost, int nodelay) SockAddr addr; char *err; + frontend = frontend_handle; + rlogin_term_width = cfg.width; + rlogin_term_height = cfg.height; + /* * Try to find host. */ @@ -121,7 +130,7 @@ static char *rlogin_init(char *host, int port, char **realhost, int nodelay) sprintf(buf, "Connecting to %.100s port %d", addrbuf, port); logevent(buf); } - s = sk_new(addr, port, 1, 0, nodelay, &fn_table_ptr); + s = new_connection(addr, *realhost, port, 1, 0, nodelay, &fn_table_ptr); if ((err = sk_socket_error(s))) return err; @@ -173,17 +182,20 @@ static int rlogin_sendbuffer(void) /* * Called to set the size of the window */ -static void rlogin_size(void) +static void rlogin_size(int width, int height) { char b[12] = { '\xFF', '\xFF', 0x73, 0x73, 0, 0, 0, 0, 0, 0, 0, 0 }; + rlogin_term_width = width; + rlogin_term_height = height; + if (s == NULL) return; - - b[6] = cols >> 8; - b[7] = cols & 0xFF; - b[4] = rows >> 8; - b[5] = rows & 0xFF; + + b[6] = rlogin_term_width >> 8; + b[7] = rlogin_term_width & 0xFF; + b[4] = rlogin_term_height >> 8; + b[5] = rlogin_term_height & 0xFF; rlogin_bufsize = sk_write(s, b, 12); return; } @@ -217,6 +229,12 @@ static int rlogin_ldisc(int option) return 0; } +static int rlogin_exitcode(void) +{ + /* If we ever implement RSH, we'll probably need to do this properly */ + return 0; +} + Backend rlogin_backend = { rlogin_init, rlogin_send, @@ -224,6 +242,7 @@ Backend rlogin_backend = { rlogin_size, rlogin_special, rlogin_socket, + rlogin_exitcode, rlogin_sendok, rlogin_ldisc, rlogin_unthrottle,