]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-settings: Add settings_parse_keyvalue()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 14 Nov 2016 23:36:57 +0000 (00:36 +0100)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 18 Nov 2016 11:55:49 +0000 (13:55 +0200)
src/lib-settings/settings-parser.c
src/lib-settings/settings-parser.h

index 0dc7d745bc91a86671009266ee65070b56acaaa0..7cdac05153829650e121b385b65e10a428ac00f4 100644 (file)
@@ -68,9 +68,6 @@ static const struct setting_parser_info strlist_info = {
 HASH_TABLE_DEFINE_TYPE(setting_link, struct setting_link *,
                       struct setting_link *);
 
-static int settings_parse_keyvalue(struct setting_parser_context *ctx,
-                                  const char *key, const char *value);
-
 static void
 setting_parser_copy_defaults(struct setting_parser_context *ctx, 
                             const struct setting_parser_info *info,
@@ -792,13 +789,16 @@ settings_parse_strlist(struct setting_parser_context *ctx,
        array_append(link->array, &vvalue, 1);
 }
 
-static int settings_parse_keyvalue(struct setting_parser_context *ctx,
-                                  const char *key, const char *value)
+int settings_parse_keyvalue(struct setting_parser_context *ctx,
+                           const char *key, const char *value)
 {
        const struct setting_define *def;
        struct setting_link *link;
        unsigned int n = 0;
 
+       ctx->error = NULL;
+       ctx->prev_info = NULL;
+
        if (!settings_find_key_nth(ctx, key, &n, &def, &link)) {
                ctx->error = p_strconcat(ctx->parser_pool,
                                         "Unknown setting: ", key, NULL);
@@ -886,9 +886,6 @@ int settings_parse_line(struct setting_parser_context *ctx, const char *line)
        const char *key, *value;
        int ret;
 
-       ctx->error = NULL;
-       ctx->prev_info = NULL;
-
        key = line;
        value = strchr(line, '=');
        if (value == NULL) {
index 25e6d6917c9430900430e4cacab9601836c7b9a7..7f9123a3ae855e1a25201904636f19288bd46420 100644 (file)
@@ -146,6 +146,9 @@ bool settings_parse_is_changed(struct setting_parser_context *ctx,
                               const char *key);
 /* Parse a single line. Returns 1 if OK, 0 if key is unknown, -1 if error. */
 int settings_parse_line(struct setting_parser_context *ctx, const char *line);
+/* Parse key/value pair. Returns 1 if OK, 0 if key is unknown, -1 if error. */
+int settings_parse_keyvalue(struct setting_parser_context *ctx,
+                           const char *key, const char *value);
 /* Parse data already read in input stream. */
 int settings_parse_stream(struct setting_parser_context *ctx,
                          struct istream *input);