Coverage Report

Created: 2026-09-03 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dovecot/src/lib-var-expand/var-expand.h
Line
Count
Source
1
#ifndef VAR_EXPAND_NEW_H
2
#define VAR_EXPAND_NEW_H
3
4
/** Variable expansion programs **
5
6
  A variable expansion program is a set of filters delineated with %{},
7
  or a literal-only program which expands to the string it contains.
8
  See https://doc.dovecot.org/latest/core/settings/syntax.html#variable-expansion.
9
10
  The normal usage is to call t_var_expand() to get rendition of a program from
11
  data stack memory, or var_expand() if you want to provide the string yourself.
12
  The string is appended to, or truncated to where it was on starting on failure.
13
14
  If you need to expand the program multiple times, you should use
15
  var_expand_program_create() to create a reusable program chain and then call
16
  var_expand_program_execute() to expand it. Since parameters are given to execute
17
  you can get the same program executed with different parameters, so you don't
18
  have to rebuild the program if your variables are changed.
19
20
  The function var_expand_program_create() parses a string that can contain
21
  one or more programs, and chains them together. This is usually what is wanted.
22
23
  There are some cases though when you need to deal with programs one by one,
24
  and this is handled by 'var-expand-split.h', and there are a few functions here
25
  that do not seem to make much sense alone:
26
27
  The var_expand_program_execute_one() and var_expand_program_has_variable() are
28
  such ones. The execute_one() only makes sense to use with individual programs
29
  that can be extracted with var_expand_program_template() or
30
  var_expand_program_split(), which are in their own header as they have
31
  array.h dependency.
32
33
  The var_expand_program_has_variable() can be used for generic purposes too
34
  by leaving the first_program_only as FALSE.
35
*/
36
37
/* Used for getting either prefix:key values, or dynamic values for keys
38
   in value tables.
39
40
   Gets key and context, needs to return -1 on error (with error_r set)
41
   or 0 on success. value_r *must* be non-null on success.
42
43
   Prefix is removed before calling the function.
44
*/
45
typedef int value_provider_func_t(const char *key, const char **value_r,
46
          void *context, const char **error_r);
47
/* Used for escaping values. On success sets output_r and returns 0.
48
   On failure sets error_r and returns -1. */
49
typedef int var_expand_escape_func_t(const char *input, const char **output_r,
50
             void *context, const char **error_r);
51
52
struct var_expand_parser_state;
53
struct var_expand_program;
54
55
0
#define VAR_EXPAND_TABLE_END { .key = NULL }
56
0
#define VAR_EXPAND_CONTEXTS_END (void*)var_expand_contexts_end
57
58
struct var_expand_table {
59
  /* Key name, as in %{key} */
60
  const char *key;
61
  /* Value to expand into */
62
  const char *value;
63
  /* Or function that provides the value */
64
  value_provider_func_t *func;
65
};
66
67
struct var_expand_provider {
68
  /* key as in %{key:name} */
69
  const char *key;
70
  /* function to call to get value */
71
  value_provider_func_t *func;
72
};
73
74
extern const void *const var_expand_contexts_end;
75
76
struct var_expand_params {
77
  /* Variables to use, must end with VAR_EXPAND_TABLE_END,
78
     asserts that tables_arr is non-NULL. */
79
  const struct var_expand_table *table;
80
  /* Providers to use, must end with VAR_EXPAND_TABLE_END,
81
     asserts that providers_arr is non-NULL. */
82
  const struct var_expand_provider *providers;
83
  /* Multiple var expand tables, must be NULL terminated */
84
  const struct var_expand_table *const *tables_arr;
85
  /* Multiple var expand providers, must be NULL terminated */
86
  const struct var_expand_provider *const *providers_arr;
87
  /* Function that gets called to escape values */
88
  var_expand_escape_func_t *escape_func;
89
  /* Context for escape function */
90
  void *escape_context;
91
  /* Contexts for table functions and providers, can be
92
     set to NULL if no multiple contexts are needed, then context
93
     is defaulted to.
94
95
     Asserts that contexts ends with VAR_EXPAND_CONTEXTS_END.
96
  */
97
  void *const *contexts;
98
  /* Context for table functions and providers. */
99
  void *context;
100
  /* Event for %{event:} expansion, can be NULL. Global event
101
     will be attempted if this is NULL. */
102
  struct event *event;
103
};
104
105
/* Creates a new expansion program for reusing */
106
int var_expand_program_create(const char *str, struct var_expand_program **program_r,
107
            const char **error_r);
108
/* Lists all seen variables in a program */
109
const char *const *var_expand_program_variables(const struct var_expand_program *program);
110
/* Checks if the program has a variable, if first_program_only is set, checks the
111
  first program only, otherwise it checks the variables using var_expand_program_variables().
112
113
  The check is done to all filters and parameters on the first program, so it can detect
114
  if the variable is used anywhere in the program.
115
*/
116
bool var_expand_program_has_variable(const struct var_expand_program *program,
117
             const char *variable, bool first_program_only);
118
/* Dumps the program into a dest for debugging */
119
void var_expand_program_dump(const struct var_expand_program *program, string_t *dest);
120
/* Executes the program with given params. Params can be left NULL, in which case
121
   empty parameters are used. */
122
int var_expand_program_execute(string_t *dest, const struct var_expand_program *program,
123
             const struct var_expand_params *params,
124
             const char **error_r) ATTR_NULL(3);
