Repository: guacamole-server Updated Branches: refs/heads/master 79ce5ad8b -> d8cb2218e
GUACAMOLE-597: Additionally parse integer flags which may affect pipe stream contents. Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/e02df8d5 Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/e02df8d5 Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/e02df8d5 Branch: refs/heads/master Commit: e02df8d5504214acf3b01cc55e124754ce0b4bcf Parents: 79ce5ad Author: Michael Jumper <mjum...@apache.org> Authored: Sun Jul 1 22:25:09 2018 -0700 Committer: Michael Jumper <mjum...@apache.org> Committed: Fri Jul 27 14:23:33 2018 -0700 ---------------------------------------------------------------------- src/terminal/terminal.c | 8 +++++--- src/terminal/terminal/terminal.h | 14 +++++++++++++- src/terminal/terminal_handlers.c | 33 +++++++++++++++++++++++++-------- 3 files changed, 43 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/e02df8d5/src/terminal/terminal.c ---------------------------------------------------------------------- diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index b24ec8e..5a106ad 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -1961,7 +1961,8 @@ int guac_terminal_next_tab(guac_terminal* term, int column) { return tabstop; } -void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name) { +void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name, + int flags) { guac_client* client = term->client; guac_socket* socket = client->socket; @@ -1972,13 +1973,14 @@ void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name) { /* Allocate and assign new pipe stream */ term->pipe_stream = guac_client_alloc_stream(client); term->pipe_buffer_length = 0; + term->pipe_stream_flags = flags; /* Open new pipe stream */ guac_protocol_send_pipe(socket, term->pipe_stream, "text/plain", name); /* Log redirect at debug level */ - guac_client_log(client, GUAC_LOG_DEBUG, - "Terminal output now redirected to pipe '%s'.", name); + guac_client_log(client, GUAC_LOG_DEBUG, "Terminal output now directed to " + "pipe \"%s\" (flags=%i).", name, flags); } http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/e02df8d5/src/terminal/terminal/terminal.h ---------------------------------------------------------------------- diff --git a/src/terminal/terminal/terminal.h b/src/terminal/terminal/terminal.h index adadc4f..e086392 100644 --- a/src/terminal/terminal/terminal.h +++ b/src/terminal/terminal/terminal.h @@ -216,6 +216,13 @@ struct guac_terminal { guac_stream* pipe_stream; /** + * 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. + */ + int pipe_stream_flags; + + /** * Buffer of data pending write to the pipe_stream. Data within this buffer * will be flushed to the pipe_stream when either (1) the buffer is full * and another character needs to be written or (2) the pipe_stream is @@ -920,8 +927,13 @@ int guac_terminal_next_tab(guac_terminal* term, int column); * * @param name * The name of the pipe stream to open. + * + * @param flags + * A bitwise OR of all integer flags which should apply to the new pipe + * stream. */ -void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name); +void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name, + int flags); /** * Writes a single byte of data to the pipe stream currently open and http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/e02df8d5/src/terminal/terminal_handlers.c ---------------------------------------------------------------------- diff --git a/src/terminal/terminal_handlers.c b/src/terminal/terminal_handlers.c index afbf20e..1437307 100644 --- a/src/terminal/terminal_handlers.c +++ b/src/terminal/terminal_handlers.c @@ -1141,27 +1141,44 @@ int guac_terminal_download(guac_terminal* term, unsigned char c) { int guac_terminal_open_pipe_stream(guac_terminal* term, unsigned char c) { - static char stream_name[2048]; + static char param[2048]; static int length = 0; + static int flags = 0; /* Open pipe on ECMA-48 ST (String Terminator) */ if (c == 0x9C || c == 0x5C || c == 0x07) { - /* End stream name string */ - stream_name[length++] = '\0'; + /* End parameter string */ + param[length++] = '\0'; length = 0; - /* Open new pipe stream */ - guac_terminal_pipe_stream_open(term, stream_name); + /* Open new pipe stream using final parameter as name */ + guac_terminal_pipe_stream_open(term, param, flags); /* Return to echo mode */ term->char_handler = guac_terminal_echo; + /* Reset tracked flags for sake of any future pipe streams */ + flags = 0; + + } + + /* Interpret all parameters prior to the final parameter as integer + * flags which should affect the pipe stream when opened */ + else if (c == ';') { + + /* End parameter string */ + param[length++] = '\0'; + length = 0; + + /* Parse parameter string as integer flags */ + flags |= atoi(param); + } - /* Otherwise, store character within stream name */ - else if (length < sizeof(stream_name)-1) - stream_name[length++] = c; + /* Otherwise, store character within parameter */ + else if (length < sizeof(param)-1) + param[length++] = c; return 0;