ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
enums.h File Reference

Option enum value definitions - single source of truth. More...

Go to the source code of this file.

Data Structures

struct  enum_to_string_entry_t
 Enum value mapping with description for shell completions. More...
struct  enum_descriptor_t
 Enum value mapping for an option. More...

Macros

#define OPT_VALUE_AUTO   "auto"
#define OPT_VALUE_TRUE   "true"
#define OPT_VALUE_FALSE   "false"
#define OPT_COMPLETION_SHELL_BASH   "bash"
#define OPT_COMPLETION_SHELL_FISH   "fish"
#define OPT_COMPLETION_SHELL_ZSH   "zsh"
#define OPT_COMPLETION_SHELL_POWERSHELL   "powershell"
#define OPT_RENDER_THEME_DARK   "dark"
#define OPT_RENDER_THEME_LIGHT   "light"
#define OPT_RENDER_THEME_AUTO   OPT_VALUE_AUTO
#define OPT_LOG_LEVEL_DEV   "dev"
#define OPT_LOG_LEVEL_DEBUG   "debug"
#define OPT_LOG_LEVEL_INFO   "info"
#define OPT_LOG_LEVEL_WARN   "warn"
#define OPT_LOG_LEVEL_ERROR   "error"
#define OPT_LOG_LEVEL_FATAL   "fatal"
#define OPT_COLOR_MODE_AUTO   "auto"
#define OPT_COLOR_MODE_NONE   "none"
#define OPT_COLOR_MODE_MONO   "mono"
#define OPT_COLOR_MODE_16   "16"
#define OPT_COLOR_MODE_256   "256"
#define OPT_COLOR_MODE_TRUECOLOR   "truecolor"
#define OPT_COLOR_FILTER_NONE   "none"
#define OPT_COLOR_FILTER_BLACK   "black"
#define OPT_COLOR_FILTER_WHITE   "white"
#define OPT_COLOR_FILTER_GREEN   "green"
#define OPT_COLOR_FILTER_MAGENTA   "magenta"
#define OPT_COLOR_FILTER_FUCHSIA   "fuchsia"
#define OPT_COLOR_FILTER_ORANGE   "orange"
#define OPT_COLOR_FILTER_TEAL   "teal"
#define OPT_COLOR_FILTER_CYAN   "cyan"
#define OPT_COLOR_FILTER_PINK   "pink"
#define OPT_COLOR_FILTER_RED   "red"
#define OPT_COLOR_FILTER_YELLOW   "yellow"
#define OPT_COLOR_FILTER_RAINBOW   "rainbow"
#define OPT_PALETTE_STANDARD   "standard"
#define OPT_PALETTE_BLOCKS   "blocks"
#define OPT_PALETTE_DIGITAL   "digital"
#define OPT_PALETTE_MINIMAL   "minimal"
#define OPT_PALETTE_COOL   "cool"
#define OPT_PALETTE_CUSTOM   "custom"
#define OPT_RENDER_MODE_FOREGROUND   "foreground"
#define OPT_RENDER_MODE_FG   "fg"
#define OPT_RENDER_MODE_BACKGROUND   "background"
#define OPT_RENDER_MODE_BG   "bg"
#define OPT_RENDER_MODE_HALF_BLOCK   "half-block"
#define OPT_RECONNECT_OFF   "off"
#define OPT_RECONNECT_AUTO   "auto"
#define OPT_AUDIO_SOURCE_ALL   "all"
#define OPT_AUDIO_SOURCE_CALL   "call"
#define OPT_AUDIO_SOURCE_MIC   "mic"
#define OPT_AUDIO_SOURCE_MEDIA   "media"
#define OPT_AUDIO_SOURCE_AUTO   "auto"
#define OPT_AUDIO_CAPTURE_SOURCE_AUTO   "auto"
#define OPT_AUDIO_CAPTURE_SOURCE_MIC   "mic"
#define OPT_AUDIO_CAPTURE_SOURCE_MEDIA   "media"
#define OPT_AUDIO_CAPTURE_SOURCE_BOTH   "both"
#define OPT_AUDIO_CAPTURE_SOURCE_REMOTE   "remote"

