ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
Config Module

The toml text file configuration file module. More...

Files

file  config.c
 📋 TOML configuration file parser with schema validation and CLI override support
file  config.c
 📋 TOML configuration file parser with schema validation and CLI override support
file  config.h
 TOML configuration file support for ascii-chat.

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_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).
flags_schema_builder_t * options_config_build_flags_schema (option_mode_bitmask_t mode_mask)
asciichat_error_t config_create_default (const char *config_path)
 Create default configuration file with all default values.

Detailed Description

The toml text file configuration file module.

This module provides functionality for loading configuration from TOML files (typically located at ~/.ascii-chat/config.toml). Configuration values are applied to global options, but command-line arguments always take precedence over config file values.

The interface provides:

  • TOML file parsing and validation
  • Automatic configuration loading from standard location
  • Non-fatal error handling (missing or malformed config files are ignored)
  • Support for network, client, palette, crypto, and logging configuration
Note
Configuration Priority: Command-line arguments override config file values. Config file values override default values. The config file is loaded before CLI argument parsing to ensure this precedence.
Configuration File Location: The config file is loaded from the ascii-chat configuration directory:
  • Unix: $XDG_CONFIG_HOME/ascii-chat/config.toml if set, otherwise ~/.ascii-chat/config.toml
  • Windows: APPDATA%\ascii-chat\config.toml if set, otherwise ~\.ascii-chat\config.toml
Error Handling: Config file parsing errors are non-fatal. If the file is missing, malformed, or contains invalid values, warnings are printed to stderr and the application continues with default values. Invalid individual values are skipped with warnings, but valid values are still applied.
Validation: All configuration values are validated using the same validation functions used by CLI argument parsing, ensuring consistency between config file and CLI option handling.
Warning
Password Storage: While passwords can be stored in the config file (via crypto.password), this is strongly discouraged for security reasons. A warning is printed if a password is found in the config file. Use CLI --password or environment variables instead.
File Permissions: Users should secure their config file to prevent unauthorized access, especially if it contains sensitive information like encryption keys or passwords.
Author
Zachary Fogg me@zf.nosp@m.o.gg
Date
October 2025

Function Documentation

◆ config_create_default()

asciichat_error_t config_create_default ( const char * config_path)

#include <include/ascii-chat/options/config.h>

Create default configuration file with all default values.

Parameters
config_pathPath to config file to create (NULL uses default location)
optsOptions structure with values to write (use defaults for a "default" config)
Returns
ASCIICHAT_OK on success, error code on failure

Creates a new configuration file at the specified path (or default location if config_path is NULL) with all configuration options set to values from opts.

The created file includes:

  • Version comment at the top (current ascii-chat version)
  • All supported configuration sections with default values
  • Comments explaining each option
Note
The function will create the directory structure if needed.
If the file already exists, it will not be overwritten (returns error).

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

