/src/pigeonhole/src/lib-sieve/plugins/vacation/ext-vacation-settings.c
Line | Count | Source |
1 | | /* Copyright (c) Pigeonhole authors, see top-level COPYING file */ |
2 | | |
3 | | #include "lib.h" |
4 | | #include "array.h" |
5 | | #include "settings.h" |
6 | | #include "settings-parser.h" |
7 | | |
8 | | #include "ext-vacation-settings.h" |
9 | | |
10 | | static bool |
11 | | ext_vacation_settings_check(void *_set, pool_t pool ATTR_UNUSED, |
12 | | const char **error_r); |
13 | | |
14 | | #undef DEF |
15 | | #define DEF(type, name) \ |
16 | | SETTING_DEFINE_STRUCT_##type("sieve_vacation_"#name, name, \ |
17 | | struct ext_vacation_settings) |
18 | | |
19 | | static const struct setting_define ext_vacation_setting_defines[] = { |
20 | | DEF(TIME, min_period), |
21 | | DEF(TIME, max_period), |
22 | | DEF(TIME, default_period), |
23 | | |
24 | | DEF(STR, default_subject), |
25 | | DEF(STR, default_subject_template), |
26 | | |
27 | | DEF(BOOL, use_original_recipient), |
28 | | DEF(BOOL, check_recipient), |
29 | | DEF(BOOL, send_from_recipient), |
30 | | DEF(BOOL, to_header_ignore_envelope), |
31 | | |
32 | | SETTING_DEFINE_LIST_END, |
33 | | }; |
34 | | |
35 | | static const struct ext_vacation_settings ext_vacation_default_settings = { |
36 | | .min_period = (24*60*60), |
37 | | .max_period = (60*24*60*60), |
38 | | .default_period = (7*24*60*60), |
39 | | .default_subject = "", |
40 | | .default_subject_template = "", |
41 | | .use_original_recipient = FALSE, |
42 | | .check_recipient = TRUE, |
43 | | .send_from_recipient = FALSE, |
44 | | .to_header_ignore_envelope = FALSE, |
45 | | }; |
46 | | |
47 | | const struct setting_parser_info ext_vacation_setting_parser_info = { |
48 | | .name = "sieve_vacation", |
49 | | |
50 | | .defines = ext_vacation_setting_defines, |
51 | | .defaults = &ext_vacation_default_settings, |
52 | | |
53 | | .struct_size = sizeof(struct ext_vacation_settings), |
54 | | |
55 | | .check_func = ext_vacation_settings_check, |
56 | | |
57 | | .pool_offset1 = 1 + offsetof(struct ext_vacation_settings, pool), |
58 | | }; |
59 | | |
60 | | /* <settings checks> */ |
61 | | static bool |
62 | | ext_vacation_settings_check(void *_set, pool_t pool ATTR_UNUSED, |
63 | | const char **error_r) |
64 | 0 | { |
65 | 0 | struct ext_vacation_settings *set = _set; |
66 | |
|
67 | 0 | if (set->max_period == 0) { |
68 | 0 | *error_r = "sieve_vacation_max_period must not be 0"; |
69 | 0 | return FALSE; |
70 | 0 | } |
71 | | |
72 | 0 | if (set->max_period > 0 && |
73 | 0 | (set->min_period > set->max_period || |
74 | 0 | set->default_period < set->min_period || |
75 | 0 | set->default_period > set->max_period)) { |
76 | 0 | *error_r = "Violated sieve_vacation_min_period < " |
77 | 0 | "sieve_vacation_default_period < " |
78 | 0 | "sieve_vacation_max_period"; |
79 | 0 | return FALSE; |
80 | 0 | } |
81 | | |
82 | 0 | return TRUE; |
83 | 0 | } |
84 | | /* </settings checks> */ |
85 | | |