ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
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_flip_x (int enabled)
 
EMSCRIPTEN_KEEPALIVE int get_flip_x (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)
 

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 74 of file src/web/common/options.c.

74 {
75 return GET_OPTION(color_filter);
76}

◆ get_color_mode()

EMSCRIPTEN_KEEPALIVE int get_color_mode ( void  )

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

59 {
60 return GET_OPTION(color_mode);
61}

◆ get_flip_x()

EMSCRIPTEN_KEEPALIVE int get_flip_x ( void  )

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

146 {
147 return GET_OPTION(flip_x) ? 1 : 0;
148}

◆ get_height()

EMSCRIPTEN_KEEPALIVE int get_height ( void  )

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

44 {
45 return GET_OPTION(height);
46}

◆ get_matrix_rain()

EMSCRIPTEN_KEEPALIVE int get_matrix_rain ( void  )

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

131 {
132 return GET_OPTION(matrix_rain) ? 1 : 0;
133}

◆ get_palette()

EMSCRIPTEN_KEEPALIVE int get_palette ( void  )

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

103 {
104 return GET_OPTION(palette_type);
105}

◆ get_palette_chars()

EMSCRIPTEN_KEEPALIVE const char * get_palette_chars ( void  )

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

116 {
117 return GET_OPTION(palette_custom);
118}

◆ get_render_mode()

EMSCRIPTEN_KEEPALIVE int get_render_mode ( void  )

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

161 {
162 return GET_OPTION(render_mode);
163}

◆ get_target_fps()

EMSCRIPTEN_KEEPALIVE int get_target_fps ( void  )

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

178 {
179 return GET_OPTION(fps);
180}

◆ get_width()

EMSCRIPTEN_KEEPALIVE int get_width ( void  )

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

31 {
32 return GET_OPTION(width);
33}

◆ set_color_filter()

EMSCRIPTEN_KEEPALIVE int set_color_filter ( int  filter)

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

68 {
69 asciichat_error_t err = options_set_int("color_filter", filter);
70 return (err == ASCIICHAT_OK) ? 0 : -1;
71}
asciichat_error_t options_set_int(const char *field_name, int value)
Definition rcu.c:449

References options_set_int().

◆ set_color_mode()

EMSCRIPTEN_KEEPALIVE int set_color_mode ( int  mode)

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

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

References options_set_int().

◆ set_flip_x()

EMSCRIPTEN_KEEPALIVE int set_flip_x ( int  enabled)

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

140 {
141 asciichat_error_t err = options_set_bool("flip_x", enabled != 0);
142 return (err == ASCIICHAT_OK) ? 0 : -1;
143}
bool enabled
Is filtering active?
Definition grep.c:78
asciichat_error_t options_set_bool(const char *field_name, bool value)
Definition rcu.c:562

References enabled, and options_set_bool().

◆ set_height()

EMSCRIPTEN_KEEPALIVE int set_height ( int  value)

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

36 {
37 if (value <= 0 || value > 1000)
38 return -1;
39 asciichat_error_t err = options_set_int("height", value);
40 return (err == ASCIICHAT_OK) ? 0 : -1;
41}

References options_set_int().

◆ set_matrix_rain()

EMSCRIPTEN_KEEPALIVE int set_matrix_rain ( int  enabled)

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

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

References 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}
bool parse_palette_type(const char *arg, void *dest, char **error_msg)
Definition parsers.c:345

References options_set_int(), and parse_palette_type().

◆ set_palette_chars()

EMSCRIPTEN_KEEPALIVE int set_palette_chars ( const char *  chars)

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

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

References options_set_string().

◆ set_render_mode()

EMSCRIPTEN_KEEPALIVE int set_render_mode ( int  mode)

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

155 {
156 asciichat_error_t err = options_set_int("render_mode", mode);
157 return (err == ASCIICHAT_OK) ? 0 : -1;
158}

References options_set_int().

◆ set_target_fps()

EMSCRIPTEN_KEEPALIVE int set_target_fps ( int  fps)

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

170 {
171 if (fps < 15 || fps > 60)
172 return -1;
173 asciichat_error_t err = options_set_int("fps", fps);
174 return (err == ASCIICHAT_OK) ? 0 : -1;
175}

References options_set_int().

◆ set_width()

EMSCRIPTEN_KEEPALIVE int set_width ( int  value)

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

23 {
24 if (value <= 0 || value > 1000)
25 return -1;
26 asciichat_error_t err = options_set_int("width", value);
27 return (err == ASCIICHAT_OK) ? 0 : -1;
28}

References options_set_int().