ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
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.

Data Structures

union  option_parsed_value_t
 Scratch storage for the scalar value produced while parsing one option. More...
struct  option_type_handler_t
 Function table for extracting, validating, storing, and formatting one TOML option type. More...
struct  config_builder_t
 Helper structure for building config content in a buffer. More...

Macros

#define OPTIONS_CONFIG_QUESTION_BUFFER_SIZE   4096
#define CONFIG_WRITTEN_FLAG_CAPACITY   64
#define CONFIG_CATEGORY_CAPACITY   16
Internal Macros

Incremental writer for generated configuration text. Owned Buffers, size, and capacity describe the owned output allocation, while overflow records an overrun; callers finish by taking the built buffer through the builder API.

Function table for extracting, validating, storing, and formatting one TOML option type

#define CONFIG_WARN(fmt, ...)
 Print configuration warning using the logging system.
#define CONFIG_DEBUG(fmt, ...)
 Print configuration debug message.

Functions

asciichat_error_t config_load_and_apply (asciichat_mode_t detected_mode, 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)
 Create default configuration file with all default values.
asciichat_error_t config_load_system_and_user (asciichat_mode_t detected_mode, 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.

Schema-Based Configuration Parser

Detailed Description

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

Definition in file options/config/config.c.

Macro Definition Documentation

◆ CONFIG_CATEGORY_CAPACITY

#define CONFIG_CATEGORY_CAPACITY   16

Definition at line 14 of file options/config/config.c.

Referenced by config_create_default().

◆ 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 74 of file options/config/config.c.

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

Referenced by config_load_and_apply(), and config_load_system_and_user().

◆ CONFIG_WARN

#define CONFIG_WARN ( fmt,
... )
Value:
do { \
log_warn("Config file: " fmt, ##__VA_ARGS__); \
} while (0)

Print configuration warning using the logging system.

Uses log_warn so that config warnings respect the –quiet flag and are routed through the logging system for proper filtering.

Definition at line 63 of file options/config/config.c.

63#define CONFIG_WARN(fmt, ...) \
64 do { \
65 log_warn("Config file: " fmt, ##__VA_ARGS__); \
66 } while (0)

Referenced by config_load_and_apply().

◆ CONFIG_WRITTEN_FLAG_CAPACITY

#define CONFIG_WRITTEN_FLAG_CAPACITY   64

Definition at line 11 of file options/config/config.c.

Referenced by config_create_default().

◆ OPTIONS_CONFIG_QUESTION_BUFFER_SIZE

#define OPTIONS_CONFIG_QUESTION_BUFFER_SIZE   4096

Definition at line 8 of file options/config/config.c.

Referenced by config_create_default().