Github user mike-jumper commented on a diff in the pull request:
https://github.com/apache/guacamole-server/pull/132#discussion_r161150916
--- Diff: src/terminal/terminal.c ---
@@ -255,52 +257,203 @@ void* guac_terminal_thread(void* data) {
}
-guac_terminal* guac_terminal_create(guac_client* client,
- const char* font_name, int font_size, int dpi,
- int width, int height, const char* color_scheme) {
+/**
+ * Compare a non-null-terminated string spanning token_start to token_end,
with
+ * a null-terminating string at literal.
+ */
+static int guac_terminal_color_scheme_compare_token(const char*
token_start,
+ const char* token_end, const char* literal) {
- int default_foreground;
- int default_background;
+ const int result = strncmp(literal, token_start, token_end -
token_start);
+ if (result != 0)
+ return result;
- /* Default to "gray-black" color scheme if no scheme provided */
- if (color_scheme == NULL || color_scheme[0] == '\0') {
- default_foreground = GUAC_TERMINAL_COLOR_GRAY;
- default_background = GUAC_TERMINAL_COLOR_BLACK;
- }
+ /* At this point, literal is same length or longer than
+ * | token_end - token_start |, so if the two are equal, literal should
+ * have its null-terminator at | token_end - token_start |. */
+ return (int) (unsigned char) literal[token_end - token_start];
+}
- /* Otherwise, parse color scheme */
- else if (strcmp(color_scheme, GUAC_TERMINAL_SCHEME_GRAY_BLACK) == 0) {
- default_foreground = GUAC_TERMINAL_COLOR_GRAY;
- default_background = GUAC_TERMINAL_COLOR_BLACK;
- }
- else if (strcmp(color_scheme, GUAC_TERMINAL_SCHEME_BLACK_WHITE) == 0) {
- default_foreground = GUAC_TERMINAL_COLOR_BLACK;
- default_background = GUAC_TERMINAL_COLOR_WHITE;
- }
- else if (strcmp(color_scheme, GUAC_TERMINAL_SCHEME_GREEN_BLACK) == 0) {
- default_foreground = GUAC_TERMINAL_COLOR_DARK_GREEN;
- default_background = GUAC_TERMINAL_COLOR_BLACK;
- }
- else if (strcmp(color_scheme, GUAC_TERMINAL_SCHEME_WHITE_BLACK) == 0) {
- default_foreground = GUAC_TERMINAL_COLOR_WHITE;
- default_background = GUAC_TERMINAL_COLOR_BLACK;
- }
+/**
+ * Parse a color-scheme configuration string, and return specified
+ * foreground/background colors and color palette.
+ *
+ * @param client
+ *
+ * @param color_scheme
+ * A semicolon-separated list of name-value pairs, i.e.
+ * "<name>: <value> [; <name>: <value> [; ...]]".
+ * For example, "color2: rgb:cc/33/22; background: color5".
--- End diff --
Is the idea behind this format to model the resource names used by xterm?
---