Coverage Report

Created: 2026-07-30 06:43

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