GUACAMOLE-1538: Only the core functionality of the terminal lib should be public.

This commit is contained in:
James Muehlner 2022-02-26 02:13:22 +00:00
parent ad0155b5f5
commit 46e813343e
35 changed files with 298 additions and 325 deletions

View File

@ -51,8 +51,7 @@ SHOW_INCLUDE_FILES = NO
CASE_SENSE_NAMES = YES CASE_SENSE_NAMES = YES
FILE_PATTERNS = *.h FILE_PATTERNS = *.h
STRIP_FROM_PATH = ../../src/terminal STRIP_FROM_PATH = ../../src/terminal
INPUT = ../../src/terminal/terminal/ INPUT = ../../src/terminal/terminal/terminal.h
EXCLUDE = ../../src/terminal/terminal/terminal_priv.h
JAVADOC_AUTOBRIEF = YES JAVADOC_AUTOBRIEF = YES
TAB_SIZE = 4 TAB_SIZE = 4
TYPEDEF_HIDES_STRUCT = YES TYPEDEF_HIDES_STRUCT = YES

View File

@ -27,6 +27,7 @@
#include <guacamole/user.h> #include <guacamole/user.h>
#include <pthread.h> #include <pthread.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -36,6 +36,8 @@
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/socket.h>
#include <guacamole/timestamp.h>
#include <guacamole/wol.h> #include <guacamole/wol.h>
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
@ -98,7 +100,7 @@ static guac_common_ssh_user* guac_ssh_get_user(guac_client* client) {
guac_client_log(client, GUAC_LOG_DEBUG, guac_client_log(client, GUAC_LOG_DEBUG,
"Initial import failed: %s", "Initial import failed: %s",
guac_common_ssh_key_error()); guac_common_ssh_key_error());
guac_client_log(client, GUAC_LOG_DEBUG, guac_client_log(client, GUAC_LOG_DEBUG,
"Re-attempting private key import (WITH passphrase)"); "Re-attempting private key import (WITH passphrase)");
@ -148,23 +150,23 @@ static guac_common_ssh_user* guac_ssh_get_user(guac_client* client) {
* A function used to generate a terminal prompt to gather additional * A function used to generate a terminal prompt to gather additional
* credentials from the guac_client during a connection, and using * credentials from the guac_client during a connection, and using
* the specified string to generate the prompt for the user. * the specified string to generate the prompt for the user.
* *
* @param client * @param client
* The guac_client object associated with the current connection * The guac_client object associated with the current connection
* where additional credentials are required. * where additional credentials are required.
* *
* @param cred_name * @param cred_name
* The prompt text to display to the screen when prompting for the * The prompt text to display to the screen when prompting for the
* additional credentials. * additional credentials.
* *
* @return * @return
* The string of credentials gathered from the user. * The string of credentials gathered from the user.
*/ */
static char* guac_ssh_get_credential(guac_client *client, char* cred_name) { static char* guac_ssh_get_credential(guac_client *client, char* cred_name) {
guac_ssh_client* ssh_client = (guac_ssh_client*) client->data; guac_ssh_client* ssh_client = (guac_ssh_client*) client->data;
return guac_terminal_prompt(ssh_client->term, cred_name, false); return guac_terminal_prompt(ssh_client->term, cred_name, false);
} }
void* ssh_input_thread(void* data) { void* ssh_input_thread(void* data) {
@ -206,17 +208,17 @@ void* ssh_client_thread(void* data) {
if (settings->wol_send_packet) { if (settings->wol_send_packet) {
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, " guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
"and pausing for %d seconds.", settings->wol_wait_time); "and pausing for %d seconds.", settings->wol_wait_time);
/* Send the Wake-on-LAN request. */ /* Send the Wake-on-LAN request. */
if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr, if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
settings->wol_udp_port)) settings->wol_udp_port))
return NULL; return NULL;
/* If wait time is specified, sleep for that amount of time. */ /* If wait time is specified, sleep for that amount of time. */
if (settings->wol_wait_time > 0) if (settings->wol_wait_time > 0)
guac_timestamp_msleep(settings->wol_wait_time * 1000); guac_timestamp_msleep(settings->wol_wait_time * 1000);
} }
/* Init SSH base libraries */ /* Init SSH base libraries */
if (guac_common_ssh_init(client)) { if (guac_common_ssh_init(client)) {
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
@ -360,7 +362,7 @@ void* ssh_client_thread(void* data) {
if (!settings->sftp_disable_upload) if (!settings->sftp_disable_upload)
guac_terminal_set_upload_path_handler(ssh_client->term, guac_terminal_set_upload_path_handler(ssh_client->term,
guac_sftp_set_upload_path); guac_sftp_set_upload_path);
if (!settings->sftp_disable_download) if (!settings->sftp_disable_download)
guac_terminal_set_file_download_handler(ssh_client->term, guac_terminal_set_file_download_handler(ssh_client->term,
guac_sftp_download_file); guac_sftp_download_file);

View File

@ -26,6 +26,7 @@
#include <guacamole/socket.h> #include <guacamole/socket.h>
#include <guacamole/user.h> #include <guacamole/user.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -30,6 +30,7 @@
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <guacamole/argv.h> #include <guacamole/argv.h>
#include <guacamole/client.h> #include <guacamole/client.h>

View File

@ -26,6 +26,7 @@
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/timestamp.h>
#include <guacamole/wol.h> #include <guacamole/wol.h>
#include <libtelnet.h> #include <libtelnet.h>
@ -559,17 +560,17 @@ void* guac_telnet_client_thread(void* data) {
pthread_t input_thread; pthread_t input_thread;
char buffer[8192]; char buffer[8192];
int wait_result; int wait_result;
/* If Wake-on-LAN is enabled, attempt to wake. */ /* If Wake-on-LAN is enabled, attempt to wake. */
if (settings->wol_send_packet) { if (settings->wol_send_packet) {
guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, " guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, "
"and pausing for %d seconds.", settings->wol_wait_time); "and pausing for %d seconds.", settings->wol_wait_time);
/* Send the Wake-on-LAN request. */ /* Send the Wake-on-LAN request. */
if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr, if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr,
settings->wol_udp_port)) settings->wol_udp_port))
return NULL; return NULL;
/* If wait time is specified, sleep for that amount of time. */ /* If wait time is specified, sleep for that amount of time. */
if (settings->wol_wait_time > 0) if (settings->wol_wait_time > 0)
guac_timestamp_msleep(settings->wol_wait_time * 1000); guac_timestamp_msleep(settings->wol_wait_time * 1000);

