Patch to PSFTP: implement mkdir, rmdir, rm and scripting. Still to
[u/mdw/putty] / telnet.c
index 41de319..04cbec0 100644 (file)
--- a/telnet.c
+++ b/telnet.c
@@ -565,8 +565,10 @@ static void do_telnet_read(char *buf, int len)
 static int telnet_closing(Plug plug, char *error_msg, int error_code,
                          int calling_back)
 {
-    sk_close(s);
-    s = NULL;
+    if (s) {
+        sk_close(s);
+        s = NULL;
+    }
     if (error_msg) {
        /* A socket error has occurred. */
        connection_fatal(error_msg);
@@ -653,7 +655,9 @@ static void telnet_send(char *buf, int len)
     char *p;
     static unsigned char iac[2] = { IAC, IAC };
     static unsigned char cr[2] = { CR, NUL };
+#if 0
     static unsigned char nl[2] = { CR, LF };
+#endif
 
     if (s == NULL)
        return;
@@ -667,7 +671,7 @@ static void telnet_send(char *buf, int len)
        sk_write(s, q, p - q);
 
        while (p < buf + len && !iswritable((unsigned char) *p)) {
-           sk_write(s, (unsigned char) *p == IAC ? iac : nl, 2);
+           sk_write(s, (unsigned char) *p == IAC ? iac : cr, 2);
            p++;
        }
     }
@@ -759,6 +763,9 @@ static void telnet_special(Telnet_Special code)
        b[1] = xEOF;
        sk_write(s, b, 2);
        break;
+      case TS_EOL:
+       sk_write(s, "\r\n", 2);
+       break;
       case TS_SYNCH:
        b[1] = DM;
        sk_write(s, b, 1);