Functions

const enum_to_string_entry_t * options_get_enum_entries (const char *option_name, size_t *entry_count)
 Get enum entries with descriptions for an option.
const char ** options_get_enum_values (const char *option_name, size_t *value_count)
 Get enum values for an option.
bool options_is_enum_option (const char *option_name)
 Check if an option has enum values.

Detailed Description

Option enum value definitions - single source of truth.

Defines all enum values for options in one place so they can be used by:

  • Option parsers
  • Help text generation
  • Shell completions (bash/fish/zsh/powershell)
  • Configuration file validation

This ensures consistency across all parts of the application.

Definition in file enums.h.

Macro Definition Documentation

◆ OPT_AUDIO_CAPTURE_SOURCE_AUTO

#define OPT_AUDIO_CAPTURE_SOURCE_AUTO   "auto"

Definition at line 146 of file enums.h.

Referenced by parse_audio_capture_source().

◆ OPT_AUDIO_CAPTURE_SOURCE_BOTH

#define OPT_AUDIO_CAPTURE_SOURCE_BOTH   "both"

Definition at line 149 of file enums.h.

Referenced by parse_audio_capture_source().

◆ OPT_AUDIO_CAPTURE_SOURCE_MEDIA

#define OPT_AUDIO_CAPTURE_SOURCE_MEDIA   "media"

Definition at line 148 of file enums.h.

Referenced by parse_audio_capture_source().

◆ OPT_AUDIO_CAPTURE_SOURCE_MIC

#define OPT_AUDIO_CAPTURE_SOURCE_MIC   "mic"

Definition at line 147 of file enums.h.

Referenced by parse_audio_capture_source().

◆ OPT_AUDIO_CAPTURE_SOURCE_REMOTE

#define OPT_AUDIO_CAPTURE_SOURCE_REMOTE   "remote"

Definition at line 150 of file enums.h.

Referenced by parse_audio_capture_source().

◆ OPT_AUDIO_SOURCE_ALL

#define OPT_AUDIO_SOURCE_ALL   "all"

Definition at line 139 of file enums.h.

Referenced by parse_audio_source().

◆ OPT_AUDIO_SOURCE_AUTO

#define OPT_AUDIO_SOURCE_AUTO   "auto"

Definition at line 143 of file enums.h.

Referenced by parse_audio_source().

◆ OPT_AUDIO_SOURCE_CALL

#define OPT_AUDIO_SOURCE_CALL   "call"

Definition at line 140 of file enums.h.

Referenced by parse_audio_source().

◆ OPT_AUDIO_SOURCE_MEDIA

#define OPT_AUDIO_SOURCE_MEDIA   "media"

Definition at line 142 of file enums.h.

Referenced by parse_audio_source().

◆ OPT_AUDIO_SOURCE_MIC

#define OPT_AUDIO_SOURCE_MIC   "mic"

Definition at line 141 of file enums.h.

Referenced by parse_audio_source().

◆ OPT_COLOR_FILTER_BLACK

#define OPT_COLOR_FILTER_BLACK   "black"

Definition at line 106 of file enums.h.

◆ OPT_COLOR_FILTER_CYAN

#define OPT_COLOR_FILTER_CYAN   "cyan"

Definition at line 113 of file enums.h.

◆ OPT_COLOR_FILTER_FUCHSIA

#define OPT_COLOR_FILTER_FUCHSIA   "fuchsia"

Definition at line 110 of file enums.h.

◆ OPT_COLOR_FILTER_GREEN

#define OPT_COLOR_FILTER_GREEN   "green"

Definition at line 108 of file enums.h.

◆ OPT_COLOR_FILTER_MAGENTA

