summaryrefslogtreecommitdiff
path: root/src/til_settings.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-07-03 07:54:21 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-07-04 21:09:16 -0700
commit68f6dee32dea0fb1bfe40d901169cf68aa6528d0 (patch)
tree730141ca4c78f289886f45998406364525acae14 /src/til_settings.c
parent6e9ae3e84486bdc90d6bc0a965ac2a977d438505 (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/til_settings.c')
-rw-r--r--src/til_settings.c42
1 files changed, 28 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)
© All Rights Reserved