mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Dave Hinton's modifications to the network layer interface, which
should make it possible to add SSL support later. [originally from svn r996]
This commit is contained in:
29
telnet.c
29
telnet.c
@ -465,19 +465,17 @@ static void do_telnet_read (char *buf, int len) {
|
||||
}
|
||||
}
|
||||
|
||||
static int telnet_receive(Socket skt, 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. */
|
||||
sk_close(s);
|
||||
s = NULL;
|
||||
connection_fatal(data);
|
||||
return 0;
|
||||
} else 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;
|
||||
@ -491,6 +489,11 @@ static int telnet_receive(Socket skt, 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;
|
||||
|
||||
@ -507,7 +510,7 @@ static char *telnet_init (char *host, int port, char **realhost) {
|
||||
/*
|
||||
* Open socket.
|
||||
*/
|
||||
s = sk_new(addr, port, 0, 1, telnet_receive);
|
||||
s = sk_new(addr, port, 0, 1, &fn_table_ptr);
|
||||
if ( (err = sk_socket_error(s)) )
|
||||
return err;
|
||||
|
||||
|
Reference in New Issue
Block a user