125
/* Execute the first program only */
126
int var_expand_program_execute_one(string_t *dest, const struct var_expand_program *program,
127
           const struct var_expand_params *params,
128
           const char **error_r);
129
/* Free up program */
130
void var_expand_program_free(struct var_expand_program **_program);
131
132
/* Creates a new program, executes it and frees it. Params can be left NULL, in which
133
   case empty parameters are used. */
134
int var_expand(string_t *dest, const char *str, const struct var_expand_params *params,
135
         const char **error_r) ATTR_NULL(3);
136
137
/* Wrapper for var_expand(), places the result into result_r. */
138
int t_var_expand(const char *str, const struct var_expand_params *params,
139
     const char **result_r, const char **error_r);
140
141
/* Merge two tables together, keys in table a will be overwritten with keys
142
 * from table b in collision. */
143
struct var_expand_table *
144
var_expand_merge_tables(pool_t pool, const struct var_expand_table *a,
145
      const struct var_expand_table *b);
146
147
/* Returns true if provider is a built-in provider */
148
bool var_expand_provider_is_builtin(const char *prefix);
149
150
/* Provides size of a table */
151
static inline size_t ATTR_PURE
152
var_expand_table_size(const struct var_expand_table *table)
153
0
{
154
0
  size_t n = 0;
155
0
  while (table != NULL && table[n].key != NULL)
156
0
     n++;
157
0
  return n;
158
0
}
Unexecuted instantiation: testsuite-settings.c:var_expand_table_size
Unexecuted instantiation: testsuite-script.c:var_expand_table_size
Unexecuted instantiation: fuzzsuite.c:var_expand_table_size
Unexecuted instantiation: sieve-settings.c:var_expand_table_size
Unexecuted instantiation: sieve-storage.c:var_expand_table_size
Unexecuted instantiation: sieve-storage-settings.c:var_expand_table_size
Unexecuted instantiation: sieve-result.c:var_expand_table_size
Unexecuted instantiation: sieve-error.c:var_expand_table_size
Unexecuted instantiation: sieve.c:var_expand_table_size
Unexecuted instantiation: sieve-file-storage-settings.c:var_expand_table_size
Unexecuted instantiation: sieve-file-storage.c:var_expand_table_size
Unexecuted instantiation: sieve-dict-storage.c:var_expand_table_size
Unexecuted instantiation: ext-vacation-settings.c:var_expand_table_size
Unexecuted instantiation: ext-subaddress-settings.c:var_expand_table_size
Unexecuted instantiation: ext-subaddress.c:var_expand_table_size
Unexecuted instantiation: ext-include-settings.c:var_expand_table_size
Unexecuted instantiation: ext-variables-settings.c:var_expand_table_size
Unexecuted instantiation: ext-enotify.c:var_expand_table_size
Unexecuted instantiation: ntfy-mailto-settings.c:var_expand_table_size
Unexecuted instantiation: ext-spamvirustest-settings.c:var_expand_table_size
Unexecuted instantiation: ext-editheader-settings.c:var_expand_table_size
Unexecuted instantiation: ext-duplicate-settings.c:var_expand_table_size
Unexecuted instantiation: ext-extlists-settings.c:var_expand_table_size
Unexecuted instantiation: ext-vnd-environment-settings.c:var_expand_table_size
Unexecuted instantiation: ext-vnd-environment.c:var_expand_table_size
Unexecuted instantiation: ext-vnd-report-settings.c:var_expand_table_size
Unexecuted instantiation: cmd-vacation.c:var_expand_table_size
Unexecuted instantiation: ext-vacation-common.c:var_expand_table_size
Unexecuted instantiation: ext-include-common.c:var_expand_table_size
Unexecuted instantiation: ext-variables-common.c:var_expand_table_size
Unexecuted instantiation: ext-enotify-settings.c:var_expand_table_size
Unexecuted instantiation: ntfy-mailto.c:var_expand_table_size
Unexecuted instantiation: ext-spamvirustest-common.c:var_expand_table_size
Unexecuted instantiation: ext-editheader-common.c:var_expand_table_size
Unexecuted instantiation: ext-duplicate-common.c:var_expand_table_size
Unexecuted instantiation: ext-extlists-common.c:var_expand_table_size
Unexecuted instantiation: ext-vnd-report-common.c:var_expand_table_size
Unexecuted instantiation: sieve-tool.c:var_expand_table_size
Unexecuted instantiation: mail-namespace.c:var_expand_table_size
Unexecuted instantiation: mail-storage-service.c:var_expand_table_size
Unexecuted instantiation: mail-storage-settings.c:var_expand_table_size
Unexecuted instantiation: mail-storage.c:var_expand_table_size
Unexecuted instantiation: mail-user.c:var_expand_table_size
Unexecuted instantiation: mailbox-attribute.c:var_expand_table_size
Unexecuted instantiation: mailbox-list-iter.c:var_expand_table_size
Unexecuted instantiation: mailbox-list.c:var_expand_table_size
Unexecuted instantiation: shared-storage.c:var_expand_table_size
Unexecuted instantiation: imapc-list.c:var_expand_table_size
Unexecuted instantiation: imapc-storage.c:var_expand_table_size
Unexecuted instantiation: index-attribute.c:var_expand_table_size
Unexecuted instantiation: maildir-storage.c:var_expand_table_size
Unexecuted instantiation: mbox-storage.c:var_expand_table_size
Unexecuted instantiation: mdbox-storage.c:var_expand_table_size
Unexecuted instantiation: pop3c-storage.c:var_expand_table_size
Unexecuted instantiation: dbox-storage.c:var_expand_table_size
Unexecuted instantiation: imapc-client.c:var_expand_table_size
Unexecuted instantiation: imapc-connection.c:var_expand_table_size
Unexecuted instantiation: mbox-lock.c:var_expand_table_size
Unexecuted instantiation: pop3c-client.c:var_expand_table_size
Unexecuted instantiation: expansion-program.c:var_expand_table_size
Unexecuted instantiation: expansion-statement.c:var_expand_table_size
Unexecuted instantiation: var-expand-lexer.c:var_expand_table_size
Unexecuted instantiation: var-expand-parser.c:var_expand_table_size
Unexecuted instantiation: var-expand.c:var_expand_table_size
Unexecuted instantiation: master-service-settings.c:var_expand_table_size
Unexecuted instantiation: master-service.c:var_expand_table_size
Unexecuted instantiation: settings-parser.c:var_expand_table_size
Unexecuted instantiation: settings.c:var_expand_table_size
Unexecuted instantiation: fs-api.c:var_expand_table_size
Unexecuted instantiation: fs-dict.c:var_expand_table_size
Unexecuted instantiation: fs-posix.c:var_expand_table_size
Unexecuted instantiation: fs-randomfail.c:var_expand_table_size
Unexecuted instantiation: fs-sis-queue.c:var_expand_table_size
Unexecuted instantiation: dict-file.c:var_expand_table_size
Unexecuted instantiation: dict-redis.c:var_expand_table_size
Unexecuted instantiation: dict.c:var_expand_table_size
Unexecuted instantiation: dns-lookup.c:var_expand_table_size
Unexecuted instantiation: iostream-ssl.c:var_expand_table_size
Unexecuted instantiation: ssl-settings.c:var_expand_table_size
Unexecuted instantiation: dict-client.c:var_expand_table_size
Unexecuted instantiation: expansion-filter.c:var_expand_table_size
Unexecuted instantiation: expansion-parameter.c:var_expand_table_size
Unexecuted instantiation: master-service-ssl.c:var_expand_table_size
Unexecuted instantiation: iostream-ssl-context-cache.c:var_expand_table_size
Unexecuted instantiation: expansion-filter-crypt.c:var_expand_table_size
Unexecuted instantiation: expansion-filter-if.c:var_expand_table_size
159
160
/* Get table entry by name. Returns NULL if not found. */
161
static inline struct var_expand_table *
162
var_expand_table_get(struct var_expand_table *table, const char *key)
163
0
{
164
0
  for (size_t i = 0; table[i].key != NULL; i++) {
165
0
    if (strcmp(table[i].key, key) == 0) {
166
0
      return &(table[i]);
167
0
    }
168
0
  }
169
0
  return NULL;
170
0
}
Unexecuted instantiation: testsuite-settings.c:var_expand_table_get
Unexecuted instantiation: testsuite-script.c:var_expand_table_get
Unexecuted instantiation: fuzzsuite.c:var_expand_table_get
Unexecuted instantiation: sieve-settings.c:var_expand_table_get
Unexecuted instantiation: sieve-storage.c:var_expand_table_get
Unexecuted instantiation: sieve-storage-settings.c:var_expand_table_get
Unexecuted instantiation: sieve-result.c:var_expand_table_get
Unexecuted instantiation: sieve-error.c:var_expand_table_get
Unexecuted instantiation: sieve.c:var_expand_table_get
Unexecuted instantiation: sieve-file-storage-settings.c:var_expand_table_get
Unexecuted instantiation: sieve-file-storage.c:var_expand_table_get
Unexecuted instantiation: sieve-dict-storage.c:var_expand_table_get
Unexecuted instantiation: ext-vacation-settings.c:var_expand_table_get
Unexecuted instantiation: ext-subaddress-settings.c:var_expand_table_get
Unexecuted instantiation: ext-subaddress.c:var_expand_table_get
Unexecuted instantiation: ext-include-settings.c:var_expand_table_get
Unexecuted instantiation: ext-variables-settings.c:var_expand_table_get
Unexecuted instantiation: ext-enotify.c:var_expand_table_get
Unexecuted instantiation: ntfy-mailto-settings.c:var_expand_table_get
Unexecuted instantiation: ext-spamvirustest-settings.c:var_expand_table_get
Unexecuted instantiation: ext-editheader-settings.c:var_expand_table_get
Unexecuted instantiation: ext-duplicate-settings.c:var_expand_table_get
Unexecuted instantiation: ext-extlists-settings.c:var_expand_table_get
Unexecuted instantiation: ext-vnd-environment-settings.c:var_expand_table_get
Unexecuted instantiation: ext-vnd-environment.c:var_expand_table_get
Unexecuted instantiation: ext-vnd-report-settings.c:var_expand_table_get
Unexecuted instantiation: cmd-vacation.c:var_expand_table_get
Unexecuted instantiation: ext-vacation-common.c:var_expand_table_get
Unexecuted instantiation: ext-include-common.c:var_expand_table_get
Unexecuted instantiation: ext-variables-common.c:var_expand_table_get
Unexecuted instantiation: ext-enotify-settings.c:var_expand_table_get
Unexecuted instantiation: ntfy-mailto.c:var_expand_table_get
Unexecuted instantiation: ext-spamvirustest-common.c:var_expand_table_get
Unexecuted instantiation: ext-editheader-common.c:var_expand_table_get
Unexecuted instantiation: ext-duplicate-common.c:var_expand_table_get
Unexecuted instantiation: ext-extlists-common.c:var_expand_table_get
Unexecuted instantiation: ext-vnd-report-common.c:var_expand_table_get
Unexecuted instantiation: sieve-tool.c:var_expand_table_get
Unexecuted instantiation: mail-namespace.c:var_expand_table_get
Unexecuted instantiation: mail-storage-service.c:var_expand_table_get
Unexecuted instantiation: mail-storage-settings.c:var_expand_table_get
Unexecuted instantiation: mail-storage.c:var_expand_table_get
Unexecuted instantiation: mail-user.c:var_expand_table_get
Unexecuted instantiation: mailbox-attribute.c:var_expand_table_get
Unexecuted instantiation: mailbox-list-iter.c:var_expand_table_get
Unexecuted instantiation: mailbox-list.c:var_expand_table_get
Unexecuted instantiation: shared-storage.c:var_expand_table_get
Unexecuted instantiation: imapc-list.c:var_expand_table_get
Unexecuted instantiation: imapc-storage.c:var_expand_table_get
Unexecuted instantiation: index-attribute.c:var_expand_table_get
Unexecuted instantiation: maildir-storage.c:var_expand_table_get
Unexecuted instantiation: mbox-storage.c:var_expand_table_get
Unexecuted instantiation: mdbox-storage.c:var_expand_table_get
Unexecuted instantiation: pop3c-storage.c:var_expand_table_get
Unexecuted instantiation: dbox-storage.c:var_expand_table_get
Unexecuted instantiation: imapc-client.c:var_expand_table_get
Unexecuted instantiation: imapc-connection.c:var_expand_table_get
Unexecuted instantiation: mbox-lock.c:var_expand_table_get
Unexecuted instantiation: pop3c-client.c:var_expand_table_get
Unexecuted instantiation: expansion-program.c:var_expand_table_get
Unexecuted instantiation: expansion-statement.c:var_expand_table_get
Unexecuted instantiation: var-expand-lexer.c:var_expand_table_get
Unexecuted instantiation: var-expand-parser.c:var_expand_table_get
Unexecuted instantiation: var-expand.c:var_expand_table_get
Unexecuted instantiation: master-service-settings.c:var_expand_table_get
Unexecuted instantiation: master-service.c:var_expand_table_get
Unexecuted instantiation: settings-parser.c:var_expand_table_get
Unexecuted instantiation: settings.c:var_expand_table_get
Unexecuted instantiation: fs-api.c:var_expand_table_get
Unexecuted instantiation: fs-dict.c:var_expand_table_get
Unexecuted instantiation: fs-posix.c:var_expand_table_get
Unexecuted instantiation: fs-randomfail.c:var_expand_table_get
Unexecuted instantiation: fs-sis-queue.c:var_expand_table_get
Unexecuted instantiation: dict-file.c:var_expand_table_get
Unexecuted instantiation: dict-redis.c:var_expand_table_get
Unexecuted instantiation: dict.c:var_expand_table_get
Unexecuted instantiation: dns-lookup.c:var_expand_table_get
Unexecuted instantiation: iostream-ssl.c:var_expand_table_get
Unexecuted instantiation: ssl-settings.c:var_expand_table_get
Unexecuted instantiation: dict-client.c:var_expand_table_get
Unexecuted instantiation: expansion-filter.c:var_expand_table_get
Unexecuted instantiation: expansion-parameter.c:var_expand_table_get
Unexecuted instantiation: master-service-ssl.c:var_expand_table_get
Unexecuted instantiation: iostream-ssl-context-cache.c:var_expand_table_get
Unexecuted instantiation: expansion-filter-crypt.c:var_expand_table_get
Unexecuted instantiation: expansion-filter-if.c:var_expand_table_get
171
172
/* Set table variable to value. Asserts that key is found. */
173
static inline void var_expand_table_set_value(struct var_expand_table *table,
174
                const char *key, const char *value,
175
                const char *file, unsigned int line)
