1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48: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:
Simon Tatham 2006-08-27 08:03:19 +00:00
parent cda522186a
commit c353c3cc97
10 changed files with 26 additions and 26 deletions

4
pscp.c
View File

@ -292,7 +292,7 @@ static void bump(char *fmt, ...)
sfree(str2); sfree(str2);
errs++; errs++;
if (back != NULL && back->socket(backhandle) != NULL) { if (back != NULL && back->connected(backhandle)) {
char ch; char ch;
back->special(backhandle, TS_EOF); back->special(backhandle, TS_EOF);
ssh_scp_recv((unsigned char *) &ch, 1); ssh_scp_recv((unsigned char *) &ch, 1);
@ -2285,7 +2285,7 @@ int psftp_main(int argc, char *argv[])
tolocal(argc, argv); tolocal(argc, argv);
} }
if (back != NULL && back->socket(backhandle) != NULL) { if (back != NULL && back->connected(backhandle)) {
char ch; char ch;
back->special(backhandle, TS_EOF); back->special(backhandle, TS_EOF);
ssh_scp_recv((unsigned char *) &ch, 1); ssh_scp_recv((unsigned char *) &ch, 1);

View File

@ -952,7 +952,7 @@ int sftp_cmd_close(struct sftp_command *cmd)
return 0; return 0;
} }
if (back != NULL && back->socket(backhandle) != NULL) { if (back != NULL && back->connected(backhandle)) {
char ch; char ch;
back->special(backhandle, TS_EOF); back->special(backhandle, TS_EOF);
sftp_recvdata(&ch, 1); sftp_recvdata(&ch, 1);
@ -2909,7 +2909,7 @@ int psftp_main(int argc, char *argv[])
do_sftp(mode, modeflags, batchfile); do_sftp(mode, modeflags, batchfile);
if (back != NULL && back->socket(backhandle) != NULL) { if (back != NULL && back->connected(backhandle)) {
char ch; char ch;
back->special(backhandle, TS_EOF); back->special(backhandle, TS_EOF);
sftp_recvdata(&ch, 1); sftp_recvdata(&ch, 1);

View File

@ -357,7 +357,7 @@ struct backend_tag {
void (*size) (void *handle, int width, int height); void (*size) (void *handle, int width, int height);
void (*special) (void *handle, Telnet_Special code); void (*special) (void *handle, Telnet_Special code);
const struct telnet_special *(*get_specials) (void *handle); const struct telnet_special *(*get_specials) (void *handle);
Socket(*socket) (void *handle); int (*connected) (void *handle);
int (*exitcode) (void *handle); int (*exitcode) (void *handle);
/* If back->sendok() returns FALSE, data sent to it from the frontend /* If back->sendok() returns FALSE, data sent to it from the frontend
* may be lost. */ * may be lost. */

6
raw.c
View File

@ -209,10 +209,10 @@ static const struct telnet_special *raw_get_specials(void *handle)
return NULL; return NULL;
} }
static Socket raw_socket(void *handle) static int raw_connected(void *handle)
{ {
Raw raw = (Raw) handle; Raw raw = (Raw) handle;
return raw->s; return raw->s != NULL;
} }
static int raw_sendok(void *handle) static int raw_sendok(void *handle)
@ -270,7 +270,7 @@ Backend raw_backend = {
raw_size, raw_size,
raw_special, raw_special,
raw_get_specials, raw_get_specials,
raw_socket, raw_connected,
raw_exitcode, raw_exitcode,
raw_sendok, raw_sendok,
raw_ldisc, raw_ldisc,

View File

@ -280,10 +280,10 @@ static const struct telnet_special *rlogin_get_specials(void *handle)
return NULL; return NULL;
} }
static Socket rlogin_socket(void *handle) static int rlogin_connected(void *handle)
{ {
Rlogin rlogin = (Rlogin) handle; Rlogin rlogin = (Rlogin) handle;
return rlogin->s; return rlogin->s != NULL;
} }
static int rlogin_sendok(void *handle) static int rlogin_sendok(void *handle)
@ -341,7 +341,7 @@ Backend rlogin_backend = {
rlogin_size, rlogin_size,
rlogin_special, rlogin_special,
rlogin_get_specials, rlogin_get_specials,
rlogin_socket, rlogin_connected,
rlogin_exitcode, rlogin_exitcode,
rlogin_sendok, rlogin_sendok,
rlogin_ldisc, rlogin_ldisc,

6
ssh.c
View File

@ -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; Ssh ssh = (Ssh) handle;
return ssh->s; return ssh->s != NULL;
} }
static int ssh_sendok(void *handle) static int ssh_sendok(void *handle)
@ -8798,7 +8798,7 @@ Backend ssh_backend = {
ssh_size, ssh_size,
ssh_special, ssh_special,
ssh_get_specials, ssh_get_specials,
ssh_socket, ssh_connected,
ssh_return_exitcode, ssh_return_exitcode,
ssh_sendok, ssh_sendok,
ssh_ldisc, ssh_ldisc,

View File

@ -1019,10 +1019,10 @@ static const struct telnet_special *telnet_get_specials(void *handle)
return specials; return specials;
} }
static Socket telnet_socket(void *handle) static int telnet_connected(void *handle)
{ {
Telnet telnet = (Telnet) handle; Telnet telnet = (Telnet) handle;
return telnet->s; return telnet->s != NULL;
} }
static int telnet_sendok(void *handle) static int telnet_sendok(void *handle)
@ -1085,7 +1085,7 @@ Backend telnet_backend = {
telnet_size, telnet_size,
telnet_special, telnet_special,
telnet_get_specials, telnet_get_specials,
telnet_socket, telnet_connected,
telnet_exitcode, telnet_exitcode,
telnet_sendok, telnet_sendok,
telnet_ldisc, telnet_ldisc,

View File

@ -899,7 +899,7 @@ int main(int argc, char **argv)
FD_SET_MAX(signalpipe[0], maxfd, rset); FD_SET_MAX(signalpipe[0], maxfd, rset);
if (connopen && !sending && if (connopen && !sending &&
back->socket(backhandle) != NULL && back->connected(backhandle) &&
back->sendok(backhandle) && back->sendok(backhandle) &&
back->sendbuffer(backhandle) < MAX_STDIN_BACKLOG) { back->sendbuffer(backhandle) < MAX_STDIN_BACKLOG) {
/* If we're OK to send, then try to read from stdin. */ /* 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]; char buf[4096];
int ret; int ret;
if (connopen && back->socket(backhandle) != NULL) { if (connopen && back->connected(backhandle)) {
ret = read(0, buf, sizeof(buf)); ret = read(0, buf, sizeof(buf));
if (ret < 0) { if (ret < 0) {
perror("stdin: read"); perror("stdin: read");
@ -1039,7 +1039,7 @@ int main(int argc, char **argv)
try_output(1); try_output(1);
} }
if ((!connopen || back->socket(backhandle) == NULL) && if ((!connopen || !back->connected(backhandle)) &&
bufchain_size(&stdout_data) == 0 && bufchain_size(&stdout_data) == 0 &&
bufchain_size(&stderr_data) == 0) bufchain_size(&stderr_data) == 0)
break; /* we closed the connection */ break; /* we closed the connection */

View File

@ -1008,10 +1008,10 @@ static const struct telnet_special *pty_get_specials(void *handle)
return NULL; return NULL;
} }
static Socket pty_socket(void *handle) static int pty_connected(void *handle)
{ {
/* Pty pty = (Pty)handle; */ /* Pty pty = (Pty)handle; */
return NULL; /* shouldn't ever be needed */ return TRUE;
} }
static int pty_sendok(void *handle) static int pty_sendok(void *handle)
@ -1068,7 +1068,7 @@ Backend pty_backend = {
pty_size, pty_size,
pty_special, pty_special,
pty_get_specials, pty_get_specials,
pty_socket, pty_connected,
pty_exitcode, pty_exitcode,
pty_sendok, pty_sendok,
pty_ldisc, pty_ldisc,

View File

@ -218,7 +218,7 @@ int stdin_gotdata(struct handle *h, void *data, int len)
cleanup_exit(0); cleanup_exit(0);
} }
noise_ultralight(len); noise_ultralight(len);
if (connopen && back->socket(backhandle) != NULL) { if (connopen && back->connected(backhandle)) {
if (len > 0) { if (len > 0) {
return back->send(backhandle, data, len); return back->send(backhandle, data, len);
} else { } else {
@ -239,7 +239,7 @@ void stdouterr_sent(struct handle *h, int new_backlog)
(h == stdout_handle ? "output" : "error")); (h == stdout_handle ? "output" : "error"));
cleanup_exit(0); cleanup_exit(0);
} }
if (connopen && back->socket(backhandle) != NULL) { if (connopen && back->connected(backhandle)) {
back->unthrottle(backhandle, (handle_backlog(stdout_handle) + back->unthrottle(backhandle, (handle_backlog(stdout_handle) +
handle_backlog(stderr_handle))); handle_backlog(stderr_handle)));
} }
@ -694,7 +694,7 @@ int main(int argc, char **argv)
if (sending) if (sending)
handle_unthrottle(stdin_handle, back->sendbuffer(backhandle)); 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) handle_backlog(stdout_handle) + handle_backlog(stderr_handle) == 0)
break; /* we closed the connection */ break; /* we closed the connection */
} }