diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-07-03 07:54:21 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-07-04 21:09:16 -0700 |
commit | 68f6dee32dea0fb1bfe40d901169cf68aa6528d0 (patch) | |
tree | 730141ca4c78f289886f45998406364525acae14 /src | |
parent | 6e9ae3e84486bdc90d6bc0a965ac2a977d438505 (diff) |
til_settings: add til_setting_desc_strprint_path() variant
There was only til_setting_desc_fprint_path() (for
setup_interactively()), but for rkt_scener this stuff has to go
out the socket and the queueing mechanism is built around
til_str_t so let's get a til_str_t-centric variant in there.
Diffstat (limited to 'src')
-rw-r--r-- | src/til_settings.c | 42 | ||||
-rw-r--r-- | src/til_settings.h | 1 |
2 files changed, 29 insertions, 14 deletions
diff --git a/src/til_settings.c b/src/til_settings.c index c546360..46224ef 100644 --- a/src/til_settings.c +++ b/src/til_settings.c @@ -475,23 +475,17 @@ til_setting_desc_t * til_setting_desc_free(const til_setting_desc_t *desc) } -int til_setting_desc_fprint_path(const til_setting_desc_t *desc, FILE *out) + +int til_setting_desc_strprint_path(const til_setting_desc_t *desc, til_str_t *str) { - til_str_t *str; - int r; + int r; assert(desc); - assert(out); - - str = til_str_new(""); - if (!str) - return -ENOMEM; + assert(str); r = til_settings_strprint_path(desc->container, str); - if (r < 0) { - til_str_free(str); + if (r < 0) return r; - } /* XXX: spec.as_label handling is done in til_settings_print_path() since it * must apply anywhere within a path, potentially in a recurring fashion. @@ -504,10 +498,30 @@ int til_setting_desc_fprint_path(const til_setting_desc_t *desc, FILE *out) */ if (desc->spec.key) { r = til_str_appendf(str, "/%s", desc->spec.key); - if (r < 0) { - til_str_free(str); + if (r < 0) return r; - } + } + + return 0; +} + + +int til_setting_desc_fprint_path(const til_setting_desc_t *desc, FILE *out) +{ + til_str_t *str; + int r; + + assert(desc); + assert(out); + + str = til_str_new(""); + if (!str) + return -ENOMEM; + + r = til_setting_desc_strprint_path(desc, str); + if (r < 0) { + til_str_free(str); + return r; } if (fputs(til_str_buf(str, NULL), out) == EOF) diff --git a/src/til_settings.h b/src/til_settings.h index 6d14d20..77811f1 100644 --- a/src/til_settings.h +++ b/src/til_settings.h @@ -60,6 +60,7 @@ int til_settings_apply_desc_generators(const til_settings_t *settings, const til int til_setting_desc_new(const til_settings_t *settings, const til_setting_spec_t *spec, const til_setting_desc_t **res_desc); 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_settings_label_setting(const til_settings_t *settings, const til_setting_t *setting, char **res_label); |