91 {
92 /*
93 * The schema and serializer belong to libflags. ascii-chat only owns the
94 * application-specific destination policy and overwrite confirmation.
95 */
96 char *expanded_path = NULL;
97 defer(SAFE_FREE(expanded_path));
98
99 const char *output_path = "-";
100 if (config_path && config_path[0] != '\0') {
101 expanded_path = expand_path(config_path);
102 if (!expanded_path)
103 expanded_path = platform_strdup(config_path);
104 if (!expanded_path)
105 return SET_ERRNO(ERROR_MEMORY, "Failed to resolve config file path");
106
107 char *validated_path = NULL;
109 expanded_path, PATH_ROLE_CONFIG_FILE, &validated_path);
110 if (validation != ASCIICHAT_OK) {
111 SAFE_FREE(validated_path);
112 return validation;
113 }
114 SAFE_FREE(expanded_path);
115 expanded_path = validated_path;
116 output_path = expanded_path;
117
118 struct stat st;
119 if (stat(output_path, &st) == 0) {
120 log_plain("Config file already exists: %s", output_path);
122 safe_snprintf(question, sizeof(question),
123 "File already exists: %s\n\nOverwrite", output_path);
124 if (!ui_notice_confirm_kind(UI_PROMPT_CONFIG_OVERWRITE, UI_NOTICE_WARNING,
125 question, 30))
126 return SET_ERRNO(ERROR_CONFIG, "User cancelled overwrite");
127 }
128
129 char *directory = platform_strdup(output_path);
130 if (!directory)
131 return SET_ERRNO(ERROR_MEMORY,
132 "Failed to allocate memory for config directory");
133 char *separator = strrchr(directory, PATH_DELIM);
134 if (separator) {
135 *separator = '\0';
136 asciichat_error_t mkdir_result =
137 platform_mkdir_recursive(directory, DIR_PERM_PRIVATE);
138 SAFE_FREE(directory);
139 if (mkdir_result != ASCIICHAT_OK)
140 return mkdir_result;
141 } else {
142 SAFE_FREE(directory);
143 }
144 }
145
146 options_t defaults = options_t_new();
147 flags_schema_builder_t *builder =
149 if (!builder)
150 return SET_ERRNO(ERROR_CONFIG, "Failed to build configuration schema");
151 flags_context_t *context = flags_create(flags_schema_builder_schema(builder),
152 &defaults, sizeof(defaults));
153 if (!context) {
154 flags_schema_builder_destroy(builder);
155 return SET_ERRNO(ERROR_CONFIG, "Failed to create configuration context");
156 }
157
158 const bool written = flags_config_write_toml(context, output_path);
159 flags_destroy(context);
160 flags_schema_builder_destroy(builder);
161 if (!written)
162 return SET_ERRNO(ERROR_CONFIG, "Failed to write configuration to '%s'",
163 output_path);
164 return ASCIICHAT_OK;
#define SET_ERRNO(code,...)
int platform_mkdir_recursive(const char *path, int mode)
Definition filesystem.c:36
#define SAFE_FREE(ptr)
flags_schema_builder_t * options_config_build_flags_schema(option_mode_bitmask_t mode_mask)
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ERROR_MEMORY
Definition error_codes.h:55
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_CONFIG
Definition error_codes.h:56
#define log_plain(...)
Plain logging - writes to both log file and stderr without timestamps or log levels.
Definition log/log.h:635
struct options_state options_t
Immutable, RCU-published snapshot of the application's runtime configuration.
options_t options_t_new(void)
Initialize options by parsing command-line arguments.
Definition options.c:688
@ OPTION_MODE_ALL
All modes + binary.
Definition options.h:943
asciichat_error_t path_validate_user_path(const char *input, path_role_t role, char **normalized_out)
Validate and canonicalize a user-supplied filesystem path.
Definition path.c:739
char * expand_path(const char *path)
Expand path with tilde (~) support.
Definition path.c:270
@ PATH_ROLE_CONFIG_FILE
Definition path.h:344
struct flags_schema_builder flags_schema_builder_t
bool ui_notice_confirm_kind(ui_prompt_kind_t kind, ui_notice_severity_t severity, const char *text, unsigned timeout_seconds)
Definition notice.c:548
@ UI_NOTICE_WARNING
Definition notice.h:15
#define OPTIONS_CONFIG_QUESTION_BUFFER_SIZE
char * platform_strdup(const char *s)

References ASCIICHAT_OK, config_builder_t::buffer, BUFFER_SIZE_MEDIUM, config_builder_t::capacity, config_option_metadata_t::category, CONFIG_CATEGORY_CAPACITY, config_schema_build_from_configs(), config_schema_get_all(), config_schema_get_by_category(), CONFIG_WRITTEN_FLAG_CAPACITY, config_option_metadata_t::description, ERROR_CONFIG, ERROR_MEMORY, expand_path(), config_option_metadata_t::field_offset, config_option_metadata_t::field_size, log_plain, config_option_metadata_t::mode_bitmask, config_option_metadata_t::mode_default_getter, MODE_INVALID, OPTION_MODE_ALL, OPTION_TYPE_CALLBACK, OPTION_TYPE_INT, OPTION_TYPE_STRING, OPTIONS_BUFF_SIZE, options_config_build_flags_schema(), options_config_destroy(), OPTIONS_CONFIG_QUESTION_BUFFER_SIZE, options_preset_unified(), options_t_new(), PATH_ROLE_CONFIG_FILE, path_validate_user_path(), platform_fopen(), platform_mkdir_recursive(), platform_strdup(), SAFE_FCLOSE, SAFE_FREE, SAFE_MALLOC, SAFE_STRNCPY, SET_ERRNO, SET_ERRNO_SYS, config_builder_t::size, terminal_flush(), config_option_metadata_t::toml_key, config_option_metadata_t::type, ui_notice_confirm_kind(), and UI_NOTICE_WARNING.

Referenced by action_create_config().

