The `socket' function in the backends is only ever checked to see if
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 27 Aug 2006 08:03:19 +0000 (08:03 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sun, 27 Aug 2006 08:03:19 +0000 (08:03 +0000)
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

pscp.c
psftp.c
putty.h
raw.c
rlogin.c
ssh.c
telnet.c
unix/uxplink.c
unix/uxpty.c
windows/winplink.c

diff --git a/pscp.c b/pscp.c
index 5f22828..8e082e7 100644 (file)
--- a/pscp.c
+++ b/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);
diff --git a/psftp.c b/psftp.c
index db3ae7f..d07ee8b 100644 (file)
--- a/psftp.c
+++ b/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);
diff --git a/putty.h b/putty.h
index 239df42..8277bbc 100644 (file)
--- a/putty.h
+++ b/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. */
diff --git a/raw.c b/raw.c
index 28da09f..d64b6d7 100644 (file)
--- a/raw.c
+++ b/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,
index 1b9a806..833d4ea 100644 (file)
--- a/rlogin.c
+++ b/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,
diff --git a/ssh.c b/ssh.c
index 969ffbc..7c5c7bc 100644 (file)
--- a/ssh.c
+++ b/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,
index 5038833..0d32f8c 100644 (file)
--- a/telnet.c
+++ b/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,
index 735d297..1daafe4 100644 (file)
@@ -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 */
index 637eaa1..50e5371 100644 (file)
@@ -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,
index c784a5d..16351ae 100644 (file)
@@ -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 */
     }