#define OPT_COLOR_FILTER_MAGENTA   "magenta"

Definition at line 109 of file enums.h.

◆ OPT_COLOR_FILTER_NONE

#define OPT_COLOR_FILTER_NONE   "none"

Definition at line 105 of file enums.h.

Referenced by parse_color_filter().

◆ OPT_COLOR_FILTER_ORANGE

#define OPT_COLOR_FILTER_ORANGE   "orange"

Definition at line 111 of file enums.h.

◆ OPT_COLOR_FILTER_PINK

#define OPT_COLOR_FILTER_PINK   "pink"

Definition at line 114 of file enums.h.

◆ OPT_COLOR_FILTER_RAINBOW

#define OPT_COLOR_FILTER_RAINBOW   "rainbow"

Definition at line 117 of file enums.h.

◆ OPT_COLOR_FILTER_RED

#define OPT_COLOR_FILTER_RED   "red"

Definition at line 115 of file enums.h.

◆ OPT_COLOR_FILTER_TEAL

#define OPT_COLOR_FILTER_TEAL   "teal"

Definition at line 112 of file enums.h.

◆ OPT_COLOR_FILTER_WHITE

#define OPT_COLOR_FILTER_WHITE   "white"

Definition at line 107 of file enums.h.

◆ OPT_COLOR_FILTER_YELLOW

#define OPT_COLOR_FILTER_YELLOW   "yellow"

Definition at line 116 of file enums.h.

◆ OPT_COLOR_MODE_16

#define OPT_COLOR_MODE_16   "16"

◆ OPT_COLOR_MODE_256

#define OPT_COLOR_MODE_256   "256"

◆ OPT_COLOR_MODE_AUTO

#define OPT_COLOR_MODE_AUTO   "auto"

Definition at line 97 of file enums.h.

Referenced by color_mode_to_string(), and parse_color_mode().

◆ OPT_COLOR_MODE_MONO

#define OPT_COLOR_MODE_MONO   "mono"

Definition at line 99 of file enums.h.

Referenced by parse_color_mode(), parse_color_mode_option(), and validate_opt_color_mode().

◆ OPT_COLOR_MODE_NONE

#define OPT_COLOR_MODE_NONE   "none"

◆ OPT_COLOR_MODE_TRUECOLOR

#define OPT_COLOR_MODE_TRUECOLOR   "truecolor"

◆ OPT_COMPLETION_SHELL_BASH

#define OPT_COMPLETION_SHELL_BASH   "bash"

Definition at line 80 of file enums.h.

Referenced by completions_get_shell_name(), and completions_parse_shell_name().

◆ OPT_COMPLETION_SHELL_FISH

#define OPT_COMPLETION_SHELL_FISH   "fish"

Definition at line 81 of file enums.h.

Referenced by completions_get_shell_name(), and completions_parse_shell_name().

◆ OPT_COMPLETION_SHELL_POWERSHELL

#define OPT_COMPLETION_SHELL_POWERSHELL   "powershell"

Definition at line 83 of file enums.h.

Referenced by completions_get_shell_name(), and completions_parse_shell_name().

◆ OPT_COMPLETION_SHELL_ZSH

#define OPT_COMPLETION_SHELL_ZSH   "zsh"

Definition at line 82 of file enums.h.

Referenced by completions_get_shell_name(), and completions_parse_shell_name().

◆ OPT_LOG_LEVEL_DEBUG

#define OPT_LOG_LEVEL_DEBUG   "debug"

Definition at line 90 of file enums.h.

Referenced by parse_log_level(), and validate_opt_log_level().

◆ OPT_LOG_LEVEL_DEV

#define OPT_LOG_LEVEL_DEV   "dev"

Definition at line 89 of file enums.h.

Referenced by parse_log_level(), and validate_opt_log_level().

◆ OPT_LOG_LEVEL_ERROR

#define OPT_LOG_LEVEL_ERROR   "error"

