GUACAMOLE-597: Add flag which sends terminal output to both the user's display 
and the open pipe stream.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/99b17b0a
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/99b17b0a
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/99b17b0a

Branch: refs/heads/master
Commit: 99b17b0ac46ab073fe78bc0fc335aa2d3fd15039
Parents: e02df8d
Author: Michael Jumper <mjum...@apache.org>
Authored: Sun Jul 1 22:28:04 2018 -0700
Committer: Michael Jumper <mjum...@apache.org>
Committed: Fri Jul 27 14:23:44 2018 -0700

----------------------------------------------------------------------
 src/terminal/terminal/terminal.h | 11 +++++++++++
 src/terminal/terminal_handlers.c |  8 +++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/99b17b0a/src/terminal/terminal/terminal.h
----------------------------------------------------------------------
diff --git a/src/terminal/terminal/terminal.h b/src/terminal/terminal/terminal.h
index e086392..4e04fc7 100644
--- a/src/terminal/terminal/terminal.h
+++ b/src/terminal/terminal/terminal.h
@@ -98,6 +98,13 @@
  */
 #define GUAC_TERMINAL_SCHEME_NUMBERED "color"
 
+/**
+ * Flag which specifies that terminal output should be sent to both the current
+ * pipe stream and the user's display. By default, terminal output will be sent
+ * only to the open pipe.
+ */
+#define GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT 1
+
 typedef struct guac_terminal guac_terminal;
 
 /**
@@ -219,6 +226,8 @@ struct guac_terminal {
      * Bitwise OR of all flags which apply to the currently-open pipe stream.
      * If no pipe stream is open, this value has no meaning, and its contents
      * are undefined.
+     *
+     * @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT
      */
     int pipe_stream_flags;
 
@@ -931,6 +940,8 @@ int guac_terminal_next_tab(guac_terminal* term, int column);
  * @param flags
  *     A bitwise OR of all integer flags which should apply to the new pipe
  *     stream.
+ *
+ *     @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT
  */
 void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name,
         int flags);

http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/99b17b0a/src/terminal/terminal_handlers.c
----------------------------------------------------------------------
diff --git a/src/terminal/terminal_handlers.c b/src/terminal/terminal_handlers.c
index 1437307..a6469ac 100644
--- a/src/terminal/terminal_handlers.c
+++ b/src/terminal/terminal_handlers.c
@@ -135,8 +135,14 @@ int guac_terminal_echo(guac_terminal* term, unsigned char 
c) {
 
     /* Echo to pipe stream if open and not starting an ESC sequence */
     if (term->pipe_stream != NULL && c != 0x1B) {
+
         guac_terminal_pipe_stream_write(term, c);
-        return 0;
+
+        /* Do not render output while pipe is open unless explicitly requested
+         * via flags */
+        if (!(term->pipe_stream_flags & GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT))
+            return 0;
+
     }
 
     /* If using non-Unicode mapping, just map straight bytes */

Reply via email to