From 273c6a8503681f2ee0742514020a56a13ebd80b1 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 20 Oct 2013 19:09:15 -0700 Subject: [PATCH] Stub out guac OSC handling. --- src/protocols/ssh/terminal_handlers.c | 72 +++++++++++++++++++++++++-- src/protocols/ssh/terminal_handlers.h | 2 + 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/protocols/ssh/terminal_handlers.c b/src/protocols/ssh/terminal_handlers.c index e555b003..14c4614b 100644 --- a/src/protocols/ssh/terminal_handlers.c +++ b/src/protocols/ssh/terminal_handlers.c @@ -890,10 +890,76 @@ int guac_terminal_csi(guac_terminal* term, char c) { } +int guac_terminal_guac_set_directory(guac_terminal* term, char c) { + + static char filename[2048]; + static int length = 0; + + /* Stop on ECMA-48 ST (String Terminator */ + if (c == 0x9C || c == 0x5C || c == 0x07) { + filename[length++] = '\0'; + term->char_handler = guac_terminal_echo; + guac_client_log_info(term->client, "STUB: set: %s", filename); + length = 0; + } + + /* Otherwise, store character */ + else if (length < sizeof(filename)-1) + filename[length++] = c; + + return 0; + +} + +int guac_terminal_guac_download(guac_terminal* term, char c) { + + static char filename[2048]; + static int length = 0; + + /* Stop on ECMA-48 ST (String Terminator */ + if (c == 0x9C || c == 0x5C || c == 0x07) { + filename[length++] = '\0'; + term->char_handler = guac_terminal_echo; + guac_client_log_info(term->client, "STUB: get: %s", filename); + length = 0; + } + + /* Otherwise, store character */ + else if (length < sizeof(filename)-1) + filename[length++] = c; + + return 0; + +} + int guac_terminal_osc(guac_terminal* term, char c) { - /* TODO: Implement OSC */ - if (c == 0x9C || c == 0x5C || c == 0x07) /* ECMA-48 ST (String Terminator */ - term->char_handler = guac_terminal_echo; + + static int operation = 0; + + /* If digit, append to operation */ + if (c >= '0' && c <= '9') + operation = operation * 10 + c - '0'; + + /* If end of parameter, check value */ + else if (c == ';') { + + /* Download OSC */ + if (operation == 482200) + term->char_handler = guac_terminal_guac_download; + + /* Set upload directory OSC */ + else if (operation == 482201) + term->char_handler = guac_terminal_guac_set_directory; + + /* Reset parameter for next OSC */ + operation = 0; + + } + + /* Stop on ECMA-48 ST (String Terminator */ + else if (c == 0x9C || c == 0x5C || c == 0x07) + term->char_handler = guac_terminal_echo; + return 0; } diff --git a/src/protocols/ssh/terminal_handlers.h b/src/protocols/ssh/terminal_handlers.h index 3b1faf68..0efa7be7 100644 --- a/src/protocols/ssh/terminal_handlers.h +++ b/src/protocols/ssh/terminal_handlers.h @@ -47,6 +47,8 @@ int guac_terminal_g1_charset(guac_terminal* term, char c); int guac_terminal_g2_charset(guac_terminal* term, char c); int guac_terminal_g3_charset(guac_terminal* term, char c); int guac_terminal_csi(guac_terminal* term, char c); +int guac_terminal_guac_download(guac_terminal* term, char c); +int guac_terminal_guac_set_directory(guac_terminal* term, char c); int guac_terminal_osc(guac_terminal* term, char c); int guac_terminal_ctrl_func(guac_terminal* term, char c);