|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
Custom option parsers for enum types. More...
Go to the source code of this file.
Functions | |
| bool | parse_color_mode (const char *arg, void *dest, char **error_msg) |
| Parse terminal color level option. | |
| bool | parse_render_mode (const char *arg, void *dest, char **error_msg) |
| Parse render mode option. | |
| bool | parse_palette_type (const char *arg, void *dest, char **error_msg) |
| Parse palette type option. | |
| bool | parse_palette_chars (const char *arg, void *dest, char **error_msg) |
| Parse custom palette characters option. | |
| bool | parse_log_level (const char *arg, void *dest, char **error_msg) |
| Parse log level option. | |
| int | parse_server_bind_address (const char *arg, void *config, char **remaining, int num_remaining, char **error_msg) |
| Parse server bind address positional argument. | |
| int | parse_client_address (const char *arg, void *config, char **remaining, int num_remaining, char **error_msg) |
| Parse client address positional argument. | |
Custom option parsers for enum types.
This module provides custom callback parsers for enum-based options used by the options builder system. Each parser converts a string argument to the appropriate enum value.
Definition in file parsers.h.
| int parse_client_address | ( | const char * | arg, |
| void * | config, | ||
| char ** | remaining, | ||
| int | num_remaining, | ||
| char ** | error_msg | ||
| ) |
Parse client address positional argument.
| arg | Address argument in format [address][:port] |
| config | Pointer to options struct (must contain address and port fields) |
| remaining | Remaining positional args (unused for client) |
| num_remaining | Count of remaining args |
| error_msg | Error message output (set on failure) |
Client address parsing rules:
This parser handles the complex logic of separating address from optional port while correctly handling IPv6 addresses that contain colons.
Example usage with options_builder_add_positional():
Implements the client address parsing logic from client.c. Parses [address][:port] with complex IPv6 handling.
Definition at line 393 of file parsers.c.
References is_session_string(), is_valid_ipv4(), log_debug, OPTIONS_BUFF_SIZE, SAFE_MALLOC, and SAFE_SNPRINTF.
Referenced by options_preset_client().
| bool parse_color_mode | ( | const char * | arg, |
| void * | dest, | ||
| char ** | error_msg | ||
| ) |
Parse terminal color level option.
| arg | String argument (e.g., "auto", "none", "16", "256", "truecolor") |
| dest | Destination pointer (terminal_color_mode_t*) |
| error_msg | Optional error message output (set on failure) |
Valid values:
Definition at line 75 of file parsers.c.
References SAFE_MALLOC, TERM_COLOR_16, TERM_COLOR_256, TERM_COLOR_AUTO, TERM_COLOR_NONE, and TERM_COLOR_TRUECOLOR.
| bool parse_log_level | ( | const char * | arg, |
| void * | dest, | ||
| char ** | error_msg | ||
| ) |
Parse log level option.
| arg | String argument (e.g., "debug", "info", "warn") |
| dest | Destination pointer (log_level_t*) |
| error_msg | Optional error message output (set on failure) |
Valid values:
Definition at line 233 of file parsers.c.
References LOG_DEBUG, LOG_DEV, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_WARN, and SAFE_MALLOC.
Referenced by options_preset_acds().
| bool parse_palette_chars | ( | const char * | arg, |
| void * | dest, | ||
| char ** | error_msg | ||
| ) |
Parse custom palette characters option.
| arg | String of characters ordered from darkest to brightest |
| dest | Destination pointer (char[256]) |
| error_msg | Optional error message output (set on failure) |
The characters should be ordered from darkest (leftmost) to brightest (rightmost). Maximum length is 255 characters.
Example: " .:-=+*#%@"
Definition at line 534 of file parsers.c.
References SAFE_MALLOC, and SAFE_STRNCPY.
| bool parse_palette_type | ( | const char * | arg, |
| void * | dest, | ||
| char ** | error_msg | ||
| ) |
Parse palette type option.
| arg | String argument (e.g., "standard", "blocks", "custom") |
| dest | Destination pointer (palette_type_t*) |
| error_msg | Optional error message output (set on failure) |
Valid values:
Definition at line 173 of file parsers.c.
References PALETTE_BLOCKS, PALETTE_COOL, PALETTE_CUSTOM, PALETTE_DIGITAL, PALETTE_MINIMAL, PALETTE_STANDARD, and SAFE_MALLOC.
| bool parse_render_mode | ( | const char * | arg, |
| void * | dest, | ||
| char ** | error_msg | ||
| ) |
Parse render mode option.
| arg | String argument (e.g., "foreground", "background", "half-block") |
| dest | Destination pointer (render_mode_t*) |
| error_msg | Optional error message output (set on failure) |
Valid values:
Definition at line 131 of file parsers.c.
References RENDER_MODE_BACKGROUND, RENDER_MODE_FOREGROUND, RENDER_MODE_HALF_BLOCK, and SAFE_MALLOC.
| int parse_server_bind_address | ( | const char * | arg, |
| void * | config, | ||
| char ** | remaining, | ||
| int | num_remaining, | ||
| char ** | error_msg | ||
| ) |
Parse server bind address positional argument.
| arg | Current bind address argument |
| config | Pointer to options struct (must contain address/address6 fields) |
| remaining | Remaining positional args (for multi-arg parsing) |
| num_remaining | Count of remaining args |
| error_msg | Error message output (set on failure) |
Server bind address parsing rules:
This parser can consume 0-2 arguments depending on what's provided. It tracks internal state to ensure only one IPv4 and one IPv6 are specified.
Example usage with options_builder_add_positional():
Implements the server bind address parsing logic from server.c. Can consume 1 argument per call, handling IPv4 or IPv6 bind addresses. The positional arg system will call this multiple times for multiple args.
Definition at line 306 of file parsers.c.
References is_valid_ipv4(), is_valid_ipv6(), OPTIONS_BUFF_SIZE, parse_ipv6_address(), SAFE_MALLOC, and SAFE_SNPRINTF.
Referenced by options_preset_acds(), and options_preset_server().