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

Go to the source code of this file.

Functions

int validate_opt_port (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate port number (1-65535)
 
bool validate_port_callback (const void *options_struct, char **error_msg)
 
int validate_opt_positive_int (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate positive integer.
 
int validate_opt_non_negative_int (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate non-negative integer.
 
int validate_opt_color_mode (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate color mode string.
 
int validate_opt_render_mode (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate render mode string.
 
int validate_opt_palette (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate palette type string.
 
int validate_opt_log_level (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate log level string.
 
int validate_opt_ip_address (const char *value_str, char *parsed_address, size_t address_size, bool is_client, char *error_msg, size_t error_msg_size)
 Validate IP address or hostname.
 
float validate_opt_float_non_negative (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate non-negative float value.
 
float validate_opt_volume (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate volume value (0.0-1.0)
 
int validate_opt_max_clients (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate max clients value (1-32)
 
int validate_opt_compression_level (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate compression level (1-9)
 
int validate_opt_fps (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate FPS value (1-144)
 
int validate_opt_reconnect (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate reconnect value.
 
int validate_opt_device_index (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate device index (-1 for default, 0+ for specific device)
 
int validate_opt_password (const char *value_str, char *error_msg, size_t error_msg_size)
 Validate password (8-256 characters)
 
int options_collect_identity_keys (options_t *opts, int argc, char *argv[])
 Collect multiple –key flags into identity_keys array.
 
bool is_remote_key_path (const char *key_path)
 Check if a key path is a remote/virtual key (not a local file)
 

Function Documentation

◆ validate_port_callback()

bool validate_port_callback ( const void *  options_struct,
char **  error_msg 
)

Validate port option callback (matches option_descriptor validate signature) Used during options parsing to validate port values with PCRE2

Definition at line 97 of file validation.c.

97 {
98 const options_t *opts = (const options_t *)options_struct;
99
100 // Port is stored as an int, but we need to validate it as a string
101 // The issue is that strtol() already accepted invalid formats like " 80", "+80", "0123"
102 // So we can't validate after parsing - we need to prevent the parse in the first place
103 // This callback runs AFTER parsing, so it's too late
104
105 // Instead, check if the port value is in range (this will catch the range but not format issues)
106 if (opts->port < 1 || opts->port > 65535) {
107 if (error_msg) {
108 *error_msg = platform_strdup("Port must be between 1 and 65535");
109 }
110 return false;
111 }
112
113 return true;
114}
char * platform_strdup(const char *s)
Duplicate string (strdup replacement)
Consolidated options structure.

References platform_strdup(), and options_state::port.