Robert de Bath's patch: integrate line disciplines into Telnet and have them
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 11 Mar 2000 14:06:11 +0000 (14:06 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 11 Mar 2000 14:06:11 +0000 (14:06 +0000)
interoperate sensibly with ECHO negotiations

git-svn-id: svn://svn.tartarus.org/sgt/putty@401 cda61777-01e9-0310-a592-d414129be87e

putty.h
telnet.c
window.c

diff --git a/putty.h b/putty.h
index 0d93665..8217024 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -79,7 +79,7 @@ GLOBAL char *logfile;
 
 typedef enum {
     TS_AYT, TS_BRK, TS_SYNCH, TS_EC, TS_EL, TS_GA, TS_NOP, TS_ABORT,
-    TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF
+    TS_AO, TS_IP, TS_SUSP, TS_EOR, TS_EOF, TS_LECHO, TS_RECHO
 } Telnet_Special;
 
 typedef enum {
index 24962bb..7dd7f1e 100644 (file)
--- a/telnet.c
+++ b/telnet.c
@@ -216,6 +216,11 @@ static void activate_option (struct Opt *o) {
         */
        deactivate_option (o->option==TELOPT_NEW_ENVIRON ? &o_oenv : &o_nenv);
     }
+    if (o->option == TELOPT_ECHO)
+    {
+       cfg.ldisc_term = FALSE;
+       ldisc = &ldisc_simple;
+    }
 }
 
 static void refused_option (struct Opt *o) {
@@ -224,6 +229,11 @@ static void refused_option (struct Opt *o) {
        send_opt (WILL, TELOPT_OLD_ENVIRON);
        o_oenv.state = REQUESTED;
     }
+    if (o->option == TELOPT_ECHO)
+    {
+       cfg.ldisc_term = TRUE;
+       ldisc = &ldisc_term;
+    }
 }
 
 static void proc_rec_opt (int cmd, int option) {
@@ -719,8 +729,20 @@ static void telnet_special (Telnet_Special code) {
       case TS_EOF: b[1] = xEOF; s_write (b, 2); break;
       case TS_SYNCH:
        outbuf_head = outbuf_reap = 0;
-       b[0] = DM;
-       send (s, b, 1, MSG_OOB);
+       b[1] = DM;
+       send (s, b, 2, MSG_OOB);
+       break;
+      case TS_RECHO:
+       if (o_echo.state == INACTIVE || o_echo.state == REALLY_INACTIVE) {
+           o_echo.state = REQUESTED;
+           send_opt (o_echo.send, o_echo.option);
+       }
+       break;
+      case TS_LECHO:
+       if (o_echo.state == ACTIVE) {
+           o_echo.state = REQUESTED;
+           send_opt (o_echo.nsend, o_echo.option);
+       }
        break;
     }
 }
index 89631a3..6bd518b 100644 (file)
--- a/window.c
+++ b/window.c
@@ -730,6 +730,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
            init_fonts();
            sfree(logpal);
            ldisc = (cfg.ldisc_term ? &ldisc_term : &ldisc_simple);
+           back->special (cfg.ldisc_term ? TS_LECHO : TS_RECHO);
            if (pal)
                DeleteObject(pal);
            logpal = NULL;