Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
The `socket' function in the backends is only ever checked to see if
Browse files Browse the repository at this point in the history
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.


git-svn-id: svn://svn.tartarus.org/sgt/putty@6810 cda61777-01e9-0310-a592-d414129be87e
  • Loading branch information
simon committed Aug 27, 2006
1 parent 616741f commit 6226c93
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions pscp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions psftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion putty.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
6 changes: 3 additions & 3 deletions raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -270,7 +270,7 @@ Backend raw_backend = {
raw_size,
raw_special,
raw_get_specials,
raw_socket,
raw_connected,
raw_exitcode,
raw_sendok,
raw_ldisc,
Expand Down
6 changes: 3 additions & 3 deletions rlogin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -341,7 +341,7 @@ Backend rlogin_backend = {
rlogin_size,
rlogin_special,
rlogin_get_specials,
rlogin_socket,
rlogin_connected,
rlogin_exitcode,
rlogin_sendok,
rlogin_ldisc,
Expand Down
6 changes: 3 additions & 3 deletions ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1085,7 +1085,7 @@ Backend telnet_backend = {
telnet_size,
telnet_special,
telnet_get_specials,
telnet_socket,
telnet_connected,
telnet_exitcode,
telnet_sendok,
telnet_ldisc,
Expand Down
6 changes: 3 additions & 3 deletions unix/uxplink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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");
Expand All @@ -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 */
Expand Down
6 changes: 3 additions & 3 deletions unix/uxpty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1068,7 +1068,7 @@ Backend pty_backend = {
pty_size,
pty_special,
pty_get_specials,
pty_socket,
pty_connected,
pty_exitcode,
pty_sendok,
pty_ldisc,
Expand Down
6 changes: 3 additions & 3 deletions windows/winplink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)));
}
Expand Down Expand Up @@ -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 */
}
Expand Down

0 comments on commit 6226c93

Please sign in to comment.