Reorganised the Unicode layer somewhat: moved luni_send and
[u/mdw/putty] / ssh.c
diff --git a/ssh.c b/ssh.c
index 072a1b3..d158d53 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -320,7 +320,8 @@ extern void x11_unthrottle(Socket s);
 extern void x11_override_throttle(Socket s, int enable);
 
 extern char *pfd_newconnect(Socket * s, char *hostname, int port, void *c);
-extern char *pfd_addforward(char *desthost, int destport, int port);
+extern char *pfd_addforward(char *desthost, int destport, int port,
+                           void *backhandle);
 extern void pfd_close(Socket s);
 extern int pfd_send(Socket s, char *data, int len);
 extern void pfd_confirm(Socket s);
@@ -555,6 +556,8 @@ struct ssh_tag {
 
     Socket s;
 
+    void *ldisc;
+
     unsigned char session_key[32];
     int v1_compressing;
     int v1_remote_protoflags;
@@ -3111,7 +3114,7 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
            }
            if (sport && dport) {
                if (type == 'L') {
-                   pfd_addforward(host, dport, sport);
+                   pfd_addforward(host, dport, sport, ssh);
                    sprintf(buf, "Local port %.*s%.*s%d%.*s forwarding to"
                            " %s:%.*s%.*s%d%.*s",
                            sserv ? strlen(sports) : 0, sports,
@@ -3233,7 +3236,8 @@ static void ssh1_protocol(Ssh ssh, unsigned char *in, int inlen, int ispkt)
     if (ssh->eof_needed)
        ssh_special(ssh, TS_EOF);
 
-    ldisc_send(NULL, 0, 0);           /* cause ldisc to notice changes */
+    if (ssh->ldisc)
+       ldisc_send(ssh->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */
     ssh->send_ok = 1;
     ssh->channels = newtree234(ssh_channelcmp);
     while (1) {
@@ -5152,7 +5156,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
            }
            if (sport && dport) {
                if (type == 'L') {
-                   pfd_addforward(host, dport, sport);
+                   pfd_addforward(host, dport, sport, ssh);
                    sprintf(buf, "Local port %.*s%.*s%d%.*s forwarding to"
                            " %s:%.*s%.*s%d%.*s",
                            sserv ? strlen(sports) : 0, sports,
@@ -5379,7 +5383,8 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, int ispkt)
     /*
      * Transfer data!
      */
-    ldisc_send(NULL, 0, 0);           /* cause ldisc to notice changes */
+    if (ssh->ldisc)
+       ldisc_send(ssh->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */
     ssh->send_ok = 1;
     while (1) {
        crReturnV;
@@ -5854,6 +5859,7 @@ static char *ssh_init(void *frontend_handle, void **backend_handle,
     ssh->state = SSH_STATE_PREPACKET;
     ssh->size_needed = FALSE;
     ssh->eof_needed = FALSE;
+    ssh->ldisc = NULL;
     {
        static const struct Packet empty = { 0, 0, NULL, NULL, 0 };
        ssh->pktin = ssh->pktout = empty;
@@ -5969,8 +5975,6 @@ static void ssh_size(void *handle, int width, int height)
        break;
       case SSH_STATE_SESSION:
        if (!cfg.nopty) {
-           if (!term)
-               return;
            if (ssh->version == 1) {
                send_packet(ssh, SSH1_CMSG_WINDOW_SIZE,
                            PKT_INT, ssh->term_height,
@@ -6072,11 +6076,10 @@ void ssh_unthrottle(void *handle, int bufsize)
     }
 }
 
-void ssh_send_port_open(void *handle, void *channel, char *hostname,
-                       int port, char *org)
+void ssh_send_port_open(void *channel, char *hostname, int port, char *org)
 {
-    Ssh ssh = (Ssh) handle;
     struct ssh_channel *c = (struct ssh_channel *)channel;
+    Ssh ssh = c->ssh;
     char buf[1024];
 
     sprintf(buf, "Opening forwarded connection to %.512s:%d", hostname, port);
@@ -6133,6 +6136,12 @@ static int ssh_ldisc(void *handle, int option)
     return FALSE;
 }
 
+static void ssh_provide_ldisc(void *handle, void *ldisc)
+{
+    Ssh ssh = (Ssh) handle;
+    ssh->ldisc = ldisc;
+}
+
 static int ssh_return_exitcode(void *handle)
 {
     Ssh ssh = (Ssh) handle;
@@ -6160,6 +6169,7 @@ Backend ssh_backend = {
     ssh_return_exitcode,
     ssh_sendok,
     ssh_ldisc,
+    ssh_provide_ldisc,
     ssh_unthrottle,
     22
 };