◆ config_load_and_apply()

asciichat_error_t config_load_and_apply ( asciichat_mode_t detected_mode,
const char * config_path,
bool strict,
options_t * opts )

#include <lib/options/config/config.c>

Main function to load configuration from file and apply to global options.

Load configuration from TOML file and apply to global options.

Parameters
is_clienttrue if loading client configuration, false for server configuration
config_pathOptional path to config file (NULL uses default location)
strictIf true, errors are fatal; if false, errors are non-fatal warnings
Returns
ASCIICHAT_OK on success, error code on failure (if strict) or non-fatal (if !strict)

This is the main entry point for configuration loading. It:

  1. Expands the config file path (default location or custom path)
  2. Checks if the file exists and is a regular file
  3. Parses the TOML file using tomlc17
  4. Applies configuration from each section (network, client, palette, crypto, logging)
  5. Frees resources and returns

Configuration file errors are non-fatal if strict is false:

  • Missing file: Returns ASCIICHAT_OK (config file is optional)
  • Not a regular file: Warns and returns ASCIICHAT_OK
  • Parse errors: Warns and returns ASCIICHAT_OK
  • Invalid values: Individual values are skipped with warnings

If strict is true, any error causes immediate return with error code.

Note
This function should be called before options_init() parses command-line arguments to ensure CLI arguments can override config file values.
Configuration warnings are printed to stderr because logging may not be initialized yet when this function is called.
Parameters
is_clienttrue if loading client configuration, false for server configuration
config_pathOptional path to config file (NULL uses default location)
strictIf true, errors are fatal; if false, errors are non-fatal warnings
Returns
ASCIICHAT_OK on success, error code on failure (if strict) or non-fatal (if !strict)

Loads configuration from the specified path (or default location if config_path is NULL) and applies values to global options.

Default config file location (when config_path is NULL):

  • Unix: $XDG_CONFIG_HOME/ascii-chat/config.toml if set, otherwise ~/.ascii-chat/config.toml
  • Windows: APPDATA%\ascii-chat\config.toml if set, otherwise ~.ascii-chat\config.toml

Only applies configuration values that haven't already been set (though in practice, CLI arguments will override config values anyway since this is called before CLI parsing).

Supported configuration sections:

Note
This function should be called before options_init() parses command-line arguments, so that CLI arguments can override config file values.
If strict is false and the config file doesn't exist, is not a regular file, or fails to parse, the function returns ASCIICHAT_OK (non-fatal). Individual invalid values are skipped with warnings, but valid values are still applied.
If strict is true, any error (file not found, parse error, etc.) causes the function to return an error code immediately.
Warning
Configuration warnings are printed directly to stderr because logging may not be initialized yet when this function is called.

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

