ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
options.h File Reference

WASM option accessor declarations. More...

Go to the source code of this file.

Functions

int set_width (int value)
 
int get_width (void)
 
int set_height (int value)
 
int get_height (void)
 
int set_color_mode (int mode)
 
int get_color_mode (void)
 
int set_color_filter (int filter)
 
int get_color_filter (void)
 
int set_palette (const char *palette_name)
 
int get_palette (void)
 
int set_palette_chars (const char *chars)
 
const char * get_palette_chars (void)
 
int set_matrix_rain (int enabled)
 
int get_matrix_rain (void)
 
int set_waveform (int enabled)
 
int get_waveform (void)
 
int set_fft (int enabled)
 
int get_fft (void)
 
int set_flip_x (int enabled)
 
int get_flip_x (void)
 
int set_flip_y (int enabled)
 
int get_flip_y (void)
 
int set_target_fps (int fps)
 
int get_target_fps (void)
 
const char * get_help_text (int mode, const char *option_name)
 

Detailed Description

WASM option accessor declarations.

Declares setter/getter functions for common web settings. Implementations in options.c are compiled into both mirror.wasm and client.wasm.

Definition in file src/web/common/options.h.

Function Documentation

◆ get_color_filter()

int get_color_filter ( void  )

Definition at line 73 of file src/web/common/options.c.

73 {
74 int result = GET_OPTION(color_filter);
75 return result;
76}
#define GET_OPTION(field)
Safely get a specific option field (lock-free read)

References GET_OPTION.

◆ get_color_mode()

int get_color_mode ( void  )

Definition at line 57 of file src/web/common/options.c.

57 {
58 int result = GET_OPTION(color_mode);
59 return result;
60}

References GET_OPTION.

◆ get_fft()

int get_fft ( void  )

Definition at line 154 of file src/web/common/options.c.

154 {
155 return GET_OPTION(fft) ? 1 : 0;
156}

References GET_OPTION.

◆ get_flip_x()

int get_flip_x ( void  )

Definition at line 169 of file src/web/common/options.c.

169 {
170 int result = GET_OPTION(flip_x) ? 1 : 0;
171 return result;
172}

References GET_OPTION.

◆ get_flip_y()

int get_flip_y ( void  )

Definition at line 185 of file src/web/common/options.c.

185 {
186 int result = GET_OPTION(flip_y) ? 1 : 0;
187 return result;
188}

References GET_OPTION.

◆ get_height()

int get_height ( void  )

Definition at line 41 of file src/web/common/options.c.

41 {
42 int result = GET_OPTION(height);
43 return result;
44}

References GET_OPTION.

◆ get_help_text()

const char * get_help_text ( int  mode,
const char *  option_name 
)

Get help text for a CLI option in a specific mode Exported to WASM for JavaScript access via FFI

Parameters
modeThe mode (asciichat_mode_t as int)
option_nameThe long name of the option
Returns
Help text string or NULL if not applicable

Definition at line 235 of file src/web/common/options.c.

235 {
236 if (!option_name || !option_name[0])
237 return NULL;
238 asciichat_mode_t mode_enum = (asciichat_mode_t)mode;
239 const char *result = options_get_help_text(mode_enum, option_name);
240 return result;
241}
const char * options_get_help_text(asciichat_mode_t mode, const char *option_name)
Get help text for an option in a specific mode.
Definition help_api.c:27
asciichat_mode_t
Mode type for options parsing.

References options_get_help_text().

◆ get_matrix_rain()

int get_matrix_rain ( void  )

Definition at line 133 of file src/web/common/options.c.

133 {
134 int result = GET_OPTION(matrix_rain) ? 1 : 0;
135 return result;
136}

References GET_OPTION.

◆ get_palette()

int get_palette ( void  )

Definition at line 103 of file src/web/common/options.c.

103 {
104 int result = GET_OPTION(palette_type);
105 return result;
106}

References GET_OPTION.

◆ get_palette_chars()

const char * get_palette_chars ( void  )

Definition at line 117 of file src/web/common/options.c.

117 {
118 const char *result = GET_OPTION(palette_custom);
119 return result;
120}

References GET_OPTION.

◆ get_target_fps()

int get_target_fps ( void  )

Definition at line 217 of file src/web/common/options.c.

217 {
218 int result = GET_OPTION(fps);
219 return result;
220}

References GET_OPTION.

◆ get_waveform()

int get_waveform ( void  )

Definition at line 144 of file src/web/common/options.c.

144 {
145 return GET_OPTION(waveform) ? 1 : 0;
146}

References GET_OPTION.

◆ get_width()

int get_width ( void  )

Definition at line 29 of file src/web/common/options.c.

29 {
30 int result = GET_OPTION(width);
31 return result;
32}

References GET_OPTION.

◆ set_color_filter()

int set_color_filter ( int  filter)

Definition at line 67 of file src/web/common/options.c.