Definition at line 93 of file enums.h.

Referenced by parse_log_level(), and validate_opt_log_level().

◆ OPT_LOG_LEVEL_FATAL

#define OPT_LOG_LEVEL_FATAL   "fatal"

Definition at line 94 of file enums.h.

Referenced by parse_log_level(), and validate_opt_log_level().

◆ OPT_LOG_LEVEL_INFO

#define OPT_LOG_LEVEL_INFO   "info"

Definition at line 91 of file enums.h.

Referenced by parse_log_level(), and validate_opt_log_level().

◆ OPT_LOG_LEVEL_WARN

#define OPT_LOG_LEVEL_WARN   "warn"

Definition at line 92 of file enums.h.

Referenced by parse_log_level(), and validate_opt_log_level().

◆ OPT_PALETTE_BLOCKS

#define OPT_PALETTE_BLOCKS   "blocks"

◆ OPT_PALETTE_COOL

#define OPT_PALETTE_COOL   "cool"

◆ OPT_PALETTE_CUSTOM

#define OPT_PALETTE_CUSTOM   "custom"

◆ OPT_PALETTE_DIGITAL

#define OPT_PALETTE_DIGITAL   "digital"

◆ OPT_PALETTE_MINIMAL

#define OPT_PALETTE_MINIMAL   "minimal"

◆ OPT_PALETTE_STANDARD

#define OPT_PALETTE_STANDARD   "standard"

◆ OPT_RECONNECT_AUTO

#define OPT_RECONNECT_AUTO   "auto"

Definition at line 136 of file enums.h.

◆ OPT_RECONNECT_OFF

#define OPT_RECONNECT_OFF   "off"

Definition at line 135 of file enums.h.

◆ OPT_RENDER_MODE_BACKGROUND

#define OPT_RENDER_MODE_BACKGROUND   "background"

◆ OPT_RENDER_MODE_BG

#define OPT_RENDER_MODE_BG   "bg"

Definition at line 131 of file enums.h.

Referenced by parse_render_mode(), parse_render_mode_option(), and validate_opt_render_mode().

◆ OPT_RENDER_MODE_FG

#define OPT_RENDER_MODE_FG   "fg"

Definition at line 129 of file enums.h.

Referenced by parse_render_mode(), parse_render_mode_option(), and validate_opt_render_mode().

◆ OPT_RENDER_MODE_FOREGROUND

#define OPT_RENDER_MODE_FOREGROUND   "foreground"

◆ OPT_RENDER_MODE_HALF_BLOCK

#define OPT_RENDER_MODE_HALF_BLOCK   "half-block"

◆ OPT_RENDER_THEME_AUTO

#define OPT_RENDER_THEME_AUTO   OPT_VALUE_AUTO

Definition at line 86 of file enums.h.

◆ OPT_RENDER_THEME_DARK

#define OPT_RENDER_THEME_DARK   "dark"

Definition at line 84 of file enums.h.

Referenced by parse_render_theme().

◆ OPT_RENDER_THEME_LIGHT

#define OPT_RENDER_THEME_LIGHT   "light"

Definition at line 85 of file enums.h.

Referenced by parse_render_theme().

◆ OPT_VALUE_AUTO

#define OPT_VALUE_AUTO   "auto"

◆ OPT_VALUE_FALSE

#define OPT_VALUE_FALSE   "false"

Definition at line 79 of file enums.h.

Referenced by config_load_system_and_user(), and options_format_default_value().

◆ OPT_VALUE_TRUE

#define OPT_VALUE_TRUE   "true"

Function Documentation

◆ options_get_enum_entries()

const enum_to_string_entry_t * options_get_enum_entries ( const char * option_name,
size_t * entry_count )

Get enum entries with descriptions for an option.

Returns entries containing both string values and descriptions for shell completion.

Parameters
option_nameOption long name (e.g., "log-level")
entry_countOUTPUT: Number of entries returned
Returns
Allocated array (caller uses SAFE_FREE), or NULL. Strings are borrowed.