1046 {
1047 // detected_mode is used in config_apply_schema for bitmask validation
1048 char *config_path_expanded = NULL;
1049 defer(SAFE_FREE(config_path_expanded));
1050
1051 if (config_path) {
1052 // Use custom path provided
1053 config_path_expanded = expand_path(config_path);
1054 if (!config_path_expanded) {
1055 // If expansion fails, try using as-is (might already be absolute)
1056 config_path_expanded = platform_strdup(config_path);
1057 }
1058 } else {
1059 // Use default location with XDG support
1060 char *config_dir = get_config_dir();
1061 defer(SAFE_FREE(config_dir));
1062 if (config_dir) {
1063 size_t len = strlen(config_dir) + strlen("config.toml") + 1;
1064 config_path_expanded = SAFE_MALLOC(len, char *);
1065 if (config_path_expanded) {
1066 safe_snprintf(config_path_expanded, len, "%sconfig.toml", config_dir);
1067 }
1068 }
1069
1070 // Fallback to ~/.ascii-chat/config.toml
1071 if (!config_path_expanded) {
1072 config_path_expanded = expand_path("~/.ascii-chat/config.toml");
1073 }
1074 }
1075
1076 if (!config_path_expanded) {
1077 if (strict) {
1078 return SET_ERRNO(ERROR_CONFIG, "Failed to resolve config file path");
1079 }
1080 return ASCIICHAT_OK;
1081 }
1082
1083 char *validated_config_path = NULL;
1084 // An optional default config is allowed not to exist. Check this before the
1085 // whitelist validator, which quite correctly rejects paths whose parent
1086 // directory has not been created yet but should not turn that normal case
1087 // into a configuration error.
1088 if (!strict && platform_access(config_path_expanded, PLATFORM_ACCESS_EXISTS) != 0 && errno == ENOENT) {
1089 SAFE_FREE(config_path_expanded);
1090 return ASCIICHAT_OK;
1091 }
1092 // An explicit --config path is already user-authorized and may point to any
1093 // readable configuration file. Do not route Windows absolute paths through
1094 // the sandbox validator, which is intended for untrusted path-valued
1095 // options and can reject valid drive-qualified paths.
1096 if (config_path) {
1097 validated_config_path = platform_strdup(config_path_expanded);
1098 if (!validated_config_path) {
1099 SAFE_FREE(config_path_expanded);
1100 return SET_ERRNO(ERROR_MEMORY, "Failed to copy config file path");
1101 }
1102 } else {
1103 asciichat_error_t validate_result = path_validate_user_path(config_path_expanded, PATH_ROLE_CONFIG_FILE, &validated_config_path);
1104 if (validate_result != ASCIICHAT_OK) {
1105 SAFE_FREE(validated_config_path);
1106 SAFE_FREE(config_path_expanded);
1107 return validate_result;
1108 }
1109 }
1110 // Free the old path before reassigning (defer will free the new one)
1111 if (config_path_expanded != validated_config_path) {
1112 SAFE_FREE(config_path_expanded);
1113 }
1114 config_path_expanded = validated_config_path;
1115
1116 // Determine display path for error messages (before any early returns)
1117 const char *display_path = config_path ? config_path : config_path_expanded;
1118
1119 // Log that we're attempting to load config (before logging is initialized, use stderr)
1120 // Only print if terminal output is enabled (suppress with --quiet)
1121 if (config_path && log_get_terminal_output()) {
1122 log_dev("Loading configuration from: %s", display_path);
1123 }
1124
1125 // Check if config file exists
1126 struct stat st;
1127 if (stat(config_path_expanded, &st) != 0) {
1128 if (strict) {
1129 return SET_ERRNO(ERROR_CONFIG, "Config file does not exist: '%s'", display_path);
1130 }
1131 // File doesn't exist, that's OK - not required (non-strict mode)
1132 return ASCIICHAT_OK;
1133 }
1134
1135 // Verify it's a regular file
1136 if (!S_ISREG(st.st_mode)) {
1137 if (strict) {
1138 return SET_ERRNO(ERROR_CONFIG, "Config file exists but is not a regular file: '%s'", display_path);
1139 }
1140 CONFIG_WARN("Config file exists but is not a regular file: '%s' (skipping)", display_path);
1141 return ASCIICHAT_OK;
1142 }
1143
1144 // Parse TOML file
1145 toml_result_t result = toml_parse_file_ex(config_path_expanded);
1146 // Ensure TOML resources are freed at ALL function exit points (defer handles cleanup)
1147 defer(toml_free(result));
1148
1149 if (!result.ok) {
1150 // result.errmsg is an array, so check its first character
1151 const char *errmsg = (strlen(result.errmsg) > 0) ? result.errmsg : "Unknown parse error";
1152
1153 if (strict) {
1154 // For strict mode, return detailed error message directly
1155 // Note: SET_ERRNO stores the message in context, but asciichat_error_string() only returns generic codes
1156 // So we need to format the error message ourselves here
1157 char error_buffer[BUFFER_SIZE_MEDIUM];
1158 safe_snprintf(error_buffer, sizeof(error_buffer), "Failed to parse config file '%s': %s", display_path, errmsg);
1159 return SET_ERRNO(ERROR_CONFIG, "%s", error_buffer);
1160 }
1161 CONFIG_WARN("Failed to parse config file '%s': %s (skipping)", display_path, errmsg);
1162 return ASCIICHAT_OK; // Non-fatal error
1163 }
1164
1165 // Apply configuration using schema-driven parser with bitmask validation
1167 asciichat_error_t schema_result = config_apply_schema(result.toptab, detected_mode, opts, strict);
1168
1169 if (schema_result != ASCIICHAT_OK && strict) {
1170 return schema_result;
1171 }
1172 if (strict && schema_result == ASCIICHAT_OK)
1173 ASSERT_NO_ERRNO_SINCE(schema_scope);
1175 // In non-strict mode, continue even if some options failed validation
1176
1177 log_dev("Loaded configuration from %s", display_path);
1178
1179 // Log successful config load (use stderr since logging may not be initialized yet)
1180 // Only print if terminal output is enabled (suppress with --quiet)
1182 log_dev("Loaded configuration from: %s", display_path);
1183 }
1184
1185 // Update RCU system with modified options (for test compatibility)
1186 // In real usage, options_state_set is called later after CLI parsing
1188 asciichat_error_t rcu_result = options_state_set(opts);
1189 if (rcu_result != ASCIICHAT_OK) {
1190 // Non-fatal - RCU might not be initialized yet in some test scenarios
1191 // But log as warning so tests can see if this is the issue
1192 CONFIG_WARN("Failed to update RCU options state: %d (values may not be persisted)", rcu_result);
1193 } else {
1194 ASSERT_NO_ERRNO_SINCE(rcu_scope);
1195 }
1197
1198 return ASCIICHAT_OK;
1199}
void errno_scope_end(asciichat_errno_scope_t scope, asciichat_errno_outcome_t outcome)
asciichat_errno_scope_t errno_scope_begin(void)
#define ASSERT_NO_ERRNO_SINCE(scope)
@ ASCIICHAT_ERRNO_DISMISSED
int platform_access(const char *pathname, int mode)
Definition filesystem.c:95
#define BUFFER_SIZE_MEDIUM
Medium buffer size (512 bytes).
#define SAFE_MALLOC(size, cast)
bool log_get_terminal_output(void)
Get current terminal output setting.
Definition log/log.c:836
#define log_dev(...)
Log a DEV message (most verbose, development only).
Definition log/log.h:551
char * get_config_dir(void)
Get configuration directory path with XDG_CONFIG_HOME support.
Definition path.c:293
#define CONFIG_WARN(fmt,...)
Print configuration warning using the logging system.
asciichat_error_t options_state_set(const options_t *opts)
Set options from a parsed options struct.
Definition rcu.c:459
When code needs to work with asciichat errno snapshot, it keeps total, copied here instead of scatter...

