summaryrefslogtreecommitdiffstats
path: root/pigeonhole/src/lib-sieve/plugins/variables/ext-variables-common.h
blob: 401d943ba76c14882c2f9653e768372b96a1bb81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef EXT_VARIABLES_COMMON_H
#define EXT_VARIABLES_COMMON_H

#include "sieve-common.h"
#include "sieve-validator.h"

#include "sieve-ext-variables.h"

/*
 * Extension
 */

struct ext_variables_config {
	/* Maximum number of variables (in a scope) */
	unsigned int max_scope_size;
	/* Maximum size of variable value */
	size_t max_variable_size;
};

extern const struct sieve_extension_def variables_extension;

bool ext_variables_load(const struct sieve_extension *ext, void **context);
void ext_variables_unload(const struct sieve_extension *ext);

const struct ext_variables_config *
ext_variables_get_config(const struct sieve_extension *var_ext);

/*
 * Commands
 */

extern const struct sieve_command_def cmd_set;
extern const struct sieve_command_def tst_string;

/*
 * Operands
 */

enum ext_variables_operand {
	EXT_VARIABLES_OPERAND_VARIABLE,
	EXT_VARIABLES_OPERAND_MATCH_VALUE,
	EXT_VARIABLES_OPERAND_NAMESPACE_VARIABLE,
	EXT_VARIABLES_OPERAND_MODIFIER
};

/*
 * Operations
 */

extern const struct sieve_operation_def cmd_set_operation;
extern const struct sieve_operation_def tst_string_operation;

enum ext_variables_opcode {
	EXT_VARIABLES_OPERATION_SET,
	EXT_VARIABLES_OPERATION_STRING
};

/*
 * Validator context
 */

struct ext_variables_validator_context {
	bool active;

	struct sieve_validator_object_registry *modifiers;
	struct sieve_validator_object_registry *namespaces;

	struct sieve_variable_scope *local_scope;
};

void ext_variables_validator_initialize(const struct sieve_extension *this_ext,
					struct sieve_validator *validator);

struct ext_variables_validator_context *
ext_variables_validator_context_get(const struct sieve_extension *this_ext,
				    struct sieve_validator *valdtr);

struct sieve_variable *
ext_variables_validator_get_variable(const struct sieve_extension *this_ext,
				     struct sieve_validator *validator,
				     const char *variable);
struct sieve_variable *
ext_variables_validator_declare_variable(const struct sieve_extension *this_ext,
					 struct sieve_validator *validator,
					 const char *variable);

/*
 * Code generation
 */

bool ext_variables_generator_load(const struct sieve_extension *ext,
				  const struct sieve_codegen_env *cgenv);

/*
 * Interpreter context
 */

bool ext_variables_interpreter_load(const struct sieve_extension *ext,
				    const struct sieve_runtime_env *renv,
				    sieve_size_t *address);

#endif