]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Replace settings_get_time*() with str_parse_get_interval*() in project
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Wed, 26 Oct 2022 15:12:27 +0000 (17:12 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 21 Nov 2022 17:50:26 +0000 (17:50 +0000)
src/lib-auth/auth-proxy.c
src/lib-settings/settings-parser.c
src/lib-settings/settings-parser.h
src/lib-sql/driver-cassandra.c
src/lib-storage/mail-storage.c
src/login-common/client-common-auth.c
src/plugins/fts-flatcurve/fts-flatcurve-plugin.c
src/plugins/fts/fts-indexer.c
src/plugins/push-notification/push-notification-driver-ox.c

index 751b48018af24dc41aeab3e749e59bd55c59dd75..46660872f84e53fbf48fb6242e0c006d2340ced6 100644 (file)
@@ -1,7 +1,7 @@
 /* Copyright (c) 2021 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
-#include "settings-parser.h"
+#include "str-parse.h"
 #include "auth-proxy.h"
 
 static const char *maybe_strdup(pool_t pool, const char *str)
@@ -60,7 +60,7 @@ int auth_proxy_settings_parse(struct auth_proxy_settings *set, pool_t pool,
                /* backwards compatibility: plain number is seconds */
                if (str_to_uint(value, &set->timeout_msecs) == 0)
                        set->timeout_msecs *= 1000;
-               else if (settings_get_time_msecs(value,
+               else if (str_parse_get_interval_msecs(value,
                                &set->timeout_msecs, error_r) < 0) {
                        return -1;
                }
index 8013c6e0cfbbbd4054b954f3e6fa6117860310ee..8bec3af5a443117b38e6d79bc515c2246652c45c 100644 (file)
@@ -339,18 +339,6 @@ get_octal(struct setting_parser_context *ctx, const char *value,
        return 0;
 }
 
-int settings_get_time(const char *str, unsigned int *secs_r,
-                     const char **error_r)
-{
-       return str_parse_get_interval(str, secs_r, error_r);
-}
-
-int settings_get_time_msecs(const char *str, unsigned int *msecs_r,
-                           const char **error_r)
-{
-       return str_parse_get_interval_msecs(str, msecs_r, error_r);
-}
-
 static int get_enum(struct setting_parser_context *ctx, const char *value,
                    char **result_r, const char *allowed_values)
 {
@@ -525,13 +513,13 @@ settings_parse(struct setting_parser_context *ctx, struct setting_link *link,
                        return -1;
                break;
        case SET_TIME:
-               if (settings_get_time(value, (unsigned int *)ptr, &error) < 0) {
+               if (str_parse_get_interval(value, (unsigned int *)ptr, &error) < 0) {
                        ctx->error = p_strdup(ctx->parser_pool, error);
                        return -1;
                }
                break;
        case SET_TIME_MSECS:
-               if (settings_get_time_msecs(value, (unsigned int *)ptr, &error) < 0) {
+               if (str_parse_get_interval_msecs(value, (unsigned int *)ptr, &error) < 0) {
                        ctx->error = p_strdup(ctx->parser_pool, error);
                        return -1;
                }
index c2279265fd3538823c44ea7030940b460095b6e1..208540179db304425a070d2bebd8be7256ebaaec 100644 (file)
@@ -270,12 +270,6 @@ int settings_parser_apply_changes(struct setting_parser_context *dest,
 
 /* Return section name escaped */
 const char *settings_section_escape(const char *name);
-/* Parse time interval string, return as seconds. */
-int settings_get_time(const char *str, unsigned int *secs_r,
-                     const char **error_r);
-/* Parse time interval string, return as milliseconds. */
-int settings_get_time_msecs(const char *str, unsigned int *msecs_r,
-                           const char **error_r);
 
 void set_config_binary(bool value);
 bool is_config_binary(void);
index 16015b062a1971248acdbfa70494b9fe049a47b9..1b60ba7981ca7a5c3d0ffa09e3c7e6198262b51c 100644 (file)
@@ -6,13 +6,13 @@
 #include "hostpid.h"
 #include "hex-binary.h"
 #include "str.h"
+#include "str-parse.h"
 #include "ioloop.h"
 #include "net.h"
 #include "write-full.h"
 #include "time-util.h"
 #include "var-expand.h"
 #include "safe-memset.h"
-#include "settings-parser.h"
 #include "sql-api-private.h"
 
 #ifdef BUILD_CASSANDRA
@@ -721,43 +721,43 @@ static int driver_cassandra_parse_connect_string(struct cassandra_db *db,
                                return -1;
                        }
                } else if (strcmp(key, "heartbeat_interval") == 0) {
-                       if (settings_get_time(value, &db->heartbeat_interval_secs,
-                                             &error) < 0) {
+                       if (str_parse_get_interval(value, &db->heartbeat_interval_secs,
+                                                  &error) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid heartbeat_interval '%s': %s",
                                        value, error);
                                return -1;
                        }
                } else if (strcmp(key, "idle_timeout") == 0) {
-                       if (settings_get_time(value, &db->idle_timeout_secs,
-                                             &error) < 0) {
+                       if (str_parse_get_interval(value, &db->idle_timeout_secs,
+                                                  &error) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid idle_timeout '%s': %s",
                                        value, error);
                                return -1;
                        }
                } else if (strcmp(key, "connect_timeout") == 0) {
-                       if (settings_get_time_msecs(value,
-                                                   &db->connect_timeout_msecs,
-                                                   &error) < 0) {
+                       if (str_parse_get_interval_msecs(value,
+                                                        &db->connect_timeout_msecs,
+                                                        &error) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid connect_timeout '%s': %s",
                                        value, error);
                                return -1;
                        }
                } else if (strcmp(key, "request_timeout") == 0) {
-                       if (settings_get_time_msecs(value,
-                                                   &db->request_timeout_msecs,
-                                                   &error) < 0) {
+                       if (str_parse_get_interval_msecs(value,
+                                                        &db->request_timeout_msecs,
+                                                        &error) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid request_timeout '%s': %s",
                                        value, error);
                                return -1;
                        }
                } else if (strcmp(key, "warn_timeout") == 0) {
-                       if (settings_get_time_msecs(value,
-                                                   &db->warn_timeout_msecs,
-                                                   &error) < 0) {
+                       if (str_parse_get_interval_msecs(value,
+                                                        &db->warn_timeout_msecs,
+                                                        &error) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid warn_timeout '%s': %s",
                                        value, error);
@@ -767,9 +767,9 @@ static int driver_cassandra_parse_connect_string(struct cassandra_db *db,
                        i_free(db->metrics_path);
                        db->metrics_path = i_strdup(value);
                } else if (strcmp(key, "execution_retry_interval") == 0) {
-                       if (settings_get_time_msecs(value,
-                                                   &db->execution_retry_interval_msecs,
-                                                   &error) < 0) {
+                       if (str_parse_get_interval_msecs(value,
+                                                        &db->execution_retry_interval_msecs,
+                                                        &error) < 0) {
                                *error_r = t_strdup_printf(
                                        "Invalid execution_retry_interval '%s': %s",
                                        value, error);
index a37ce308528b72600c57fadc21d8b6c1abd58659..05ce59d48fae46910c7ef84f8eface2d2b4d92f6 100644 (file)
@@ -6,6 +6,7 @@
 #include "llist.h"
 #include "mail-storage.h"
 #include "str.h"
+#include "str-parse.h"
 #include "sha1.h"
 #include "unichar.h"
 #include "hex-binary.h"
@@ -20,7 +21,6 @@
 #include "var-expand.h"
 #include "dsasl-client.h"
 #include "imap-date.h"
-#include "settings-parser.h"
 #include "mail-index-private.h"
 #include "mail-index-alloc-cache.h"
 #include "mailbox-tree.h"
@@ -3237,7 +3237,7 @@ int mail_parse_human_timestamp(const char *str, time_t *timestamp_r,
                /* unix timestamp */
                *utc_r = TRUE;
                return 0;
-       } else if (settings_get_time(str, &secs, &error) == 0) {
+       } else if (str_parse_get_interval(str, &secs, &error) == 0) {
                *timestamp_r = ioloop_time - secs;
                *utc_r = TRUE;
                return 0;
index 6e003b74b1eb2ff4b44fd4da493b321e6c0cdac3..b9e1ab9883f0263febb40deb6143f2d597c53cb7 100644 (file)
@@ -8,9 +8,9 @@
 #include "ostream.h"
 #include "str.h"
 #include "strescape.h"
+#include "str-parse.h"
 #include "safe-memset.h"
 #include "time-util.h"
-#include "settings-parser.h"
 #include "login-proxy.h"
 #include "auth-client.h"
 #include "dsasl-client.h"
@@ -171,7 +171,7 @@ static bool client_auth_parse_args(const struct client *client, bool success,
                } else if (strcmp(key, "reason") == 0)
                        reply_r->reason = value;
                else if (strcmp(key, "proxy_host_immediate_failure_after") == 0) {
-                       if (settings_get_time(value,
+                       if (str_parse_get_interval(value,
                                &reply_r->proxy_host_immediate_failure_after_secs,
                                &error) < 0) {
                                e_error(client->event,
index bf19eb92fa16130f2066cd0a537288cbd4ff3bd2..940058eea9a976c87ae44b23705c24df940c322a 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "lib.h"
 #include "mail-storage-hooks.h"
-#include "settings-parser.h"
+#include "str-parse.h"
 #include "fts-user.h"
 #include "fts-backend-flatcurve.h"
 #include "fts-backend-flatcurve-xapian.h"
@@ -111,7 +111,7 @@ fts_flatcurve_plugin_init_settings(struct mail_user *user,
        pset = mail_user_plugin_getenv(user, FTS_FLATCURVE_PLUGIN_ROTATE_TIME);
        if (pset != NULL) {
                const char *error;
-               if (settings_get_time_msecs(pset, &val, &error) < 0) {
+               if (str_parse_get_interval_msecs(pset, &val, &error) < 0) {
                        *error_r = t_strdup_printf("Invalid %s: %s",
                                FTS_FLATCURVE_PLUGIN_ROTATE_TIME, error);
                        return -1;
index 73ff6a7bfb24c4925055e25a6bdadc9a79f0f3c0..79d4a4d7af543bc827fc1803c1cb137f7d78e660 100644 (file)
@@ -8,7 +8,7 @@
 #include "ostream.h"
 #include "strescape.h"
 #include "time-util.h"
-#include "settings-parser.h"
+#include "str-parse.h"
 #include "mail-user.h"
 #include "mail-storage-private.h"
 #include "fts-api.h"
@@ -231,7 +231,7 @@ int fts_indexer_init(struct fts_backend *backend, struct mailbox *box,
 
        value = mail_user_plugin_getenv(box->storage->user, "fts_index_timeout");
        if (value != NULL) {
-               if (settings_get_time(value, &timeout_secs, &error) < 0) {
+               if (str_parse_get_interval(value, &timeout_secs, &error) < 0) {
                        e_error(box->storage->user->event,
                                "Invalid fts_index_timeout setting: %s",
                                error);
index 962ee54758140aed2c9bd9af3e6ef3359a107394..f2e19ae9718cb1a1eb3c0578cdd4788d6d1360d5 100644 (file)
@@ -6,12 +6,12 @@
 #include "http-url.h"
 #include "ioloop.h"
 #include "istream.h"
-#include "settings-parser.h"
 #include "json-parser.h"
 #include "mailbox-attribute.h"
 #include "mail-storage-private.h"
 #include "str.h"
 #include "strescape.h"
+#include "str-parse.h"
 #include "iostream-ssl.h"
 
 #include "push-notification-plugin.h"
@@ -117,7 +117,7 @@ push_notification_driver_ox_init(struct push_notification_driver_config *config,
        if (tmp == NULL) {
                dconfig->cached_ox_metadata_lifetime_secs =
                        DEFAULT_CACHE_LIFETIME_SECS;
-       } else if (settings_get_time(
+       } else if (str_parse_get_interval(
                tmp, &dconfig->cached_ox_metadata_lifetime_secs, &error) < 0) {
                event_unref(&dconfig->event);
                *error_r = t_strdup_printf(