Coverage Report

Created: 2026-09-14 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/lib-sieve/plugins/include/ext-include-common.h
Line
Count
Source
1
#ifndef EXT_INCLUDE_COMMON_H
2
#define EXT_INCLUDE_COMMON_H
3
4
#include "lib.h"
5
#include "hash.h"
6
7
#include "sieve-common.h"
8
#include "sieve-extensions.h"
9
#include "sieve-storage.h"
10
11
#include "ext-include-settings.h"
12
13
/*
14
 * Forward declarations
15
 */
16
17
struct ext_include_script_info;
18
struct ext_include_binary_context;
19
20
/*
21
 * Types
22
 */
23
24
enum ext_include_flags { // stored in one byte
25
  EXT_INCLUDE_FLAG_ONCE = 0x01,
26
  EXT_INCLUDE_FLAG_OPTIONAL = 0x02,
27
  EXT_INCLUDE_FLAG_MISSING_AT_UPLOAD = 0x04
28
};
29
30
enum ext_include_script_location {
31
  EXT_INCLUDE_LOCATION_PERSONAL,
32
  EXT_INCLUDE_LOCATION_GLOBAL,
33
  EXT_INCLUDE_LOCATION_INVALID
34
};
35
36
static inline const char *
37
ext_include_script_location_name(enum ext_include_script_location location)
38
0
{
39
0
  switch (location) {
40
0
  case EXT_INCLUDE_LOCATION_PERSONAL:
41
0
    return "personal";
42
0
  case EXT_INCLUDE_LOCATION_GLOBAL:
43
0
    return "global";
44
0
  default:
45
0
    break;
46
0
  }
47
48
0
  return "[INVALID LOCATION]";
49
0
}
Unexecuted instantiation: ext-include.c:ext_include_script_location_name
Unexecuted instantiation: cmd-global.c:ext_include_script_location_name
Unexecuted instantiation: cmd-include.c:ext_include_script_location_name
Unexecuted instantiation: cmd-return.c:ext_include_script_location_name
Unexecuted instantiation: ext-include-binary.c:ext_include_script_location_name
Unexecuted instantiation: ext-include-common.c:ext_include_script_location_name
Unexecuted instantiation: ext-include-variables.c:ext_include_script_location_name
50
51
52
/*
53
 * Extension
54
 */
55
56
extern const struct sieve_extension_def include_extension;
57
extern const struct sieve_binary_extension include_binary_ext;
58
59
int ext_include_load(const struct sieve_extension *ext, void **context_r);
60
void ext_include_unload(const struct sieve_extension *ext);
61
62
/*
63
 * Commands
64
 */
65
66
extern const struct sieve_command_def cmd_include;
67
extern const struct sieve_command_def cmd_return;
68
extern const struct sieve_command_def cmd_global;
69
70
/*
71
 * Operations
72
 */
73
74
enum ext_include_opcode {
75
  EXT_INCLUDE_OPERATION_INCLUDE,
76
  EXT_INCLUDE_OPERATION_RETURN,
77
  EXT_INCLUDE_OPERATION_GLOBAL
78
};
79
80
extern const struct sieve_operation_def include_operation;
81
extern const struct sieve_operation_def return_operation;
82
extern const struct sieve_operation_def global_operation;
83
84
/*
85
 * Script access
86
 */
87
88
int ext_include_open_script(const struct sieve_extension *ext,
89
          enum ext_include_script_location location,
90
          const char *cause, const char *script_name,
91
          struct sieve_script **script_r,
92
          enum sieve_error *error_code_r);
93
94
/*
95
 * Context
96
 */
97
98
/* Extension context */
99
100
struct ext_include_context {
101
  /* Extension dependencies */
102
  const struct sieve_extension *var_ext;
103
104
  struct sieve_storage *personal_storage;
105
106
  const struct ext_include_settings *set;
107
};
108
109
static inline struct ext_include_context *
110
ext_include_get_context(const struct sieve_extension *ext)
111
0
{
112
0
  return ext->context;
113
0
}
Unexecuted instantiation: ext-include.c:ext_include_get_context
Unexecuted instantiation: cmd-global.c:ext_include_get_context
Unexecuted instantiation: cmd-include.c:ext_include_get_context
Unexecuted instantiation: cmd-return.c:ext_include_get_context
Unexecuted instantiation: ext-include-binary.c:ext_include_get_context
Unexecuted instantiation: ext-include-common.c:ext_include_get_context
Unexecuted instantiation: ext-include-variables.c:ext_include_get_context
114
115
/* AST Context */
116
117
struct ext_include_ast_context {
118
  struct sieve_variable_scope *global_vars;
119
120
  ARRAY(struct sieve_script *) included_scripts;
121
};
122
123
struct ext_include_ast_context *
124
ext_include_create_ast_context(const struct sieve_extension *this_ext,
125
             struct sieve_ast *ast, struct sieve_ast *parent);
126
struct ext_include_ast_context *
127
ext_include_get_ast_context(const struct sieve_extension *this_ext,
128
          struct sieve_ast *ast);
129
130
void ext_include_ast_link_included_script(
131
  const struct sieve_extension *this_ext, struct sieve_ast *ast,
132
  struct sieve_script *script);
133
134
bool ext_include_validator_have_variables(
135
  const struct sieve_extension *this_ext, struct sieve_validator *valdtr);
136
137
/* Generator context */
138
139
void ext_include_register_generator_context(
140
  const struct sieve_extension *this_ext,
141
  const struct sieve_codegen_env *cgenv);
142
143
int ext_include_generate_include(
144
  const struct sieve_codegen_env *cgenv, struct sieve_command *cmd,
145
  enum ext_include_script_location location, const char *script_name,
146
  enum ext_include_flags flags, struct sieve_script *script,
147
  const struct ext_include_script_info **included_r);
148
149
/* Interpreter context */
150
151
void ext_include_interpreter_context_init(
152
  const struct sieve_extension *this_ext,
153
  struct sieve_interpreter *interp);
154
155
int ext_include_execute_include(const struct sieve_runtime_env *renv,
156
        unsigned int block_id,
157
        enum ext_include_flags flags);
158
void ext_include_execute_return(const struct sieve_runtime_env *renv);
159
160
struct sieve_variable_storage *
161
ext_include_interpreter_get_global_variables(
162
  const struct sieve_extension *this_ext,
163
  struct sieve_interpreter *interp);
164
165
#endif