]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings: Add settings_file_has_path()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 9 Feb 2024 21:33:00 +0000 (23:33 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:12 +0000 (12:34 +0200)
src/lib-settings/settings-parser.c
src/lib-settings/settings-parser.h

index d18168f12e5d8f44565d99093cac2cf7c2a19e9c..b18e81523b58da0ebddb48f1556704d53f8eee23 100644 (file)
@@ -463,6 +463,15 @@ void settings_file_get(const char *value, pool_t path_pool,
        file_r->content = p + 1;
 }
 
+bool settings_file_has_path(const char *value)
+{
+       /* value must be in <path><LF><content> format */
+       const char *p = strchr(value, '\n');
+       if (p == NULL)
+               i_panic("Settings file value is missing LF");
+       return p != value;
+}
+
 const char *settings_file_get_value(pool_t pool,
                                    const struct settings_file *file)
 {
index 10e87320e682d3731d2fd10bb12c6c5a18dc8035..ac7730a3ae65a02f7f3475f41756be9011cc0eca 100644 (file)
@@ -256,6 +256,9 @@ const char *const *settings_boollist_get(const ARRAY_TYPE(const_string) *array);
    the path_pool, while content points directly to the value string. */
 void settings_file_get(const char *value, pool_t path_pool,
                       struct settings_file *file_r);
+/* Returns TRUE if the settings value contains a non-empty path. The value
+   is expected to be in the SET_FILE format (path LF content). */
+bool settings_file_has_path(const char *value);
 /* Convert settings_file into a value (path LF content). The file path may be
    NULL, but the content must exist. */
 const char *settings_file_get_value(pool_t pool,