mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
The `socket' function in the backends is only ever checked to see if
it's NULL. Since we already have one back end (uxpty) which doesn't in fact talk to a network socket, and may well have more soon, I'm replacing this TCP/IP-centric function with a nice neutral `connected' function returning a boolean. Nothing else about its semantics has currently changed. [originally from svn r6810]
This commit is contained in:
parent
cda522186a
commit
c353c3cc97
4
pscp.c
4
pscp.c
@ -292,7 +292,7 @@ static void bump(char *fmt, ...)
|
||||
sfree(str2);
|
||||
errs++;
|
||||
|
||||
if (back != NULL && back->socket(backhandle) != NULL) {
|
||||
if (back != NULL && back->connected(backhandle)) {
|
||||
char ch;
|
||||
back->special(backhandle, TS_EOF);
|
||||
ssh_scp_recv((unsigned char *) &ch, 1);
|
||||
@ -2285,7 +2285,7 @@ int psftp_main(int argc, char *argv[])
|
||||
tolocal(argc, argv);
|
||||
}
|
||||
|
||||
if (back != NULL && back->socket(backhandle) != NULL) {
|
||||
if (back != NULL && back->connected(backhandle)) {
|
||||
char ch;
|
||||
back->special(backhandle, TS_EOF);
|
||||
ssh_scp_recv((unsigned char *) &ch, 1);
|
||||
|
4
psftp.c
4
psftp.c
@ -952,7 +952,7 @@ int sftp_cmd_close(struct sftp_command *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (back != NULL && back->socket(backhandle) != NULL) {
|
||||
if (back != NULL && back->connected(backhandle)) {
|
||||
char ch;
|
||||
back->special(backhandle, TS_EOF);
|
||||
sftp_recvdata(&ch, 1);
|
||||
@ -2909,7 +2909,7 @@ int psftp_main(int argc, char *argv[])
|
||||
|
||||
do_sftp(mode, modeflags, batchfile);
|
||||
|
||||
if (back != NULL && back->socket(backhandle) != NULL) {
|
||||
if (back != NULL && back->connected(backhandle)) {
|
||||
char ch;
|
||||
back->special(backhandle, TS_EOF);
|
||||
sftp_recvdata(&ch, 1);
|
||||
|
2
putty.h
2
putty.h
@ -357,7 +357,7 @@ struct backend_tag {
|
||||
void (*size) (void *handle, int width, int height);
|
||||
void (*special) (void *handle, Telnet_Special code);
|
||||
const struct telnet_special *(*get_specials) (void *handle);
|
||||
Socket(*socket) (void *handle);
|
||||
int (*connected) (void *handle);
|
||||
int (*exitcode) (void *handle);
|
||||
/* If back->sendok() returns FALSE, data sent to it from the frontend
|
||||
* may be lost. */
|
||||
|
6
raw.c
6
raw.c
@ -209,10 +209,10 @@ static const struct telnet_special *raw_get_specials(void *handle)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Socket raw_socket(void *handle)
|
||||
static int raw_connected(void *handle)
|
||||
{
|
||||
Raw raw = (Raw) handle;
|
||||
return raw->s;
|
||||
return raw->s != NULL;
|
||||
}
|
||||
|
||||
static int raw_sendok(void *handle)
|
||||
@ -270,7 +270,7 @@ Backend raw_backend = {
|
||||
raw_size,
|
||||
raw_special,
|
||||
raw_get_specials,
|
||||
raw_socket,
|
||||
raw_connected,
|
||||
raw_exitcode,
|
||||
raw_sendok,
|
||||
raw_ldisc,
|
||||
|
6
rlogin.c
6
rlogin.c
@ -280,10 +280,10 @@ static const struct telnet_special *rlogin_get_specials(void *handle)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Socket rlogin_socket(void *handle)
|
||||
static int rlogin_connected(void *handle)
|
||||
{
|
||||
Rlogin rlogin = (Rlogin) handle;
|
||||
return rlogin->s;
|
||||
return rlogin->s != NULL;
|
||||
}
|
||||
|
||||
static int rlogin_sendok(void *handle)
|
||||
@ -341,7 +341,7 @@ Backend rlogin_backend = {
|
||||
rlogin_size,
|
||||
rlogin_special,
|
||||
rlogin_get_specials,
|
||||
rlogin_socket,
|
||||
rlogin_connected,
|
||||
rlogin_exitcode,
|
||||
rlogin_sendok,
|
||||
rlogin_ldisc,
|
||||
|
6
ssh.c
6
ssh.c
@ -8725,10 +8725,10 @@ void ssh_send_port_open(void *channel, char *hostname, int port, char *org)
|
||||
}
|
||||
}
|
||||
|
||||
static Socket ssh_socket(void *handle)
|
||||
static int ssh_connected(void *handle)
|
||||
{
|
||||
Ssh ssh = (Ssh) handle;
|
||||
return ssh->s;
|
||||
return ssh->s != NULL;
|
||||
}
|
||||
|
||||
static int ssh_sendok(void *handle)
|
||||
@ -8798,7 +8798,7 @@ Backend ssh_backend = {
|
||||
ssh_size,
|
||||
ssh_special,
|
||||
ssh_get_specials,
|
||||
ssh_socket,
|
||||
ssh_connected,
|
||||
ssh_return_exitcode,
|
||||
ssh_sendok,
|
||||
ssh_ldisc,
|
||||
|
6
telnet.c
6
telnet.c
@ -1019,10 +1019,10 @@ static const struct telnet_special *telnet_get_specials(void *handle)
|
||||
return specials;
|
||||
}
|
||||
|
||||
static Socket telnet_socket(void *handle)
|
||||
static int telnet_connected(void *handle)
|
||||
{
|
||||
Telnet telnet = (Telnet) handle;
|
||||
return telnet->s;
|
||||
return telnet->s != NULL;
|
||||
}
|
||||
|
||||
static int telnet_sendok(void *handle)
|
||||
@ -1085,7 +1085,7 @@ Backend telnet_backend = {
|
||||
telnet_size,
|
||||
telnet_special,
|
||||
telnet_get_specials,
|
||||
telnet_socket,
|
||||
telnet_connected,
|
||||
telnet_exitcode,
|
||||
telnet_sendok,
|
||||
telnet_ldisc,
|
||||
|
@ -899,7 +899,7 @@ int main(int argc, char **argv)
|
||||
FD_SET_MAX(signalpipe[0], maxfd, rset);
|
||||
|
||||
if (connopen && !sending &&
|
||||
back->socket(backhandle) != NULL &&
|
||||
back->connected(backhandle) &&
|
||||
back->sendok(backhandle) &&
|
||||
back->sendbuffer(backhandle) < MAX_STDIN_BACKLOG) {
|
||||
/* If we're OK to send, then try to read from stdin. */
|
||||
@ -1014,7 +1014,7 @@ int main(int argc, char **argv)
|
||||
char buf[4096];
|
||||
int ret;
|
||||
|
||||
if (connopen && back->socket(backhandle) != NULL) {
|
||||
if (connopen && back->connected(backhandle)) {
|
||||
ret = read(0, buf, sizeof(buf));
|
||||
if (ret < 0) {
|
||||
perror("stdin: read");
|
||||
@ -1039,7 +1039,7 @@ int main(int argc, char **argv)
|
||||
try_output(1);
|
||||
}
|
||||
|
||||
if ((!connopen || back->socket(backhandle) == NULL) &&
|
||||
if ((!connopen || !back->connected(backhandle)) &&
|
||||
bufchain_size(&stdout_data) == 0 &&
|
||||
bufchain_size(&stderr_data) == 0)
|
||||
break; /* we closed the connection */
|
||||
|
@ -1008,10 +1008,10 @@ static const struct telnet_special *pty_get_specials(void *handle)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static Socket pty_socket(void *handle)
|
||||
static int pty_connected(void *handle)
|
||||
{
|
||||
/* Pty pty = (Pty)handle; */
|
||||
return NULL; /* shouldn't ever be needed */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int pty_sendok(void *handle)
|
||||
@ -1068,7 +1068,7 @@ Backend pty_backend = {
|
||||
pty_size,
|
||||
pty_special,
|
||||
pty_get_specials,
|
||||
pty_socket,
|
||||
pty_connected,
|
||||
pty_exitcode,
|
||||
pty_sendok,
|
||||
pty_ldisc,
|
||||
|
@ -218,7 +218,7 @@ int stdin_gotdata(struct handle *h, void *data, int len)
|
||||
cleanup_exit(0);
|
||||
}
|
||||
noise_ultralight(len);
|
||||
if (connopen && back->socket(backhandle) != NULL) {
|
||||
if (connopen && back->connected(backhandle)) {
|
||||
if (len > 0) {
|
||||
return back->send(backhandle, data, len);
|
||||
} else {
|
||||
@ -239,7 +239,7 @@ void stdouterr_sent(struct handle *h, int new_backlog)
|
||||
(h == stdout_handle ? "output" : "error"));
|
||||
cleanup_exit(0);
|
||||
}
|
||||
if (connopen && back->socket(backhandle) != NULL) {
|
||||
if (connopen && back->connected(backhandle)) {
|
||||
back->unthrottle(backhandle, (handle_backlog(stdout_handle) +
|
||||
handle_backlog(stderr_handle)));
|
||||
}
|
||||
@ -694,7 +694,7 @@ int main(int argc, char **argv)
|
||||
if (sending)
|
||||
handle_unthrottle(stdin_handle, back->sendbuffer(backhandle));
|
||||
|
||||
if ((!connopen || back->socket(backhandle) == NULL) &&
|
||||
if ((!connopen || !back->connected(backhandle)) &&
|
||||
handle_backlog(stdout_handle) + handle_backlog(stderr_handle) == 0)
|
||||
break; /* we closed the connection */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user