View File

@ -23,17 +23,14 @@
# to you by the ASF under the Apache License, Version 2.0, as described above. # to you by the ASF under the Apache License, Version 2.0, as described above.
# #
AUTOMAKE_OPTIONS = foreign AUTOMAKE_OPTIONS = foreign
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
lib_LTLIBRARIES = libguac-terminal.la lib_LTLIBRARIES = libguac-terminal.la
libguac_terminalincdir = $(includedir)/guacamole/terminal libguac_terminalincdir = $(includedir)/guacamole/terminal
noinst_HEADERS = \ noinst_HEADERS = \
terminal/terminal-priv.h
libguac_terminalinc_HEADERS = \
terminal/buffer.h \ terminal/buffer.h \
terminal/char-mappings.h \ terminal/char-mappings.h \
terminal/common.h \ terminal/common.h \
@ -43,12 +40,15 @@ libguac_terminalinc_HEADERS = \
terminal/palette.h \ terminal/palette.h \
terminal/scrollbar.h \ terminal/scrollbar.h \
terminal/select.h \ terminal/select.h \
terminal/terminal.h \ terminal/terminal-priv.h \
terminal/terminal-handlers.h \ terminal/terminal-handlers.h \
terminal/types.h \ terminal/types.h \
terminal/typescript.h \ terminal/typescript.h \
terminal/xparsecolor.h terminal/xparsecolor.h
libguac_terminalinc_HEADERS = \
terminal/terminal.h
libguac_terminal_la_SOURCES = \ libguac_terminal_la_SOURCES = \
buffer.c \ buffer.c \
char-mappings.c \ char-mappings.c \

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "terminal/buffer.h" #include "terminal/buffer.h"
#include "terminal/common.h" #include "terminal/common.h"

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
const int vt100_map[] = { const int vt100_map[] = {
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "terminal/color-scheme.h" #include "terminal/color-scheme.h"
#include "terminal/palette.h" #include "terminal/palette.h"

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "terminal/types.h" #include "terminal/types.h"
#include <stdbool.h> #include <stdbool.h>

View File

@ -17,12 +17,13 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "common/surface.h" #include "common/surface.h"
#include "terminal/common.h" #include "terminal/common.h"
#include "terminal/display.h" #include "terminal/display.h"
#include "terminal/palette.h" #include "terminal/palette.h"
#include "terminal/terminal.h"
#include "terminal/terminal-priv.h"
#include "terminal/types.h" #include "terminal/types.h"
#include <math.h> #include <math.h>

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "terminal/palette.h" #include "terminal/palette.h"
#include <ctype.h> #include <ctype.h>

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "terminal/palette.h" #include "terminal/palette.h"
const guac_terminal_color GUAC_TERMINAL_INITIAL_PALETTE[256] = { const guac_terminal_color GUAC_TERMINAL_INITIAL_PALETTE[256] = {

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "terminal/scrollbar.h" #include "terminal/scrollbar.h"
#include <guacamole/client.h> #include <guacamole/client.h>

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "common/clipboard.h" #include "common/clipboard.h"
#include "terminal/buffer.h" #include "terminal/buffer.h"

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "terminal/common.h" #include "terminal/common.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal-priv.h" #include "terminal/terminal-priv.h"

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "common/clipboard.h" #include "common/clipboard.h"
#include "common/cursor.h" #include "common/cursor.h"

View File

@ -28,7 +28,6 @@
*/ */
#include "config.h"
#include "types.h" #include "types.h"

View File

@ -27,7 +27,6 @@
* @file char-mappings.h * @file char-mappings.h
*/ */
#include "config.h"
/** /**
* VT100 graphics mapping. Each entry is the corresponding Unicode codepoint * VT100 graphics mapping. Each entry is the corresponding Unicode codepoint

View File

@ -17,8 +17,8 @@
* under the License. * under the License.
*/ */
#ifndef GUAC_TERMINAL_GET_COLOR_SCHEME_H #ifndef GUAC_TERMINAL_COLOR_SCHEME_H
#define GUAC_TERMINAL_GET_COLOR_SCHEME_H #define GUAC_TERMINAL_COLOR_SCHEME_H
/** /**
* Definitions and functions related to color scheme handling. * Definitions and functions related to color scheme handling.
@ -26,9 +26,8 @@
* @file color-scheme.h * @file color-scheme.h
*/ */
#include "config.h"
#include "terminal/palette.h" #include "palette.h"
#include <guacamole/client.h> #include <guacamole/client.h>

View File

@ -27,7 +27,6 @@
* @file common.h * @file common.h
*/ */
#include "config.h"
#include "types.h" #include "types.h"
#include <stdbool.h> #include <stdbool.h>

View File

@ -27,7 +27,6 @@
* @file display.h * @file display.h
*/ */
#include "config.h"
#include "common/surface.h" #include "common/surface.h"
#include "palette.h" #include "palette.h"

View File

@ -26,8 +26,7 @@
* @file named-colors.h * @file named-colors.h
*/ */
#include "config.h" #include "palette.h"
#include "terminal/palette.h"
/** /**
* Searches for the color having the given name, storing that color within the * Searches for the color having the given name, storing that color within the

View File

@ -26,7 +26,6 @@
* @file palette.h * @file palette.h
*/ */
#include "config.h"
#include <stdint.h> #include <stdint.h>

View File

@ -26,7 +26,6 @@
* @file scrollbar.h * @file scrollbar.h
*/ */
#include "config.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/layer.h> #include <guacamole/layer.h>

View File

@ -27,7 +27,6 @@
* @file select.h * @file select.h
*/ */
#include "config.h"
#include "terminal.h" #include "terminal.h"
#include <stdbool.h> #include <stdbool.h>

View File

@ -29,6 +29,7 @@
#include "config.h" #include "config.h"
#include "display.h"
#include "terminal.h" #include "terminal.h"
/** /**

View File

@ -22,7 +22,12 @@
#define GUAC_TERMINAL_PRIV_H #define GUAC_TERMINAL_PRIV_H
#include "common/clipboard.h" #include "common/clipboard.h"
#include "terminal/terminal.h" #include "common/cursor.h"
#include "buffer.h"
#include "display.h"
#include "scrollbar.h"
#include "terminal.h"
#include "typescript.h"
struct guac_terminal { struct guac_terminal {
@ -442,5 +447,194 @@ struct guac_terminal {
}; };
/**
* Handles a scroll event received from the scrollbar associated with a
* terminal.
*
* @param scrollbar
* The scrollbar that has been scrolled.
*
* @param value
* The new value that should be stored within the scrollbar, and
* represented within the terminal display.
*/
void guac_terminal_scroll_handler(guac_terminal_scrollbar* scrollbar, int value);
/**
* Sets the given range of columns within the given row to the given
* character.
*/
void guac_terminal_set_columns(guac_terminal* terminal, int row,
int start_column, int end_column, guac_terminal_char* character);
/**
* Acquires exclusive access to the terminal. Note that enforcing this
* exclusive access requires that ALL users of the terminal call this
* function before making further calls to the terminal.
*/
void guac_terminal_lock(guac_terminal* terminal);
/**
* Releases exclusive access to the terminal.
*/
void guac_terminal_unlock(guac_terminal* terminal);
/**
* Resets the state of the given terminal, as if it were just allocated.
*/
void guac_terminal_reset(guac_terminal* term);
/**
* Sets the character at the given row and column to the specified value.
*/
int guac_terminal_set(guac_terminal* term, int row, int col, int codepoint);
/**
* Clears the given region within a single row.
*/
int guac_terminal_clear_columns(guac_terminal* term,
int row, int start_col, int end_col);
/**
* Clears the given region from right-to-left, top-to-bottom, replacing
* all characters with the current background color and attributes.
*/
int guac_terminal_clear_range(guac_terminal* term,
int start_row, int start_col,
int end_row, int end_col);
/**
* Scrolls the terminal's current scroll region up by one row.
*/
int guac_terminal_scroll_up(guac_terminal* term,
int start_row, int end_row, int amount);
/**
* Scrolls the terminal's current scroll region down by one row.
*/
int guac_terminal_scroll_down(guac_terminal* term,
int start_row, int end_row, int amount);
/**
* Commits the current cursor location, updating the visible cursor
* on the screen.
*/
void guac_terminal_commit_cursor(guac_terminal* term);
/**
* Scroll down the display by the given amount, replacing the new space with
* data from the buffer. If not enough data is available, the maximum
* amount will be scrolled.
*/
void guac_terminal_scroll_display_down(guac_terminal* terminal, int amount);
/**
* Scroll up the display by the given amount, replacing the new space with data
* from either the buffer or the terminal buffer. If not enough data is
* available, the maximum amount will be scrolled.
*/
void guac_terminal_scroll_display_up(guac_terminal* terminal, int amount);
/**
* Opens a new pipe stream, redirecting all output from the given terminal to
* that pipe stream. If a pipe stream is already open, that pipe stream will
* be flushed and closed prior to opening the new pipe stream.
*
* @param term
* The terminal which should redirect output to a new pipe stream having
* the given name.
*
* @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.
*
* @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT
* @see GUAC_TERMINAL_PIPE_AUTOFLUSH
*/
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
* associated with the given terminal. The pipe stream must already have been
* opened via guac_terminal_pipe_stream_open(). If no pipe stream is currently
* open, this function has no effect. Data written through this function may
* be buffered.
*
* @param term
* The terminal whose currently-open pipe stream should be written to.
*
* @param c
* The byte of data to write to the pipe stream.
*/
void guac_terminal_pipe_stream_write(guac_terminal* term, char c);
/**
* Flushes any data currently buffered for the currently-open pipe stream
* associated with the given terminal. The pipe stream must already have been
* opened via guac_terminal_pipe_stream_open(). If no pipe stream is currently
* open or no data is in the buffer, this function has no effect.
*
* @param term
* The terminal whose pipe stream buffer should be flushed.
*/
void guac_terminal_pipe_stream_flush(guac_terminal* term);
/**
* Closes the currently-open pipe stream associated with the given terminal,
* redirecting all output back to the terminal display. Any data currently
* buffered for output to the pipe stream will be flushed prior to closure. The
* pipe stream must already have been opened via
* guac_terminal_pipe_stream_open(). If no pipe stream is currently open, this
* function has no effect.
*
* @param term
* The terminal whose currently-open pipe stream should be closed.
*/
void guac_terminal_pipe_stream_close(guac_terminal* term);
/**
* Sets a tabstop in the given column.
*/
void guac_terminal_set_tab(guac_terminal* term, int column);
/**
* Removes the tabstop at the given column.
*/
void guac_terminal_unset_tab(guac_terminal* term, int column);
/**
* Removes all tabstops.
*/
void guac_terminal_clear_tabs(guac_terminal* term);
/**
* Given a column within the given terminal, returns the location of the
* next tabstop (or the rightmost character, if no more tabstops exist).
*/
int guac_terminal_next_tab(guac_terminal* term, int column);
/**
* Copies the given range of columns to a new location, offset from
* the original by the given number of columns.
*/
void guac_terminal_copy_columns(guac_terminal* terminal, int row,
int start_column, int end_column, int offset);
/**
* Copies the given range of rows to a new location, offset from the
* original by the given number of rows.
*/
void guac_terminal_copy_rows(guac_terminal* terminal,
int start_row, int end_row, int offset);
/**
* Flushes all pending operations within the given guac_terminal.
*/
void guac_terminal_flush(guac_terminal* terminal);
#endif #endif

View File

@ -28,15 +28,6 @@
* @file terminal.h * @file terminal.h
*/ */
#include "config.h"
#include "buffer.h"
#include "common/cursor.h"
#include "display.h"
#include "scrollbar.h"
#include "types.h"
#include "typescript.h"
#include <pthread.h> #include <pthread.h>
#include <stdbool.h> #include <stdbool.h>
@ -453,6 +444,52 @@ int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed);
int guac_terminal_send_mouse(guac_terminal* term, guac_user* user, int guac_terminal_send_mouse(guac_terminal* term, guac_user* user,
int x, int y, int mask); int x, int y, int mask);
/**
* Sends the given string as if typed by the user. If terminal input is
* currently coming from a stream due to a prior call to
* guac_terminal_send_stream(), any input which would normally result from
* invoking this function is dropped.
*
* @param term
* The terminal which should receive the given data on STDIN.
*
* @param data
* The data the terminal should receive on STDIN.
*
* @param length
* The size of the given data, in bytes.
*
* @return
* The number of bytes written to STDIN, or a negative value if an error
* occurs preventing the data from being written. This should always be
* the size of the data given unless data is intentionally dropped.
*/
int guac_terminal_send_data(guac_terminal* term, const char* data, int length);
/**
* Sends the given string as if typed by the user. If terminal input is
* currently coming from a stream due to a prior call to
* guac_terminal_send_stream(), any input which would normally result from
* invoking this function is dropped.
*
* @param term
* The terminal which should receive the given data on STDIN.
*
* @param data
* The data the terminal should receive on STDIN.
*
* @return
* The number of bytes written to STDIN, or a negative value if an error
* occurs preventing the data from being written. This should always be
* the size of the data given unless data is intentionally dropped.
*/
int guac_terminal_send_string(guac_terminal* term, const char* data);
/**
* Writes the given string of characters to the terminal.
*/
int guac_terminal_write(guac_terminal* term, const char* c, int size);
/** /**
* Initializes the handlers of the given guac_stream such that it serves as the * Initializes the handlers of the given guac_stream such that it serves as the
* source of input to the terminal. Other input sources will be temporarily * source of input to the terminal. Other input sources will be temporarily
@ -482,17 +519,27 @@ int guac_terminal_send_stream(guac_terminal* term, guac_user* user,
guac_stream* stream); guac_stream* stream);
/** /**
* Handles a scroll event received from the scrollbar associated with a * Sends data through STDIN as if typed by the user, using the format string
* terminal. * given and any args (similar to printf). If terminal input is currently
* coming from a stream due to a prior call to guac_terminal_send_stream(), any
* input which would normally result from invoking this function is dropped.
* *
* @param scrollbar * @param term
* The scrollbar that has been scrolled. * The terminal which should receive the given data on STDIN.
* *
* @param value * @param format
* The new value that should be stored within the scrollbar, and * A printf-style format string describing the data to be received on
* represented within the terminal display. * STDIN.
*
* @param ...
* Any srguments to use when filling the format string.
*
* @return
* The number of bytes written to STDIN, or a negative value if an error
* occurs preventing the data from being written. This should always be
* the size of the data given unless data is intentionally dropped.
*/ */
void guac_terminal_scroll_handler(guac_terminal_scrollbar* scrollbar, int value); int guac_terminal_sendf(guac_terminal* term, const char* format, ...);
/** /**
* Replicates the current display state to a user that has just joined the * Replicates the current display state to a user that has just joined the
@ -512,6 +559,11 @@ void guac_terminal_scroll_handler(guac_terminal_scrollbar* scrollbar, int value)
void guac_terminal_dup(guac_terminal* term, guac_user* user, void guac_terminal_dup(guac_terminal* term, guac_user* user,
guac_socket* socket); guac_socket* socket);
/**
* Resize the terminal to the given dimensions.
*/
int guac_terminal_resize(guac_terminal* term, int width, int height);
/** /**
* Returns the number of rows within the buffer of the given terminal which are * Returns the number of rows within the buffer of the given terminal which are
* not currently displayed on screen. Adjustments to the desired scrollback * not currently displayed on screen. Adjustments to the desired scrollback
@ -588,262 +640,6 @@ void guac_terminal_clipboard_append(guac_terminal* terminal,
*/ */
void guac_terminal_remove_user(guac_terminal* terminal, guac_user* user); void guac_terminal_remove_user(guac_terminal* terminal, guac_user* user);
/* INTERNAL FUNCTIONS */
/**
* Acquires exclusive access to the terminal. Note that enforcing this
* exclusive access requires that ALL users of the terminal call this
* function before making further calls to the terminal.
*/
void guac_terminal_lock(guac_terminal* terminal);
/**
* Releases exclusive access to the terminal.
*/
void guac_terminal_unlock(guac_terminal* terminal);
/**
* Resets the state of the given terminal, as if it were just allocated.
*/
void guac_terminal_reset(guac_terminal* term);
/**
* Writes the given string of characters to the terminal.
*/
int guac_terminal_write(guac_terminal* term, const char* c, int size);
/**
* Sets the character at the given row and column to the specified value.
*/
int guac_terminal_set(guac_terminal* term, int row, int col, int codepoint);
/**
* Clears the given region within a single row.
*/
int guac_terminal_clear_columns(guac_terminal* term,
int row, int start_col, int end_col);
/**
* Clears the given region from right-to-left, top-to-bottom, replacing
* all characters with the current background color and attributes.
*/
int guac_terminal_clear_range(guac_terminal* term,
int start_row, int start_col,
int end_row, int end_col);
/**
* Scrolls the terminal's current scroll region up by one row.
*/
int guac_terminal_scroll_up(guac_terminal* term,
int start_row, int end_row, int amount);
/**
* Scrolls the terminal's current scroll region down by one row.
*/
int guac_terminal_scroll_down(guac_terminal* term,
int start_row, int end_row, int amount);
/**
* Commits the current cursor location, updating the visible cursor
* on the screen.
*/
void guac_terminal_commit_cursor(guac_terminal* term);
/**
* Scroll down the display by the given amount, replacing the new space with
* data from the buffer. If not enough data is available, the maximum
* amount will be scrolled.
*/
void guac_terminal_scroll_display_down(guac_terminal* terminal, int amount);
/**
* Scroll up the display by the given amount, replacing the new space with data
* from either the buffer or the terminal buffer. If not enough data is
* available, the maximum amount will be scrolled.
*/
void guac_terminal_scroll_display_up(guac_terminal* terminal, int amount);
/* LOW-LEVEL TERMINAL OPERATIONS */
/**
* Copies the given range of columns to a new location, offset from
* the original by the given number of columns.
*/
void guac_terminal_copy_columns(guac_terminal* terminal, int row,
int start_column, int end_column, int offset);
/**
* Copies the given range of rows to a new location, offset from the
* original by the given number of rows.
*/
void guac_terminal_copy_rows(guac_terminal* terminal,
int start_row, int end_row, int offset);
/**
* Sets the given range of columns within the given row to the given
* character.
*/
void guac_terminal_set_columns(guac_terminal* terminal, int row,
int start_column, int end_column, guac_terminal_char* character);
/**
* Resize the terminal to the given dimensions.
*/
int guac_terminal_resize(guac_terminal* term, int width, int height);
/**
* Flushes all pending operations within the given guac_terminal.
*/
void guac_terminal_flush(guac_terminal* terminal);
/**
* Sends the given string as if typed by the user. If terminal input is
* currently coming from a stream due to a prior call to
* guac_terminal_send_stream(), any input which would normally result from
* invoking this function is dropped.
*
* @param term
* The terminal which should receive the given data on STDIN.
*
* @param data
* The data the terminal should receive on STDIN.
*
* @param length
* The size of the given data, in bytes.
*
* @return
* The number of bytes written to STDIN, or a negative value if an error
* occurs preventing the data from being written. This should always be
* the size of the data given unless data is intentionally dropped.
*/
int guac_terminal_send_data(guac_terminal* term, const char* data, int length);
/**
* Sends the given string as if typed by the user. If terminal input is
* currently coming from a stream due to a prior call to
* guac_terminal_send_stream(), any input which would normally result from
* invoking this function is dropped.
*
* @param term
* The terminal which should receive the given data on STDIN.
*
* @param data
* The data the terminal should receive on STDIN.
*
* @return
* The number of bytes written to STDIN, or a negative value if an error
* occurs preventing the data from being written. This should always be
* the size of the data given unless data is intentionally dropped.
*/
int guac_terminal_send_string(guac_terminal* term, const char* data);
/**
* Sends data through STDIN as if typed by the user, using the format string
* given and any args (similar to printf). If terminal input is currently
* coming from a stream due to a prior call to guac_terminal_send_stream(), any
* input which would normally result from invoking this function is dropped.
*
* @param term
* The terminal which should receive the given data on STDIN.
*
* @param format
* A printf-style format string describing the data to be received on
* STDIN.
*
* @param ...
* Any srguments to use when filling the format string.
*
* @return
* The number of bytes written to STDIN, or a negative value if an error
* occurs preventing the data from being written. This should always be
* the size of the data given unless data is intentionally dropped.
*/
int guac_terminal_sendf(guac_terminal* term, const char* format, ...);
/**
* Sets a tabstop in the given column.
*/
void guac_terminal_set_tab(guac_terminal* term, int column);
/**
* Removes the tabstop at the given column.
*/
void guac_terminal_unset_tab(guac_terminal* term, int column);
/**
* Removes all tabstops.
*/
void guac_terminal_clear_tabs(guac_terminal* term);
/**
* Given a column within the given terminal, returns the location of the
* next tabstop (or the rightmost character, if no more tabstops exist).
*/
int guac_terminal_next_tab(guac_terminal* term, int column);
/**
* Opens a new pipe stream, redirecting all output from the given terminal to
* that pipe stream. If a pipe stream is already open, that pipe stream will
* be flushed and closed prior to opening the new pipe stream.
*
* @param term
* The terminal which should redirect output to a new pipe stream having
* the given name.
*
* @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.
*
* @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT
* @see GUAC_TERMINAL_PIPE_AUTOFLUSH
*/
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
* associated with the given terminal. The pipe stream must already have been
* opened via guac_terminal_pipe_stream_open(). If no pipe stream is currently
* open, this function has no effect. Data written through this function may
* be buffered.
*
* @param term
* The terminal whose currently-open pipe stream should be written to.
*
* @param c
* The byte of data to write to the pipe stream.
*/
void guac_terminal_pipe_stream_write(guac_terminal* term, char c);
/**
* Flushes any data currently buffered for the currently-open pipe stream
* associated with the given terminal. The pipe stream must already have been
* opened via guac_terminal_pipe_stream_open(). If no pipe stream is currently
* open or no data is in the buffer, this function has no effect.
*
* @param term
* The terminal whose pipe stream buffer should be flushed.
*/
void guac_terminal_pipe_stream_flush(guac_terminal* term);
/**
* Closes the currently-open pipe stream associated with the given terminal,
* redirecting all output back to the terminal display. Any data currently
* buffered for output to the pipe stream will be flushed prior to closure. The
* pipe stream must already have been opened via
* guac_terminal_pipe_stream_open(). If no pipe stream is currently open, this
* function has no effect.
*
* @param term
* The terminal whose currently-open pipe stream should be closed.
*/
void guac_terminal_pipe_stream_close(guac_terminal* term);
/** /**
* Requests that the terminal write all output to a new pair of typescript * Requests that the terminal write all output to a new pair of typescript
* files within the given path and using the given base name. Terminal output * files within the given path and using the given base name. Terminal output

View File

@ -28,7 +28,6 @@
* @file types.h * @file types.h
*/ */
#include "config.h"
#include "palette.h" #include "palette.h"
#include <stdbool.h> #include <stdbool.h>

View File

@ -28,7 +28,6 @@
* @file typescript.h * @file typescript.h
*/ */
#include "config.h"
#include <guacamole/timestamp.h> #include <guacamole/timestamp.h>

View File

@ -26,9 +26,8 @@
* @file xparsecolor.h * @file xparsecolor.h
*/ */
#include "config.h"
#include "terminal/palette.h" #include "palette.h"
/** /**
* Parses an X11 color spec, as defined by Xlib's XParseColor(), storing the * Parses an X11 color spec, as defined by Xlib's XParseColor(), storing the

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "common/io.h" #include "common/io.h"
#include "terminal/typescript.h" #include "terminal/typescript.h"

View File

@ -17,7 +17,6 @@
* under the License. * under the License.
*/ */
#include "config.h"
#include "terminal/named-colors.h" #include "terminal/named-colors.h"
#include "terminal/palette.h" #include "terminal/palette.h"