X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/0965bee0865fd8ea129b2de62a3c50e09c59a184..765c42008aab65bf1b3c2ba7d0eb156ab447386f:/telnet.c diff --git a/telnet.c b/telnet.c index 3e65cd41..29daf0f1 100644 --- a/telnet.c +++ b/telnet.c @@ -174,7 +174,7 @@ static void deactivate_option (struct Opt *o) { static void option_side_effects(struct Opt *o, int enabled) { if (o->option == TELOPT_ECHO && o->send == DO) echoing = !enabled; - else if (o->option = TELOPT_SGA && o->send == DO) + else if (o->option == TELOPT_SGA && o->send == DO) editing = !enabled; ldisc_send(NULL, 0); /* cause ldisc to notice the change */ } @@ -465,18 +465,18 @@ static void do_telnet_read (char *buf, int len) { } } -static int telnet_receive(Socket s, int urgent, char *data, int len) { - if (urgent==3) { +static int telnet_closing (Plug plug, char *error_msg, int error_code, int calling_back) { + sk_close(s); + s = NULL; + if (error_msg) { /* A socket error has occurred. */ - connection_fatal(data); - len = 0; - } - if (!len) { - /* Connection has closed. */ - sk_close(s); - s = NULL; - return 0; - } + connection_fatal (error_msg); + } /* Otherwise, the remote side closed the connection normally. */ + return 0; +} + +static int telnet_receive(Plug plug, int urgent, char *data, int len) { + if(urgent) in_synch = TRUE; do_telnet_read (data, len); return 1; } @@ -489,6 +489,11 @@ static int telnet_receive(Socket s, int urgent, char *data, int len) { * Also places the canonical host name into `realhost'. */ static char *telnet_init (char *host, int port, char **realhost) { + static struct plug_function_table fn_table = { + telnet_closing, + telnet_receive + }, *fn_table_ptr = &fn_table; + SockAddr addr; char *err; @@ -505,7 +510,7 @@ static char *telnet_init (char *host, int port, char **realhost) { /* * Open socket. */ - s = sk_new(addr, port, 0, telnet_receive); + s = sk_new(addr, port, 0, 1, &fn_table_ptr); if ( (err = sk_socket_error(s)) ) return err;