67 {
68 asciichat_error_t err = options_set_int("color_filter", filter);
69 return (err == ASCIICHAT_OK) ? 0 : -1;
70}
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
@ ASCIICHAT_OK
Definition error_codes.h:51
asciichat_error_t options_set_int(const char *field_name, int value)
Check if an option was explicitly set via command-line.
Definition rcu.c:761

References ASCIICHAT_OK, and options_set_int().

◆ set_color_mode()

int set_color_mode ( int  mode)

Definition at line 51 of file src/web/common/options.c.

51 {
52 asciichat_error_t err = options_set_int("color_mode", mode);
53 return (err == ASCIICHAT_OK) ? 0 : -1;
54}

References ASCIICHAT_OK, and options_set_int().

◆ set_fft()

int set_fft ( int  enabled)

Definition at line 149 of file src/web/common/options.c.

149 {
150 return options_set_bool("fft", enabled != 0) == ASCIICHAT_OK ? 0 : -1;
151}
bool enabled
Is filtering active?
Definition grep.c:84
asciichat_error_t options_set_bool(const char *field_name, bool value)
Definition rcu.c:969

References ASCIICHAT_OK, enabled, and options_set_bool().

◆ set_flip_x()

int set_flip_x ( int  enabled)

Definition at line 163 of file src/web/common/options.c.

163 {
164 asciichat_error_t err = options_set_bool("flip_x", enabled != 0);
165 return (err == ASCIICHAT_OK) ? 0 : -1;
166}

References ASCIICHAT_OK, enabled, and options_set_bool().

◆ set_flip_y()

int set_flip_y ( int  enabled)

Definition at line 179 of file src/web/common/options.c.

179 {
180 asciichat_error_t err = options_set_bool("flip_y", enabled != 0);
181 return (err == ASCIICHAT_OK) ? 0 : -1;
182}

References ASCIICHAT_OK, enabled, and options_set_bool().

◆ set_height()

int set_height ( int  value)

Definition at line 35 of file src/web/common/options.c.

35 {
36 asciichat_error_t err = options_set_int("height", value);
37 return (err == ASCIICHAT_OK) ? 0 : -1;
38}

References ASCIICHAT_OK, and options_set_int().

◆ set_matrix_rain()

int set_matrix_rain ( int  enabled)

Definition at line 127 of file src/web/common/options.c.

127 {
128 asciichat_error_t err = options_set_bool("matrix_rain", enabled != 0);
129 return (err == ASCIICHAT_OK) ? 0 : -1;
130}

References ASCIICHAT_OK, enabled, and options_set_bool().

◆ set_palette()

int set_palette ( const char *  palette_name)

Definition at line 83 of file src/web/common/options.c.

83 {
84 if (!palette_name)
85 return -1;
86
87 palette_type_t palette_value;
88 char *error_msg = NULL;
89
90 if (!parse_palette_type(palette_name, &palette_value, &error_msg)) {
91 if (error_msg) {
92 log_error("Failed to parse palette '%s': %s", palette_name, error_msg);
93 free(error_msg);
94 }
95 return -1;
96 }
97
98 asciichat_error_t err = options_set_int("palette_type", (int)palette_value);
99 return (err == ASCIICHAT_OK) ? 0 : -1;
100}
#define log_error(...)
Log an ERROR message.
Definition log/log.h:587
palette_type_t
Built-in palette type enumeration.
Definition palette.h:84
bool parse_palette_type(const char *arg, void *dest, char **error_msg)
Parse palette type option.
Definition parsers.c:385

References ASCIICHAT_OK, log_error, options_set_int(), and parse_palette_type().

◆ set_palette_chars()

int set_palette_chars ( const char *  chars)

Definition at line 109 of file src/web/common/options.c.

109 {
110 if (!chars)
111 return -1;
112 asciichat_error_t err = options_set_string("palette_custom", chars);
113 return (err == ASCIICHAT_OK) ? 0 : -1;
114}
asciichat_error_t options_set_string(const char *field_name, const char *value)
Definition rcu.c:1186

References ASCIICHAT_OK, and options_set_string().

◆ set_target_fps()

int set_target_fps ( int  fps)

Definition at line 211 of file src/web/common/options.c.

211 {
212 asciichat_error_t err = options_set_int("fps", fps);
213 return (err == ASCIICHAT_OK) ? 0 : -1;
214}

References ASCIICHAT_OK, and options_set_int().

◆ set_waveform()

int set_waveform ( int  enabled)

Definition at line 139 of file src/web/common/options.c.

139 {
140 return options_set_bool("waveform", enabled != 0) == ASCIICHAT_OK ? 0 : -1;
141}

References ASCIICHAT_OK, enabled, and options_set_bool().

◆ set_width()

int set_width ( int  value)

Definition at line 23 of file src/web/common/options.c.

23 {
24 asciichat_error_t err = options_set_int("width", value);
25 return (err == ASCIICHAT_OK) ? 0 : -1;
26}

References ASCIICHAT_OK, and options_set_int().