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/include/ext-include.c
Line
Count
Source
1
/* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file
2
 */
3
4
/* Extension include
5
 * -----------------
6
 *
7
 * Authors: Stephan Bosch
8
 * Specification: RFC 6609
9
 * Implementation: full
10
 * Status: testing
11
 *
12
 */
13
14
/* FIXME: Current include implementation does not allow for parts of the script
15
   to be located in external binaries; all included scripts are recompiled and
16
   the resulting byte code is imported into the main binary in separate blocks.
17
 */
18
19
#include "lib.h"
20
21
#include "sieve-common.h"
22
23
#include "sieve-extensions.h"
24
#include "sieve-validator.h"
25
#include "sieve-generator.h"
26
#include "sieve-interpreter.h"
27
#include "sieve-binary.h"
28
#include "sieve-dump.h"
29
30
#include "sieve-ext-variables.h"
31
32
#include "ext-include-common.h"
33
#include "ext-include-binary.h"
34
#include "ext-include-variables.h"
35
36
/*
37
 * Operations
38
 */
39
40
static const struct sieve_operation_def *ext_include_operations[] = {
41
  &include_operation,
42
  &return_operation,
43
  &global_operation,
44
};
45
46
/*
47
 * Extension
48
 */
49
50
/* Forward declaration */
51
52
static bool
53
ext_include_validator_load(const struct sieve_extension *ext,
54
         struct sieve_validator *validator);
55
static bool
56
ext_include_generator_load(const struct sieve_extension *ext,
57
         const struct sieve_codegen_env *cgenv);
58
static bool
59
ext_include_interpreter_load(const struct sieve_extension *ext,
60
           const struct sieve_runtime_env *renv,
61
           sieve_size_t *address);
62
static bool
63
ext_include_binary_load(const struct sieve_extension *ext,
64
      struct sieve_binary *binary);
65
66
/* Extension objects */
67
68
const struct sieve_extension_def include_extension = {
69
  .name = "include",
70
  .version = 2,
71
72
  .load = ext_include_load,
73
  .unload = ext_include_unload,
74
  .validator_load = ext_include_validator_load,
75
  .generator_load = ext_include_generator_load,
76
  .interpreter_load = ext_include_interpreter_load,
77
  .binary_load = ext_include_binary_load,
78
  .binary_dump = ext_include_binary_dump,
79
  .code_dump = ext_include_code_dump,
80
81
  SIEVE_EXT_DEFINE_OPERATIONS(ext_include_operations),
82
};
83
84
static bool
85
ext_include_validator_load(const struct sieve_extension *ext,
86
         struct sieve_validator *valdtr)
87
0
{
88
  /* Register new commands */
89
0
  sieve_validator_register_command(valdtr, ext, &cmd_include);
90
0
  sieve_validator_register_command(valdtr, ext, &cmd_return);
91
0
  sieve_validator_register_command(valdtr, ext, &cmd_global);
92
93
  /* Initialize global variables namespace */
94
0
  ext_include_variables_global_namespace_init(ext, valdtr);
95
96
0
  return TRUE;
97
0
}
98
99
static bool
100
ext_include_generator_load(const struct sieve_extension *ext,
101
         const struct sieve_codegen_env *cgenv)
102
0
{
103
0
  ext_include_register_generator_context(ext, cgenv);
104
105
0
  return TRUE;
106
0
}
107
108
static bool
109
ext_include_interpreter_load(const struct sieve_extension *ext,
110
           const struct sieve_runtime_env *renv,
111
           sieve_size_t *address ATTR_UNUSED)
112
0
{
113
0
  ext_include_interpreter_context_init(ext, renv->interp);
114
115
0
  return TRUE;
116
0
}
117
118
static bool
119
ext_include_binary_load(const struct sieve_extension *ext,
120
      struct sieve_binary *sbin)
121
0
{
122
0
  (void)ext_include_binary_get_context(ext, sbin);
123
124
0
  return TRUE;
125
0
}