/* 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)
/* 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;
}
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)
{
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;
}
/* 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);
#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
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);
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);
#include "llist.h"
#include "mail-storage.h"
#include "str.h"
+#include "str-parse.h"
#include "sha1.h"
#include "unichar.h"
#include "hex-binary.h"
#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"
/* 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;
#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"
} 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,
#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"
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;
#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"
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);
#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"
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(