References ASCIICHAT_ERRNO_DISMISSED, ASCIICHAT_OK, ASSERT_NO_ERRNO_SINCE, BUFFER_SIZE_MEDIUM, CONFIG_WARN, errno_scope_begin(), errno_scope_end(), ERROR_CONFIG, ERROR_MEMORY, expand_path(), get_config_dir(), log_dev, log_get_terminal_output(), options_state_set(), PATH_ROLE_CONFIG_FILE, path_validate_user_path(), platform_access(), platform_strdup(), SAFE_FREE, SAFE_MALLOC, and SET_ERRNO.

Referenced by config_load_system_and_user().

◆ config_load_system_and_user()

asciichat_error_t config_load_system_and_user ( asciichat_mode_t detected_mode,
bool strict,
options_t * opts )

#include <include/ascii-chat/options/config.h>

Load system config first, then user config (user config overrides system).

Parameters
detected_modeThe detected mode (client or server)
strictIf true, user config errors are fatal; system config is always non-strict
optsOptions structure to write configuration to
Returns
ASCIICHAT_OK on success, error code on failure

Loads configuration from two locations in order:

  1. System config: ${INSTALL_PREFIX}/etc/ascii-chat/config.toml (non-strict, optional)
  2. User config: default location (strictness as specified)

User config values override system config values. Both override defaults. This function should be called before options_init() parses command-line arguments.

Note
System config is always loaded non-strict (missing file is not an error)
User config strictness follows the strict parameter

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

