Fix echoing of ICS commands in ICS/Chat window
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 1 Jun 2019 13:58:01 +0000 (15:58 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 1 Jun 2019 14:02:24 +0000 (16:02 +0200)
The ICS output pane did not show the commands submitted to the ICS
by typing in the input field. Now it does, but to prevent the password
from being shown this is made dependent on the value of 'remoteEchoOption'.
Which, to this end, had to be made an external variable shared through
backend.h.

backend.c
backend.h
dialogs.c

index 0050f11..da93d18 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -2844,6 +2844,8 @@ SeekGraphClick (ClickType click, int x, int y, int moving)
     return TRUE;
 }
 
+int remoteEchoOption = FALSE; /* telnet ECHO option */
+
 void
 read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int error)
 {
@@ -2977,7 +2979,6 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int
               telnet server that will try to keep WILL ECHO on permanently.
              */
            if (buf_len - i >= 3 && (unsigned char) buf[i] == TN_IAC) {
-               static int remoteEchoOption = FALSE; /* telnet ECHO option */
                unsigned char option;
                oldi = i;
                switch ((unsigned char) buf[++i]) {
index 2fbae11..d9392c4 100644 (file)
--- a/backend.h
+++ b/backend.h
@@ -411,6 +411,7 @@ typedef struct {
 extern ChessProgramStats_Move pvInfoList[MAX_MOVES];
 extern Boolean shuffleOpenings;
 extern ChessProgramStats programStats;
+extern int remoteEchoOption;
 extern int opponentKibitzes; // used by wengineo.c
 extern int errorExitStatus;
 extern char *recentEngines;
index c1d0930..421e938 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -2181,8 +2181,10 @@ ChatOK (int n)
        // from here on it could be back-end
        if(line[strlen(line)-1] == '\n') line[strlen(line)-1] = NULLCHAR;
        SaveInHistory(line);
-       if(hidden || !*chatPartner[activePartner]) snprintf(buf, MSG_SIZ, "%s\n", line); else // command for ICS
-       if(!strcmp("whispers", chatPartner[activePartner]))
+       if(hidden || !*chatPartner[activePartner]) { // command for ICS
+               snprintf(buf, MSG_SIZ, "%s\n", line);
+               if(!remoteEchoOption) ConsoleWrite(buf, strlen(buf));
+       } else if(!strcmp("whispers", chatPartner[activePartner]))
              snprintf(buf, MSG_SIZ, "whisper %s\n", line); // WHISPER box uses "whisper" to send
        else if(!strcmp("shouts", chatPartner[activePartner]))
              snprintf(buf, MSG_SIZ, "shout %s\n", line); // SHOUT box uses "shout" to send