#include "ioloop.h"
#include "array.h"
#include "str.h"
-#include "var-expand.h"
+#include "var-expand-new.h"
#include "wildcard-match.h"
#include "settings-parser.h"
#include "master-service.h"
json_output, userdb_fields, show_field);
} else {
string_t *str = t_str_new(128);
- if (var_expand_with_funcs(str, expand_field,
- mail_user_var_expand_table(user),
- mail_user_var_expand_func_table, user,
- &error) <= 0) {
+ const struct var_expand_params *params =
+ mail_user_var_expand_params(user);
+ if (var_expand_new(str, expand_field, params, &error) < 0) {
json_ostream_nwritef_string(json_output,
"error", "Failed to expand field: %s", error);
} else {
#include "hex-binary.h"
#include "str.h"
#include "strescape.h"
-#include "var-expand.h"
+#include "var-expand-new.h"
#include "wildcard-match.h"
#include "dsasl-client.h"
#include "settings-parser.h"
cmd_user_mail_print_fields(input, user, userdb_fields, show_field);
} else {
string_t *str = t_str_new(128);
- if (var_expand_with_funcs(str, expand_field,
- mail_user_var_expand_table(user),
- mail_user_var_expand_func_table, user,
- &error) <= 0) {
+ const struct var_expand_params *params =
+ mail_user_var_expand_params(user);
+ if (var_expand_new(str, expand_field, params, &error) < 0) {
e_error(event, "Failed to expand %s: %s", expand_field, error);
} else {
printf("%s\n", str_c(str));
#include "strescape.h"
#include "str-parse.h"
#include "env-util.h"
-#include "var-expand.h"
+#include "var-expand-new.h"
#include "process-title.h"
#include "settings.h"
#include "imap-util.h"
get_ssh_cmd_args(const char *host, const char *login, const char *mail_user,
struct event *event)
{
- static struct var_expand_table static_tab[] = {
- { 'u', NULL, "user" },
- { '\0', NULL, "login" },
- { '\0', NULL, "host" },
- { '\0', NULL, NULL }
+ static const struct var_expand_table static_tab[] = {
+ { .key = "user", .value = NULL },
+ { .key = "login", .value = NULL },
+ { .key = "host", .value = NULL },
+ VAR_EXPAND_TABLE_END
+ };
+ static const struct var_expand_params static_params = {
+ .table = static_tab
};
struct var_expand_table *tab;
ARRAY_TYPE(const_string) cmd_args;
tab[0].value = mail_user;
tab[1].value = login;
tab[2].value = host;
+ const struct var_expand_params params = {
+ .table = tab,
+ .event = event,
+ };
t_array_init(&cmd_args, 8);
str = t_str_new(128);
if (strchr(*args, '%') == NULL)
value = *args;
else {
- /* some automation: if parameter's all %variables
- expand to empty, but the %variable isn't the only
+ /* some automation: if parameter's all %{variables}
+ expand to empty, but the %{variable} isn't the only
text in the parameter, skip it. */
str_truncate(str, 0);
str_truncate(str2, 0);
- if (var_expand_with_table(str, *args, tab, &error) <= 0 ||
- var_expand_with_table(str2, *args, static_tab, &error) <= 0) {
+ if (var_expand_new(str, *args, ¶ms, &error) < 0 ||
+ var_expand_new(str2, *args, &static_params, &error) < 0) {
e_error(event,
"Failed to expand dsync_remote_cmd=%s: %s",
*args, error);
#include "doveadm-print.h"
#include "doveadm-print-private.h"
#include "client-connection.h"
-#include "var-expand.h"
+#include "var-expand-new.h"
struct doveadm_print_formatted_context {
pool_t pool;
{
struct var_expand_table entry;
i_zero(&entry);
- entry.key = '\0';
- entry.long_key = p_strdup(ctx.pool, hdr->key);
+ entry.key = p_strdup(ctx.pool, hdr->key);
entry.value = NULL;
array_push_back(&ctx.headers, &entry);
}
entry->value = value;
if (ctx.idx >= array_count(&ctx.headers)) {
- if (var_expand_with_table(ctx.buf, ctx.format,
- array_front(&ctx.headers),
- &error) <= 0) {
+ const struct var_expand_params params = {
+ .table = array_front(&ctx.headers),
+ };
+ if (var_expand_new(ctx.buf, ctx.format, ¶ms, &error) < 0) {
i_error("Failed to expand print format '%s': %s",
ctx.format, error);
}
.doveadm_password = "",
.doveadm_allowed_commands = ARRAY_INIT,
.dsync_alt_char = "_",
- .dsync_remote_cmd = "ssh -l%{login} %{host} doveadm dsync-server -u%u -U",
+ .dsync_remote_cmd = "ssh -l%{login} %{host} doveadm dsync-server -u%{user} -U",
.dsync_features = "",
.dsync_hashed_headers = "Date Message-ID",
.dsync_commit_msgs_interval = 100,