176
0
{
177
0
  struct var_expand_table *entry = var_expand_table_get(table, key);
178
0
  if (entry != NULL) {
179
0
    i_assert(entry->func == NULL);
180
0
    entry->value = value;
181
0
  } else
182
0
    i_panic("%s:%u No key '%s' in table", file, line, key);
183
0
}
Unexecuted instantiation: testsuite-settings.c:var_expand_table_set_value
Unexecuted instantiation: testsuite-script.c:var_expand_table_set_value
Unexecuted instantiation: fuzzsuite.c:var_expand_table_set_value
Unexecuted instantiation: sieve-settings.c:var_expand_table_set_value
Unexecuted instantiation: sieve-storage.c:var_expand_table_set_value
Unexecuted instantiation: sieve-storage-settings.c:var_expand_table_set_value
Unexecuted instantiation: sieve-result.c:var_expand_table_set_value
Unexecuted instantiation: sieve-error.c:var_expand_table_set_value
Unexecuted instantiation: sieve.c:var_expand_table_set_value
Unexecuted instantiation: sieve-file-storage-settings.c:var_expand_table_set_value
Unexecuted instantiation: sieve-file-storage.c:var_expand_table_set_value
Unexecuted instantiation: sieve-dict-storage.c:var_expand_table_set_value
Unexecuted instantiation: ext-vacation-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-subaddress-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-subaddress.c:var_expand_table_set_value
Unexecuted instantiation: ext-include-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-variables-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-enotify.c:var_expand_table_set_value
Unexecuted instantiation: ntfy-mailto-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-spamvirustest-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-editheader-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-duplicate-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-extlists-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-vnd-environment-settings.c:var_expand_table_set_value
Unexecuted instantiation: ext-vnd-environment.c:var_expand_table_set_value
Unexecuted instantiation: ext-vnd-report-settings.c:var_expand_table_set_value
Unexecuted instantiation: cmd-vacation.c:var_expand_table_set_value
Unexecuted instantiation: ext-vacation-common.c:var_expand_table_set_value
Unexecuted instantiation: ext-include-common.c:var_expand_table_set_value
Unexecuted instantiation: ext-variables-common.c:var_expand_table_set_value
Unexecuted instantiation: ext-enotify-settings.c:var_expand_table_set_value
Unexecuted instantiation: ntfy-mailto.c:var_expand_table_set_value
Unexecuted instantiation: ext-spamvirustest-common.c:var_expand_table_set_value
Unexecuted instantiation: ext-editheader-common.c:var_expand_table_set_value
Unexecuted instantiation: ext-duplicate-common.c:var_expand_table_set_value
Unexecuted instantiation: ext-extlists-common.c:var_expand_table_set_value
Unexecuted instantiation: ext-vnd-report-common.c:var_expand_table_set_value
Unexecuted instantiation: sieve-tool.c:var_expand_table_set_value
Unexecuted instantiation: mail-namespace.c:var_expand_table_set_value
Unexecuted instantiation: mail-storage-service.c:var_expand_table_set_value
Unexecuted instantiation: mail-storage-settings.c:var_expand_table_set_value
Unexecuted instantiation: mail-storage.c:var_expand_table_set_value
Unexecuted instantiation: mail-user.c:var_expand_table_set_value
Unexecuted instantiation: mailbox-attribute.c:var_expand_table_set_value
Unexecuted instantiation: mailbox-list-iter.c:var_expand_table_set_value
Unexecuted instantiation: mailbox-list.c:var_expand_table_set_value
Unexecuted instantiation: shared-storage.c:var_expand_table_set_value
Unexecuted instantiation: imapc-list.c:var_expand_table_set_value
Unexecuted instantiation: imapc-storage.c:var_expand_table_set_value
Unexecuted instantiation: index-attribute.c:var_expand_table_set_value
Unexecuted instantiation: maildir-storage.c:var_expand_table_set_value
Unexecuted instantiation: mbox-storage.c:var_expand_table_set_value
Unexecuted instantiation: mdbox-storage.c:var_expand_table_set_value
Unexecuted instantiation: pop3c-storage.c:var_expand_table_set_value
Unexecuted instantiation: dbox-storage.c:var_expand_table_set_value
Unexecuted instantiation: imapc-client.c:var_expand_table_set_value
Unexecuted instantiation: imapc-connection.c:var_expand_table_set_value
Unexecuted instantiation: mbox-lock.c:var_expand_table_set_value
Unexecuted instantiation: pop3c-client.c:var_expand_table_set_value
Unexecuted instantiation: expansion-program.c:var_expand_table_set_value
Unexecuted instantiation: expansion-statement.c:var_expand_table_set_value
Unexecuted instantiation: var-expand-lexer.c:var_expand_table_set_value
Unexecuted instantiation: var-expand-parser.c:var_expand_table_set_value
Unexecuted instantiation: var-expand.c:var_expand_table_set_value
Unexecuted instantiation: master-service-settings.c:var_expand_table_set_value
Unexecuted instantiation: master-service.c:var_expand_table_set_value
Unexecuted instantiation: settings-parser.c:var_expand_table_set_value
Unexecuted instantiation: settings.c:var_expand_table_set_value
Unexecuted instantiation: fs-api.c:var_expand_table_set_value
Unexecuted instantiation: fs-dict.c:var_expand_table_set_value
Unexecuted instantiation: fs-posix.c:var_expand_table_set_value
Unexecuted instantiation: fs-randomfail.c:var_expand_table_set_value
Unexecuted instantiation: fs-sis-queue.c:var_expand_table_set_value
Unexecuted instantiation: dict-file.c:var_expand_table_set_value
Unexecuted instantiation: dict-redis.c:var_expand_table_set_value
Unexecuted instantiation: dict.c:var_expand_table_set_value
Unexecuted instantiation: dns-lookup.c:var_expand_table_set_value
Unexecuted instantiation: iostream-ssl.c:var_expand_table_set_value
Unexecuted instantiation: ssl-settings.c:var_expand_table_set_value
Unexecuted instantiation: dict-client.c:var_expand_table_set_value
Unexecuted instantiation: expansion-filter.c:var_expand_table_set_value
Unexecuted instantiation: expansion-parameter.c:var_expand_table_set_value
Unexecuted instantiation: master-service-ssl.c:var_expand_table_set_value
Unexecuted instantiation: iostream-ssl-context-cache.c:var_expand_table_set_value
Unexecuted instantiation: expansion-filter-crypt.c:var_expand_table_set_value
Unexecuted instantiation: expansion-filter-if.c:var_expand_table_set_value
184
#define var_expand_table_set_value(table, key, value) \
185
  var_expand_table_set_value((table), (key), (value), __FILE__, __LINE__);
