From 401cfce3ebb205e46b4582fc6be1a0d42e213d31 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 2 Jun 2023 18:06:33 -0700 Subject: til_settings,setup: introduce til_setting_spec_t.override() In situations where modules wish to alias setting values like expanding "all" -> "mod0,mod1,mod2,mod3" they need a way to intercept the value-acceptance @ desc-assignment time in the front-end. This optional override() function does just that when present in the spec. The current setting's value is passed to the override, and if what's returned differs from what was passed (by pointer value), then the current value is freed and the override takes its place. The override function is expected to _always_ return non-NULL; either the value provided, or a newly allocated value override. The override function must never free the supplied value, that's the front-end's job in applying the override. The override() must return NULL on errors, which are assumed to be limited to ENOMEM failures. --- src/til_settings.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/til_settings.c') diff --git a/src/til_settings.c b/src/til_settings.c index 08098d5..2811b72 100644 --- a/src/til_settings.c +++ b/src/til_settings.c @@ -407,6 +407,7 @@ int til_setting_desc_new(const til_settings_t *settings, const til_setting_spec_ } d->spec.random = spec->random; + d->spec.override = spec->override; d->spec.as_nested_settings = spec->as_nested_settings; d->spec.as_label = spec->as_label; -- cgit v1.2.1