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

WASM shared option setters and getters. More...

Go to the source code of this file.

Functions

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

Detailed Description

WASM shared option setters and getters.

Provides unified option access for all WASM modes. These functions are compiled into both mirror.wasm and client.wasm.

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

Function Documentation

◆ get_color_filter()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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_render_mode()

EMSCRIPTEN_KEEPALIVE int get_render_mode ( void  )

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

201 {
202 int result = GET_OPTION(render_mode);
203 return result;
204}

References GET_OPTION.

◆ get_target_fps()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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_render_mode()

EMSCRIPTEN_KEEPALIVE int set_render_mode ( int  mode)

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

195 {
196 asciichat_error_t err = options_set_int("render_mode", mode);
197 return (err == ASCIICHAT_OK) ? 0 : -1;
198}

References ASCIICHAT_OK, and options_set_int().

◆ set_target_fps()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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()

EMSCRIPTEN_KEEPALIVE 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().