summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/til_settings.c42
-rw-r--r--src/til_settings.h1
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);
© All Rights Reserved