Coverage Report

Created: 2026-04-12 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/lib-sieve/plugins/vacation/ext-vacation.c
Line
Count
Source
1
/* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file
2
 */
3
4
/* Extension vacation
5
 * ------------------
6
 *
7
 * Authors: Stephan Bosch <stephan@rename-it.nl>
8
 * Specification: RFC 5230
9
 * Implementation: full
10
 * Status: testing
11
 *
12
 */
13
14
#include "lib.h"
15
16
#include "sieve-common.h"
17
18
#include "sieve-extensions.h"
19
#include "sieve-commands.h"
20
#include "sieve-validator.h"
21
#include "sieve-generator.h"
22
#include "sieve-interpreter.h"
23
#include "sieve-dump.h"
24
25
#include "ext-vacation-common.h"
26
27
/*
28
 * Extension
29
 */
30
31
static bool
32
ext_vacation_validator_load(const struct sieve_extension *ext,
33
         struct sieve_validator *valdtr);
34
static bool
35
ext_vacation_interpreter_load(const struct sieve_extension *ext,
36
            const struct sieve_runtime_env *renv,
37
            sieve_size_t *address);
38
39
static bool
40
ext_vacation_validator_validate(const struct sieve_extension *ext,
41
        struct sieve_validator *valdtr, void *context,
42
        struct sieve_ast_argument *require_arg,
43
        bool required);
44
static int
45
ext_vacation_interpreter_run(const struct sieve_extension *this_ext,
46
           const struct sieve_runtime_env *renv,
47
           void *context, bool deferred);
48
49
const struct sieve_extension_def vacation_extension = {
50
  .name = "vacation",
51
  .load = ext_vacation_load,
52
  .unload = ext_vacation_unload,
53
  .validator_load = ext_vacation_validator_load,
54
  .interpreter_load = ext_vacation_interpreter_load,
55
  SIEVE_EXT_DEFINE_OPERATION(vacation_operation),
56
};
57
const struct sieve_validator_extension
58
vacation_validator_extension = {
59
  .ext = &vacation_extension,
60
  .validate = ext_vacation_validator_validate,
61
};
62
const struct sieve_interpreter_extension
63
vacation_interpreter_extension = {
64
  .ext_def = &vacation_extension,
65
  .run = ext_vacation_interpreter_run,
66
};
67
68
static bool
69
ext_vacation_validator_load(const struct sieve_extension *ext,
70
          struct sieve_validator *valdtr)
71
0
{
72
  /* Register new command */
73
0
  sieve_validator_register_command(valdtr, ext, &vacation_command);
74
75
0
  sieve_validator_extension_register(valdtr, ext,
76
0
             &vacation_validator_extension, NULL);
77
0
  return TRUE;
78
0
}
79
80
static bool
81
ext_vacation_interpreter_load(const struct sieve_extension *ext,
82
            const struct sieve_runtime_env *renv,
83
            sieve_size_t *address ATTR_UNUSED)
84
0
{
85
0
  sieve_interpreter_extension_register(
86
0
    renv->interp, ext, &vacation_interpreter_extension, NULL);
87
0
  return TRUE;
88
0
}
89
90
static bool
91
ext_vacation_validator_validate(const struct sieve_extension *ext,
92
        struct sieve_validator *valdtr,
93
        void *context ATTR_UNUSED,
94
        struct sieve_ast_argument *require_arg,
95
        bool required)
96
0
{
97
0
  if (required) {
98
0
    enum sieve_compile_flags flags =
99
0
      sieve_validator_compile_flags(valdtr);
100
101
0
    if ((flags & SIEVE_COMPILE_FLAG_NO_ENVELOPE) != 0) {
102
0
      sieve_argument_validate_error(
103
0
        valdtr, require_arg,
104
0
        "the %s extension cannot be used in this context "
105
0
        "(needs access to message envelope)",
106
0
        sieve_extension_name(ext));
107
0
      return FALSE;
108
0
    }
109
0
  }
110
0
  return TRUE;
111
0
}
112
113
static int
114
ext_vacation_interpreter_run(const struct sieve_extension *ext,
115
           const struct sieve_runtime_env *renv,
116
           void *context ATTR_UNUSED, bool deferred)
117
0
{
118
0
  const struct sieve_execute_env *eenv = renv->exec_env;
119
120
0
  if ((eenv->flags & SIEVE_EXECUTE_FLAG_NO_ENVELOPE) != 0) {
121
0
    if (!deferred) {
122
0
      sieve_runtime_error(
123
0
        renv, NULL,
124
0
        "the %s extension cannot be used in this context "
125
0
        "(needs access to message envelope)",
126
0
        sieve_extension_name(ext));
127
0
    }
128
0
    return SIEVE_EXEC_FAILURE;
129
0
  }
130
0
  return SIEVE_EXEC_OK;
131
0
}