From c286668b797a149c77ae609d654d3e7899a9c36b Mon Sep 17 00:00:00 2001 From: Nick Couchman Date: Tue, 27 Feb 2018 09:23:30 -0500 Subject: [PATCH] GUACAMOLE-269: Name functions per Guacamole standards. --- src/protocols/ssh/ssh.c | 9 +++++---- src/protocols/ssh/ttymode.c | 8 ++++---- src/protocols/ssh/ttymode.h | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 6b90a197..6aecde0c 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -193,7 +193,7 @@ void* ssh_client_thread(void* data) { } /* Initialize a ttymode array */ - guac_ssh_ttymodes ssh_ttymodes = init_ttymodes(); + guac_ssh_ttymodes ssh_ttymodes = guac_ssh_ttymodes_init(); /* Set up screen recording, if requested */ if (settings->recording_path != NULL) { @@ -213,7 +213,7 @@ void* ssh_client_thread(void* data) { settings->color_scheme, settings->backspace); /* Add the backspace key to the ttymode array */ - add_ttymode(&ssh_ttymodes, GUAC_SSH_TTY_OP_VERASE, settings->backspace); + guac_ssh_ttymodes_add(&ssh_ttymodes, GUAC_SSH_TTY_OP_VERASE, settings->backspace); /* Fail if terminal init failed */ if (ssh_client->term == NULL) { @@ -304,8 +304,9 @@ void* ssh_client_thread(void* data) { } /* Request PTY */ - if (libssh2_channel_request_pty_ex(ssh_client->term_channel, "linux", sizeof("linux")-1, ttymodes_to_array(&ssh_ttymodes), - sizeof_ttymodes(&ssh_ttymodes), ssh_client->term->term_width, ssh_client->term->term_height, 0, 0)) { + if (libssh2_channel_request_pty_ex(ssh_client->term_channel, "linux", sizeof("linux")-1, + guac_ssh_ttymodes_to_array(&ssh_ttymodes), guac_ssh_ttymodes_size(&ssh_ttymodes), + ssh_client->term->term_width, ssh_client->term->term_height, 0, 0)) { guac_client_abort(client, GUAC_PROTOCOL_STATUS_UPSTREAM_ERROR, "Unable to allocate PTY."); return NULL; } diff --git a/src/protocols/ssh/ttymode.c b/src/protocols/ssh/ttymode.c index f1e21d3f..f21e9f7f 100644 --- a/src/protocols/ssh/ttymode.c +++ b/src/protocols/ssh/ttymode.c @@ -23,7 +23,7 @@ #include #include -guac_ssh_ttymodes init_ttymodes() { +guac_ssh_ttymodes guac_ssh_ttymodes_init() { /* Simple allocation for a placeholder */ guac_ssh_ttymode* ttymode_array = malloc(1); @@ -36,7 +36,7 @@ guac_ssh_ttymodes init_ttymodes() { return empty_modes; } -void add_ttymode(guac_ssh_ttymodes *tty_modes, char opcode, uint32_t value) { +void guac_ssh_ttymodes_add(guac_ssh_ttymodes *tty_modes, char opcode, uint32_t value) { tty_modes->num_opcodes++; tty_modes->ttymode_array = realloc(tty_modes->ttymode_array, sizeof(guac_ssh_ttymode) * tty_modes->num_opcodes); tty_modes->ttymode_array[tty_modes->num_opcodes - 1].opcode = opcode; @@ -44,14 +44,14 @@ void add_ttymode(guac_ssh_ttymodes *tty_modes, char opcode, uint32_t value) { } -int sizeof_ttymodes(guac_ssh_ttymodes *tty_modes) { +int guac_ssh_ttymodes_size(guac_ssh_ttymodes *tty_modes) { /* Each opcode pair is 5 bytes (1 opcode, 4 value) Add one for the ending opcode */ return (tty_modes->num_opcodes * 5) + 1; } -char* ttymodes_to_array(guac_ssh_ttymodes *tty_modes) { +char* guac_ssh_ttymodes_to_array(guac_ssh_ttymodes *tty_modes) { /* Total data size should be number of tracked opcodes plus one final byte for the TTY_OP_END code. */ int data_size = (tty_modes->num_opcodes * 5) + 1; diff --git a/src/protocols/ssh/ttymode.h b/src/protocols/ssh/ttymode.h index 93f85bf1..ca5569d4 100644 --- a/src/protocols/ssh/ttymode.h +++ b/src/protocols/ssh/ttymode.h @@ -62,7 +62,7 @@ typedef struct guac_ssh_ttymodes { * with a null array of guac_ssh_ttymode and opcodes * set to zero. */ -guac_ssh_ttymodes init_ttymodes(); +guac_ssh_ttymodes guac_ssh_ttymodes_init(); /** * Add an item to the opcode array. This resizes the @@ -70,19 +70,19 @@ guac_ssh_ttymodes init_ttymodes(); * the specified opcode and value pair to the data * structure. */ -void add_ttymode(guac_ssh_ttymodes *tty_modes, char opcode, uint32_t value); +void guac_ssh_ttymodes_add(guac_ssh_ttymodes *tty_modes, char opcode, uint32_t value); /** * Retrieve the size, in bytes, of the ttymode_array * in the given guac_ssh_ttymodes data structure. */ -int sizeof_ttymodes(guac_ssh_ttymodes *tty_modes); +int guac_ssh_ttymodes_size(guac_ssh_ttymodes *tty_modes); /** * Convert the ttymodes data structure into a char * pointer array suitable for passing into the * libssh2_channel_request_pty_ex() function. */ -char* ttymodes_to_array(guac_ssh_ttymodes *tty_modes); +char* guac_ssh_ttymodes_to_array(guac_ssh_ttymodes *tty_modes); #endif