Coverage Report

Created: 2026-04-27 06:39

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