186
187
/* Set table variable function. Asserts that key is found. */
188
static inline void var_expand_table_set_func(struct var_expand_table *table,
189
               const char *key,
190
               value_provider_func_t *func,
191
               const char *file, unsigned int line)
192
0
{
193
0
  struct var_expand_table *entry = var_expand_table_get(table, key);
194
0
  if (entry != NULL) {
195
0
    i_assert(entry->value == NULL);
196
0
    entry->func = func;
197
0
  } else
198
0
    i_panic("%s:%u No key '%s' in table", file, line, key);
199
0
}
Unexecuted instantiation: testsuite-settings.c:var_expand_table_set_func
Unexecuted instantiation: testsuite-script.c:var_expand_table_set_func
Unexecuted instantiation: fuzzsuite.c:var_expand_table_set_func
Unexecuted instantiation: sieve-settings.c:var_expand_table_set_func
Unexecuted instantiation: sieve-storage.c:var_expand_table_set_func
Unexecuted instantiation: sieve-storage-settings.c:var_expand_table_set_func
Unexecuted instantiation: sieve-result.c:var_expand_table_set_func
Unexecuted instantiation: sieve-error.c:var_expand_table_set_func
Unexecuted instantiation: sieve.c:var_expand_table_set_func
Unexecuted instantiation: sieve-file-storage-settings.c:var_expand_table_set_func
Unexecuted instantiation: sieve-file-storage.c:var_expand_table_set_func
Unexecuted instantiation: sieve-dict-storage.c:var_expand_table_set_func
Unexecuted instantiation: ext-vacation-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-subaddress-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-subaddress.c:var_expand_table_set_func
Unexecuted instantiation: ext-include-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-variables-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-enotify.c:var_expand_table_set_func
Unexecuted instantiation: ntfy-mailto-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-spamvirustest-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-editheader-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-duplicate-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-extlists-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-vnd-environment-settings.c:var_expand_table_set_func
Unexecuted instantiation: ext-vnd-environment.c:var_expand_table_set_func
Unexecuted instantiation: ext-vnd-report-settings.c:var_expand_table_set_func
Unexecuted instantiation: cmd-vacation.c:var_expand_table_set_func
Unexecuted instantiation: ext-vacation-common.c:var_expand_table_set_func
Unexecuted instantiation: ext-include-common.c:var_expand_table_set_func
Unexecuted instantiation: ext-variables-common.c:var_expand_table_set_func
Unexecuted instantiation: ext-enotify-settings.c:var_expand_table_set_func
Unexecuted instantiation: ntfy-mailto.c:var_expand_table_set_func
Unexecuted instantiation: ext-spamvirustest-common.c:var_expand_table_set_func
Unexecuted instantiation: ext-editheader-common.c:var_expand_table_set_func
Unexecuted instantiation: ext-duplicate-common.c:var_expand_table_set_func
Unexecuted instantiation: ext-extlists-common.c:var_expand_table_set_func
Unexecuted instantiation: ext-vnd-report-common.c:var_expand_table_set_func
Unexecuted instantiation: sieve-tool.c:var_expand_table_set_func
Unexecuted instantiation: mail-namespace.c:var_expand_table_set_func
Unexecuted instantiation: mail-storage-service.c:var_expand_table_set_func
Unexecuted instantiation: mail-storage-settings.c:var_expand_table_set_func
Unexecuted instantiation: mail-storage.c:var_expand_table_set_func
Unexecuted instantiation: mail-user.c:var_expand_table_set_func
Unexecuted instantiation: mailbox-attribute.c:var_expand_table_set_func
Unexecuted instantiation: mailbox-list-iter.c:var_expand_table_set_func
Unexecuted instantiation: mailbox-list.c:var_expand_table_set_func
Unexecuted instantiation: shared-storage.c:var_expand_table_set_func
Unexecuted instantiation: imapc-list.c:var_expand_table_set_func
Unexecuted instantiation: imapc-storage.c:var_expand_table_set_func
Unexecuted instantiation: index-attribute.c:var_expand_table_set_func
Unexecuted instantiation: maildir-storage.c:var_expand_table_set_func
Unexecuted instantiation: mbox-storage.c:var_expand_table_set_func
Unexecuted instantiation: mdbox-storage.c:var_expand_table_set_func
Unexecuted instantiation: pop3c-storage.c:var_expand_table_set_func
Unexecuted instantiation: dbox-storage.c:var_expand_table_set_func
Unexecuted instantiation: imapc-client.c:var_expand_table_set_func
Unexecuted instantiation: imapc-connection.c:var_expand_table_set_func
Unexecuted instantiation: mbox-lock.c:var_expand_table_set_func
Unexecuted instantiation: pop3c-client.c:var_expand_table_set_func
Unexecuted instantiation: expansion-program.c:var_expand_table_set_func
Unexecuted instantiation: expansion-statement.c:var_expand_table_set_func
Unexecuted instantiation: var-expand-lexer.c:var_expand_table_set_func
Unexecuted instantiation: var-expand-parser.c:var_expand_table_set_func
Unexecuted instantiation: var-expand.c:var_expand_table_set_func
Unexecuted instantiation: master-service-settings.c:var_expand_table_set_func
Unexecuted instantiation: master-service.c:var_expand_table_set_func
Unexecuted instantiation: settings-parser.c:var_expand_table_set_func
Unexecuted instantiation: settings.c:var_expand_table_set_func
Unexecuted instantiation: fs-api.c:var_expand_table_set_func
Unexecuted instantiation: fs-dict.c:var_expand_table_set_func
Unexecuted instantiation: fs-posix.c:var_expand_table_set_func
Unexecuted instantiation: fs-randomfail.c:var_expand_table_set_func
Unexecuted instantiation: fs-sis-queue.c:var_expand_table_set_func
Unexecuted instantiation: dict-file.c:var_expand_table_set_func
Unexecuted instantiation: dict-redis.c:var_expand_table_set_func
Unexecuted instantiation: dict.c:var_expand_table_set_func
Unexecuted instantiation: dns-lookup.c:var_expand_table_set_func
Unexecuted instantiation: iostream-ssl.c:var_expand_table_set_func
Unexecuted instantiation: ssl-settings.c:var_expand_table_set_func
Unexecuted instantiation: dict-client.c:var_expand_table_set_func
Unexecuted instantiation: expansion-filter.c:var_expand_table_set_func
Unexecuted instantiation: expansion-parameter.c:var_expand_table_set_func
Unexecuted instantiation: master-service-ssl.c:var_expand_table_set_func
Unexecuted instantiation: iostream-ssl-context-cache.c:var_expand_table_set_func
Unexecuted instantiation: expansion-filter-crypt.c:var_expand_table_set_func
Unexecuted instantiation: expansion-filter-if.c:var_expand_table_set_func
200
#define var_expand_table_set_func(table, key, func) \
201
  var_expand_table_set_func((table), (key), (func), __FILE__, __LINE__);
