ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
config.c File Reference

📋 TOML configuration file parser with schema validation and CLI override support More...

Go to the source code of this file.

Macros

#define ASCIICHAT_INSTALL_PREFIX   "/usr"
 
Internal Macros
#define CONFIG_WARN(fmt, ...)
 Print configuration warning to stderr.
 
#define CONFIG_DEBUG(fmt, ...)
 Print configuration debug message.
 

Functions

asciichat_error_t config_load_and_apply (bool is_client, const char *config_path, bool strict, options_t *opts)
 Main function to load configuration from file and apply to global options.
 
asciichat_error_t config_create_default (const char *config_path, const options_t *opts)
 Create default configuration file with all default values.
 
asciichat_error_t config_load_system_and_user (bool is_client, const char *user_config_path, bool strict, options_t *opts)
 Load system config first, then user config (user config overrides system)
 
TOML Value Extraction Helpers

Helper functions to safely extract typed values from TOML datum structures.

Internal Configuration Application Functions

These functions apply configuration values from TOML sections to global options, with validation and error handling.

Detailed Description

📋 TOML configuration file parser with schema validation and CLI override support

Definition in file config.c.

Macro Definition Documentation

◆ ASCIICHAT_INSTALL_PREFIX

#define ASCIICHAT_INSTALL_PREFIX   "/usr"

◆ CONFIG_DEBUG

#define CONFIG_DEBUG (   fmt,
  ... 
)
Value:
do { \
/* Debug messages are only shown in debug builds after logging is initialized */ \
/* Use log_debug which safely checks initialization itself */ \
log_debug(fmt, ##__VA_ARGS__); \
} while (0)

Print configuration debug message.

Debug messages use the logging system if it's initialized, otherwise they are silently dropped.

Definition at line 59 of file config.c.

60 { \
61 /* Debug messages are only shown in debug builds after logging is initialized */ \
62 /* Use log_debug which safely checks initialization itself */ \
63 log_debug(fmt, ##__VA_ARGS__); \
64 } while (0)

◆ CONFIG_WARN

#define CONFIG_WARN (   fmt,
  ... 
)
Value:
do { \
(void)fprintf(stderr, "WARNING: Config file: " fmt "\n", ##__VA_ARGS__); \
(void)fflush(stderr); \
} while (0)

Print configuration warning to stderr.

Config warnings are printed directly to stderr because logging may not be initialized yet when configuration is loaded. This ensures users see validation errors immediately.

Definition at line 47 of file config.c.

48 { \
49 (void)fprintf(stderr, "WARNING: Config file: " fmt "\n", ##__VA_ARGS__); \
50 (void)fflush(stderr); \
51 } while (0)