Definition at line 9 of file enums.c.

9 {
10 if (!entry_count)
11 return NULL;
12 *entry_count = 0;
13 if (!option_name)
14 return NULL;
15 const option_metadata_t *meta = options_registry_get_metadata(option_name);
16 if (!meta || !meta->enum_values)
17 return NULL;
18 while (meta->enum_values[*entry_count])
19 ++*entry_count;
20 enum_to_string_entry_t *entries = SAFE_CALLOC(*entry_count + 1, sizeof(*entries), enum_to_string_entry_t *);
21 for (size_t i = 0; i < *entry_count; ++i) {
22 entries[i].enum_value = meta->enum_integer_values ? meta->enum_integer_values[i] : (int)i;
23 entries[i].string = meta->enum_values[i];
24 entries[i].desc = meta->enum_descriptions ? meta->enum_descriptions[i] : NULL;
25 }
26 entries[*entry_count].enum_value = -1;
27 return entries;
28}
#define SAFE_CALLOC(count, size, cast)
Definition common.h:275
const option_metadata_t * options_registry_get_metadata(const char *long_name)
Get complete metadata for an option.
Definition public_api.c:325
Enum value mapping with description for shell completions.
Definition enums.h:29
int enum_value
The numeric enum value.
Definition enums.h:30
const char * desc
Description for shell completion.
Definition enums.h:32
const char * string
The string representation of that enum value.
Definition enums.h:31
Completion metadata attached to one option descriptor.
Definition builder.h:197
const char ** enum_descriptions
Descriptions parallel to enum_values (null-terminated, e.g., "Auto-detect from terminal").
Definition builder.h:202
const int * enum_integer_values
Actual enum integer values (e.g., {-1, 0, 1, 2, 3} for non-sequential enums).
Definition builder.h:203
const char ** enum_values
Enum value strings (null-terminated, e.g., {"auto", "none", "16", "256", "truecolor",...
Definition builder.h:200

References enum_to_string_entry_t::desc, option_metadata_t::enum_descriptions, option_metadata_t::enum_integer_values, enum_to_string_entry_t::enum_value, option_metadata_t::enum_values, options_registry_get_metadata(), SAFE_CALLOC, and enum_to_string_entry_t::string.

◆ options_get_enum_values()

const char ** options_get_enum_values ( const char * option_name,
size_t * value_count )

Get enum values for an option.

Parameters
option_nameOption long name (e.g., "log-level")
value_countOUTPUT: Number of values returned
Returns
Allocated NULL-terminated array (caller uses SAFE_FREE), or NULL. Strings are borrowed.

Definition at line 30 of file enums.c.

30 {
31 if (!value_count)
32 return NULL;
33 *value_count = 0;
34 if (!option_name)
35 return NULL;
36 const char **values = options_registry_get_enum_values(option_name, NULL, value_count);
37 if (!values)
38 return NULL;
39 const char **copy = SAFE_MALLOC((*value_count + 1) * sizeof(*copy), const char **);
40 memcpy(copy, values, (*value_count + 1) * sizeof(*copy));
41 return copy;
42}
#define SAFE_MALLOC(size, cast)
Definition common.h:265
const char ** options_registry_get_enum_values(const char *option_name, const char ***descriptions, size_t *count)
Get enum values for an option.
Definition public_api.c:346

References options_registry_get_enum_values(), and SAFE_MALLOC.

◆ options_is_enum_option()

bool options_is_enum_option ( const char * option_name)

Check if an option has enum values.

Parameters
option_nameOption long name
Returns
true if option has enum values, false otherwise

Definition at line 44 of file enums.c.

44 {
45 if (!option_name)
46 return false;
47 size_t count = 0;
48 return options_registry_get_enum_values(option_name, NULL, &count) != NULL;
49}

References options_registry_get_enum_values().