202
203
/* Set key_b variable to key_a. Copies func and value.
204
   Asserts that both are found. */
205
static inline void var_expand_table_copy(struct var_expand_table *table,
206
           const char *key_b, const char *key_a)
207
0
{
208
0
  struct var_expand_table *entry_a = var_expand_table_get(table, key_a);
209
0
  struct var_expand_table *entry_b = var_expand_table_get(table, key_b);
210
0
211
0
  i_assert(entry_a != NULL && entry_b != NULL);
212
0
  entry_b->value = entry_a->value;
213
0
  entry_b->func = entry_a->func;
214
0
}
Unexecuted instantiation: testsuite-settings.c:var_expand_table_copy
Unexecuted instantiation: testsuite-script.c:var_expand_table_copy
Unexecuted instantiation: fuzzsuite.c:var_expand_table_copy
Unexecuted instantiation: sieve-settings.c:var_expand_table_copy
Unexecuted instantiation: sieve-storage.c:var_expand_table_copy
Unexecuted instantiation: sieve-storage-settings.c:var_expand_table_copy
Unexecuted instantiation: sieve-result.c:var_expand_table_copy
Unexecuted instantiation: sieve-error.c:var_expand_table_copy
Unexecuted instantiation: sieve.c:var_expand_table_copy
Unexecuted instantiation: sieve-file-storage-settings.c:var_expand_table_copy
Unexecuted instantiation: sieve-file-storage.c:var_expand_table_copy
Unexecuted instantiation: sieve-dict-storage.c:var_expand_table_copy
Unexecuted instantiation: ext-vacation-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-subaddress-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-subaddress.c:var_expand_table_copy
Unexecuted instantiation: ext-include-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-variables-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-enotify.c:var_expand_table_copy
Unexecuted instantiation: ntfy-mailto-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-spamvirustest-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-editheader-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-duplicate-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-extlists-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-vnd-environment-settings.c:var_expand_table_copy
Unexecuted instantiation: ext-vnd-environment.c:var_expand_table_copy
Unexecuted instantiation: ext-vnd-report-settings.c:var_expand_table_copy
Unexecuted instantiation: cmd-vacation.c:var_expand_table_copy
Unexecuted instantiation: ext-vacation-common.c:var_expand_table_copy
Unexecuted instantiation: ext-include-common.c:var_expand_table_copy
Unexecuted instantiation: ext-variables-common.c:var_expand_table_copy
Unexecuted instantiation: ext-enotify-settings.c:var_expand_table_copy
Unexecuted instantiation: ntfy-mailto.c:var_expand_table_copy
Unexecuted instantiation: ext-spamvirustest-common.c:var_expand_table_copy
Unexecuted instantiation: ext-editheader-common.c:var_expand_table_copy
Unexecuted instantiation: ext-duplicate-common.c:var_expand_table_copy
Unexecuted instantiation: ext-extlists-common.c:var_expand_table_copy
Unexecuted instantiation: ext-vnd-report-common.c:var_expand_table_copy
Unexecuted instantiation: sieve-tool.c:var_expand_table_copy
Unexecuted instantiation: mail-namespace.c:var_expand_table_copy
Unexecuted instantiation: mail-storage-service.c:var_expand_table_copy
Unexecuted instantiation: mail-storage-settings.c:var_expand_table_copy
Unexecuted instantiation: mail-storage.c:var_expand_table_copy
Unexecuted instantiation: mail-user.c:var_expand_table_copy
Unexecuted instantiation: mailbox-attribute.c:var_expand_table_copy
Unexecuted instantiation: mailbox-list-iter.c:var_expand_table_copy
Unexecuted instantiation: mailbox-list.c:var_expand_table_copy
Unexecuted instantiation: shared-storage.c:var_expand_table_copy
Unexecuted instantiation: imapc-list.c:var_expand_table_copy
Unexecuted instantiation: imapc-storage.c:var_expand_table_copy
Unexecuted instantiation: index-attribute.c:var_expand_table_copy
Unexecuted instantiation: maildir-storage.c:var_expand_table_copy
Unexecuted instantiation: mbox-storage.c:var_expand_table_copy
Unexecuted instantiation: mdbox-storage.c:var_expand_table_copy
Unexecuted instantiation: pop3c-storage.c:var_expand_table_copy
Unexecuted instantiation: dbox-storage.c:var_expand_table_copy
Unexecuted instantiation: imapc-client.c:var_expand_table_copy
Unexecuted instantiation: imapc-connection.c:var_expand_table_copy
Unexecuted instantiation: mbox-lock.c:var_expand_table_copy
Unexecuted instantiation: pop3c-client.c:var_expand_table_copy
Unexecuted instantiation: expansion-program.c:var_expand_table_copy
Unexecuted instantiation: expansion-statement.c:var_expand_table_copy
Unexecuted instantiation: var-expand-lexer.c:var_expand_table_copy
Unexecuted instantiation: var-expand-parser.c:var_expand_table_copy
Unexecuted instantiation: var-expand.c:var_expand_table_copy
Unexecuted instantiation: master-service-settings.c:var_expand_table_copy
Unexecuted instantiation: master-service.c:var_expand_table_copy
Unexecuted instantiation: settings-parser.c:var_expand_table_copy
Unexecuted instantiation: settings.c:var_expand_table_copy
Unexecuted instantiation: fs-api.c:var_expand_table_copy
Unexecuted instantiation: fs-dict.c:var_expand_table_copy
Unexecuted instantiation: fs-posix.c:var_expand_table_copy
Unexecuted instantiation: fs-randomfail.c:var_expand_table_copy
Unexecuted instantiation: fs-sis-queue.c:var_expand_table_copy
Unexecuted instantiation: dict-file.c:var_expand_table_copy
Unexecuted instantiation: dict-redis.c:var_expand_table_copy
Unexecuted instantiation: dict.c:var_expand_table_copy
Unexecuted instantiation: dns-lookup.c:var_expand_table_copy
Unexecuted instantiation: iostream-ssl.c:var_expand_table_copy
Unexecuted instantiation: ssl-settings.c:var_expand_table_copy
Unexecuted instantiation: dict-client.c:var_expand_table_copy
Unexecuted instantiation: expansion-filter.c:var_expand_table_copy
Unexecuted instantiation: expansion-parameter.c:var_expand_table_copy
Unexecuted instantiation: master-service-ssl.c:var_expand_table_copy
Unexecuted instantiation: iostream-ssl-context-cache.c:var_expand_table_copy
Unexecuted instantiation: expansion-filter-crypt.c:var_expand_table_copy
Unexecuted instantiation: expansion-filter-if.c:var_expand_table_copy
215
216
/* Export variable expand program to a portable string.
217
218
   Output format is a list of programs. Each program is catenated after
219
   the previous program.
220
   If there is only literal: \x01 <literal>
221
   <literal>: tab-escaped string \r
222
   Otherwise:
223
   <program>: \x02 <function> \x01 <list-of-parameters> \t <list-of-variables> \t
224
   <function>: string
225
   <list-of-parameters>: <parameter> \x01 <parameter> \x01 ..
226
      Note that last parameter has no \x01 at the end.
227
   <parameter>: <key> \x01 <type> <value>
228
   <key>: string
229
   <type>: s = string, i = intmax, v = variable
230
   <value>: <encoded-number> | tab-escaped string \r
231
   <encoded-number>:
232
     The number is expressed in 7-bit bytes and 8th bit indicates the
233
     presence of next byte. The number is in little-endian ordering.
234
   <list-of-variables>: <variable-name> \x01 <variable-name> \x01 ..
235
     Note that last variable has no \x01 at the end.
236
*/
237
238
const char *var_expand_program_export(const struct var_expand_program *program);
239
void var_expand_program_export_append(string_t *dest,
240
              const struct var_expand_program *program);
241
242
/* Reconstruct var_expand program */
243
const char *var_expand_program_to_string_one(const struct var_expand_program *program);
244
const char *var_expand_program_to_string(const struct var_expand_program *program);
245
void var_expand_program_to_string_append_one(string_t *dest,
246
           const struct var_expand_program *program);
247
void var_expand_program_to_string_append(string_t *dest,
248
           const struct var_expand_program *program);
249
250
/* Imports a variable expansion program exported by var_expand_program_export(). */
251
252
int var_expand_program_import(const char *data,
253
            struct var_expand_program **program_r,
254
            const char **error_r);
255
int var_expand_program_import_sized(const char *data, size_t size,
256
            struct var_expand_program **program_r,
257
            const char **error_r);
258
259
void var_expand_crypt_load(void);
260
261
#endif