projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add the ability to close sessions. This adds *_free() functions to most
[u/mdw/putty]
/
telnet.c
diff --git
a/telnet.c
b/telnet.c
index
2d87b31
..
f2d31ef
100644
(file)
--- a/
telnet.c
+++ b/
telnet.c
@@
-689,7
+689,7
@@
static char *telnet_init(void *frontend_handle, void **backend_handle,
logevent(telnet->frontend, buf);
sfree(buf);
}
logevent(telnet->frontend, buf);
sfree(buf);
}
- addr = name_lookup(host, port, realhost);
+ addr = name_lookup(host, port, realhost
, &telnet->cfg
);
if ((err = sk_addr_error(addr)) != NULL)
return err;
if ((err = sk_addr_error(addr)) != NULL)
return err;
@@
-707,7
+707,7
@@
static char *telnet_init(void *frontend_handle, void **backend_handle,
sfree(buf);
}
telnet->s = new_connection(addr, *realhost, port, 0, 1,
sfree(buf);
}
telnet->s = new_connection(addr, *realhost, port, 0, 1,
- nodelay, (Plug) telnet);
+ nodelay, (Plug) telnet
, &telnet->cfg
);
if ((err = sk_socket_error(telnet->s)) != NULL)
return err;
if ((err = sk_socket_error(telnet->s)) != NULL)
return err;
@@
-740,6
+740,15
@@
static char *telnet_init(void *frontend_handle, void **backend_handle,
return NULL;
}
return NULL;
}
+static void telnet_free(void *handle)
+{
+ Telnet telnet = (Telnet) handle;
+
+ sfree(telnet->sb_buf);
+ if (telnet->s)
+ sk_close(telnet->s);
+ sfree(telnet);
+}
/*
* Reconfigure the Telnet backend. There's no immediate action
* necessary, in this backend: we just save the fresh config for
/*
* Reconfigure the Telnet backend. There's no immediate action
* necessary, in this backend: we just save the fresh config for
@@
-758,10
+767,10
@@
static int telnet_send(void *handle, char *buf, int len)
{
Telnet telnet = (Telnet) handle;
unsigned char *p, *end;
{
Telnet telnet = (Telnet) handle;
unsigned char *p, *end;
- static unsigned char iac[2] = { IAC, IAC };
- static unsigned char cr[2] = { CR, NUL };
+ static
const
unsigned char iac[2] = { IAC, IAC };
+ static
const
unsigned char cr[2] = { CR, NUL };
#if 0
#if 0
- static unsigned char nl[2] = { CR, LF };
+ static
const
unsigned char nl[2] = { CR, LF };
#endif
if (telnet->s == NULL)
#endif
if (telnet->s == NULL)
@@
-974,6
+983,7
@@
static int telnet_exitcode(void *handle)
Backend telnet_backend = {
telnet_init,
Backend telnet_backend = {
telnet_init,
+ telnet_free,
telnet_reconfig,
telnet_send,
telnet_sendbuffer,
telnet_reconfig,
telnet_send,
telnet_sendbuffer,