summaryrefslogtreecommitdiff
path: root/src/til_settings.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-03 00:55:59 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-03 00:55:59 -0700
commit81f6fd2208cbed6ac8f7e77b2f0b8dd7ac741fe3 (patch)
treefccb815ca92e9983f086f3c39ddcd05c3a5f38f8 /src/til_settings.h
parent70cc48ba418d69127e3a1d82415785c5964d9448 (diff)
til_settings: introduce til_setting_t.nocheck
This adds a setting value syntax for bypassing checks; ':' prefix e.g. --module=:experimental_module Would result in the value experimental_module added, and no verification performed of its presence in the module setting's values list. Two new til_settings api functions are introduced as well for setting and getting the raw values including any prefix syntax: til_setting_get_raw_value() til_setting_set_raw_value() these are needed because the til_setting_t.value member will continue to point at the "cooked" form of the value with the prefix stripped out, so the general cases of needing the value won't have to worry about the presence of prefixes. They have the til_setting_t.nocheck member to see if the setting was a nocheck-prefixed value. The nocheck prefix is preserved across serialization as well. So using a serialized form to seed a derivative settings instance won't spuriously start failing checks because the ':' prefixes are gone where they were necessary. They'll be kept wherever they were previously. There will probably be some more random fixes needed here and there where code is directly manipulating til_setting_t.value and must now go through the "raw" getter/setter api.
Diffstat (limited to 'src/til_settings.h')
-rw-r--r--src/til_settings.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/til_settings.h b/src/til_settings.h
index 85df105..95b2ac4 100644
--- a/src/til_settings.h
+++ b/src/til_settings.h
@@ -43,6 +43,7 @@ struct til_setting_t {
const char *value;
const til_setting_desc_t *desc;
void *user_data;
+ unsigned nocheck:1; /* set when user explicitly set the value outside the guards */
};
til_settings_t * til_settings_new(const char *prefix, const til_settings_t *parent, const char *label, const char *settings);
@@ -65,6 +66,8 @@ til_setting_desc_t * til_setting_desc_free(const til_setting_desc_t *desc);
int til_setting_desc_strprint_path(const til_setting_desc_t *desc, til_str_t *str);
int til_setting_desc_fprint_path(const til_setting_desc_t *desc, FILE *out);
int til_setting_spec_check(const til_setting_spec_t *spec, const char *value);
+int til_setting_set_raw_value(til_setting_t *setting, const char *value);
+const char * til_setting_get_raw_value(til_setting_t *setting);
int til_settings_label_setting(const til_settings_t *settings, const til_setting_t *setting, char **res_label);
int til_settings_strprint_path(const til_settings_t *settings, til_str_t *str);
int til_settings_fprint_path(const til_settings_t *settings, FILE *out);
© All Rights Reserved