220 {
221 // Use platform abstraction to find all config.toml files across standard
222 // locations
223 config_file_list_t config_files = {0};
224 asciichat_error_t search_result =
225 platform_find_config_file("config.toml", &config_files);
226 defer(config_file_list_destroy(&config_files));
227
228 // Keep the application config authoritative even when an older platform
229 // runtime is present. The explicit config path and generated config both
230 // use this directory, so discovery must not silently fall back to the
231 // generic "application" directory.
232 if (search_result == ASCIICHAT_OK && config_files.count == 0) {
233 char *config_dir = get_config_dir();
234 if (config_dir) {
235 size_t dir_len = strlen(config_dir);
236 bool has_separator = dir_len > 0 && (config_dir[dir_len - 1] == '/' ||
237 config_dir[dir_len - 1] == '\\');
238 size_t path_len =
239 dir_len + (has_separator ? 0 : 1) + strlen("config.toml") + 1;
240 char *path = SAFE_MALLOC(path_len, char *);
241 if (path) {
242 safe_snprintf(path, path_len, "%s%sconfig.toml", config_dir,
243 has_separator ? "" : "\\");
244 if (config_files.capacity > config_files.count) {
245 config_file_result_t *file =
246 &config_files.files[config_files.count++];
247 file->path = path;
248 file->priority = 0;
249 file->exists = true;
250 file->is_system_config = false;
251 path = NULL;
252 }
253 SAFE_FREE(path);
254 }
255 SAFE_FREE(config_dir);
256 }
257 }
258
259 if (search_result != ASCIICHAT_OK) {
260 CONFIG_DEBUG("Failed to search for config files: %d", search_result);
261 return search_result;
262 }
263
264 // Cascade load: Load all found configs in reverse order (lowest priority
265 // first) This allows higher-priority configs to override lower-priority
266 // values. Example: System configs load first, then user configs override
267 // them.
268
270 for (size_t i = config_files.count; i > 0; i--) {
271 const config_file_result_t *file = &config_files.files[i - 1];
272
273 // Determine strictness based on whether this is a system or user config
274 // System configs are non-strict (values can be missing, errors are
275 // non-fatal) User config is strict or non-strict based on parameter
276 bool is_user_config = !file->is_system_config;
277 bool file_strict = is_user_config ? strict : false;
278
279 CONFIG_DEBUG("Loading config from %s (system=%s, strict=%s)", file->path,
280 file->is_system_config ? "yes" : "no",
281 file_strict ? OPT_VALUE_TRUE : OPT_VALUE_FALSE);
282
284 asciichat_error_t load_result =
285 config_load_and_apply(detected_mode, file->path, file_strict, opts);
286
287 if (load_result != ASCIICHAT_OK) {
288 if (file_strict) {
289 // Strict mode: errors are fatal
290 CONFIG_DEBUG("Strict config loading failed for %s", file->path);
291 result = load_result;
292 } else {
293 // Non-strict mode: errors are non-fatal, just log and continue
295 "Non-strict config loading warning for %s: %d (continuing)",
296 file->path, load_result);
298 ASSERT_NO_ERRNO_SINCE(load_scope);
299 }
300 } else {
301 ASSERT_NO_ERRNO_SINCE(load_scope);
303 }
304 }
305
306 return result;
@ ASCIICHAT_ERRNO_HANDLED
#define OPT_VALUE_FALSE
Definition enums.h:84
#define OPT_VALUE_TRUE
Definition enums.h:83
int platform_find_config_file(const char *filename, config_file_list_t *list_out)
Definition filesystem.c:42
void config_file_list_destroy(config_file_list_t *list)
Definition filesystem.c:52
#define CONFIG_DEBUG(fmt,...)
Print configuration debug message.
asciichat_error_t config_load_and_apply(asciichat_mode_t detected_mode, const char *config_path, bool strict, options_t *opts)
Load configuration from TOML file and apply to global options.

References ASCIICHAT_ERRNO_DISMISSED, ASCIICHAT_ERRNO_HANDLED, ASCIICHAT_OK, ASSERT_NO_ERRNO_SINCE, CONFIG_DEBUG, config_file_list_destroy(), config_load_and_apply(), errno_scope_begin(), errno_scope_end(), get_config_dir(), OPT_VALUE_FALSE, OPT_VALUE_TRUE, platform_find_config_file(), SAFE_FREE, and SAFE_MALLOC.

◆ options_config_build_flags_schema()

flags_schema_builder_t * options_config_build_flags_schema ( option_mode_bitmask_t mode_mask)

#include <include/ascii-chat/options/config.h>

Build the generic scalar/string portion of ascii-chat's TOML schema.

The application registry remains authoritative for mode filtering and callbacks while libflags owns storage binding and TOML conversion.

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

52 {
53 flags_schema_builder_t *builder = flags_schema_builder_create();
54 if (!builder)
55 return NULL;
56 if (registry_add_all_to_flags_builder(builder, mode_mask) != ASCIICHAT_OK) {
57 flags_schema_builder_destroy(builder);
58 return NULL;
59 }
60
61 return builder;
62}
asciichat_error_t registry_add_all_to_flags_builder(flags_schema_builder_t *builder, option_mode_bitmask_t mode_mask)
Definition public_api.c:84

References ASCIICHAT_OK, and registry_add_all_to_flags_builder().

Referenced by action_create_manpage(), config_create_default(), and config_load_and_apply().