Mercurial > dovecot > core-2.2
annotate src/lib/var-expand.h @ 22664:fea53c2725c0
director: Fix director_max_parallel_moves/kicks type
Should be uint, not time.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Thu, 09 Nov 2017 12:24:16 +0200 |
parents | bb81856fe3c1 |
children | 7b6f77272538 |
rev | line source |
---|---|
6410
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5485
diff
changeset
|
1 #ifndef VAR_EXPAND_H |
e4eb71ae8e96
Changed .h ifdef/defines to use <NAME>_H format.
Timo Sirainen <tss@iki.fi>
parents:
5485
diff
changeset
|
2 #define VAR_EXPAND_H |
1034 | 3 |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
1034
diff
changeset
|
4 struct var_expand_table { |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
1034
diff
changeset
|
5 char key; |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
1034
diff
changeset
|
6 const char *value; |
8544
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8324
diff
changeset
|
7 const char *long_key; |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
1034
diff
changeset
|
8 }; |
1034 | 9 |
14053
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
10 struct var_expand_func_table { |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
11 const char *key; |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
12 /* %{key:data}, or data is "" with %{key}, */ |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
13 const char *(*func)(const char *data, void *context); |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
14 }; |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
15 |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
1034
diff
changeset
|
16 /* Expand % variables in src and append the string in dest. |
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
1034
diff
changeset
|
17 table must end with key = 0. */ |
1034 | 18 void var_expand(string_t *dest, const char *str, |
2057
5e0167577399
Fixed var_expand() to take a table of variables rather than a few predefined
Timo Sirainen <tss@iki.fi>
parents:
1034
diff
changeset
|
19 const struct var_expand_table *table); |
14053
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
20 /* Like var_expand(), but support also callback functions for |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
21 variable expansion. */ |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
22 void var_expand_with_funcs(string_t *dest, const char *str, |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
23 const struct var_expand_table *table, |
ba86a60e3059
liblib: Added var_expand_with_funcs() to expand variables with function callbacks.
Timo Sirainen <tss@iki.fi>
parents:
8544
diff
changeset
|
24 const struct var_expand_func_table *func_table, |
14629
c93ca5e46a8a
Marked functions parameters that are allowed to be NULL. Some APIs were also changed.
Timo Sirainen <tss@iki.fi>
parents:
14339
diff
changeset
|
25 void *func_context) ATTR_NULL(3, 4, 5); |
1034 | 26 |
2975
c59fd95ad3ee
Auth cache key was built wrong if any modifiers were used for %vars.
Timo Sirainen <tss@iki.fi>
parents:
2057
diff
changeset
|
27 /* Returns the actual key character for given string, ie. skip any modifiers |
20550
ba37ec73c6aa
lib: var_get_key() didn't handle %{long_variables} correctly
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
14629
diff
changeset
|
28 that are before it. The string should be the data after the '%' character. |
ba37ec73c6aa
lib: var_get_key() didn't handle %{long_variables} correctly
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
14629
diff
changeset
|
29 For %{long_variable}, '{' is returned. */ |
7912
81806d402514
Added more consts, ATTR_CONSTs and ATTR_PUREs.
Timo Sirainen <tss@iki.fi>
parents:
6410
diff
changeset
|
30 char var_get_key(const char *str) ATTR_PURE; |
14339
13d4c4f91622
liblib: Added var_get_key_range()
Timo Sirainen <tss@iki.fi>
parents:
14053
diff
changeset
|
31 /* Similar to var_get_key(), but works for long keys as well. For single char |
13d4c4f91622
liblib: Added var_get_key_range()
Timo Sirainen <tss@iki.fi>
parents:
14053
diff
changeset
|
32 keys size=1, while for e.g. %{key} size=3 and idx points to 'k'. */ |
13d4c4f91622
liblib: Added var_get_key_range()
Timo Sirainen <tss@iki.fi>
parents:
14053
diff
changeset
|
33 void var_get_key_range(const char *str, unsigned int *idx_r, |
13d4c4f91622
liblib: Added var_get_key_range()
Timo Sirainen <tss@iki.fi>
parents:
14053
diff
changeset
|
34 unsigned int *size_r); |
20551
64f547f5bd86
lib: var_has_key() properly ignores key=='\0' now.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20550
diff
changeset
|
35 /* Returns TRUE if key variable is used in the string. |
64f547f5bd86
lib: var_has_key() properly ignores key=='\0' now.
Timo Sirainen <timo.sirainen@dovecot.fi>
parents:
20550
diff
changeset
|
36 If key is '\0', it's ignored. If long_key is NULL, it's ignored. */ |
8544
983d38de06c9
var_expand(): Added support for long %{variable} names.
Timo Sirainen <tss@iki.fi>
parents:
8324
diff
changeset
|
37 bool var_has_key(const char *str, char key, const char *long_key) ATTR_PURE; |
2975
c59fd95ad3ee
Auth cache key was built wrong if any modifiers were used for %vars.
Timo Sirainen <tss@iki.fi>
parents:
2057
diff
changeset
|
38 |
1034 | 39 #endif |