GUACAMOLE-269: Name functions per Guacamole standards.

This commit is contained in:
Nick Couchman 2018-02-27 09:23:30 -05:00
parent 9bd28321e5
commit c286668b79
3 changed files with 13 additions and 12 deletions

View File

@ -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;
}

View File

@ -23,7 +23,7 @@
#include <stdlib.h>
#include <string.h>
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;

View File

@ -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