summaryrefslogtreecommitdiffstats
path: root/pigeonhole/src/lib-sieve/sieve-common.h
blob: e79fb4da9336ecf9dbf11578581cb2d8c8136814 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#ifndef SIEVE_COMMON_H
#define SIEVE_COMMON_H

#include "lib.h"

#include "sieve.h"

#include <sys/types.h>

/*
 * Types
 */

typedef size_t sieve_size_t;
typedef uint32_t sieve_offset_t;
typedef uint64_t sieve_number_t;

#define SIEVE_MAX_NUMBER ((sieve_number_t)-1)
#define SIEVE_PRI_NUMBER PRIu64

/*
 * Forward declarations
 */

/* sieve-error.h */
struct sieve_error_handler;

/* sieve-ast.h */
enum sieve_ast_argument_type;

struct sieve_ast;
struct sieve_ast_node;
struct sieve_ast_argument;

/* sieve-commands.h */
struct sieve_argument;
struct sieve_argument_def;
struct sieve_command;
struct sieve_command_def;
struct sieve_command_context;
struct sieve_command_registration;

/* sieve-stringlist.h */
struct sieve_stringlist;

/* sieve-code.h */
struct sieve_operation_extension;

/* sieve-lexer.h */
struct sieve_lexer;

/* sieve-parser.h */
struct sieve_parser;

/* sieve-validator.h */
struct sieve_validator;

/* sieve-generator.h */
struct sieve_jumplist;
struct sieve_generator;
struct sieve_codegen_env;

/* sieve-runtime.h */
struct sieve_runtime_env;

/* sieve-interpreter.h */
struct sieve_interpreter;

/* sieve-dump.h */
struct sieve_dumptime_env;

/* sieve-binary-dumper.h */
struct sieve_binary_dumper;

/* sieve-code-dumper.h */
struct sieve_code_dumper;

/* sieve-extension.h */
struct sieve_extension;
struct sieve_extension_def;
struct sieve_extension_objects;

/* sieve-code.h */
struct sieve_operand;
struct sieve_operand_def;
struct sieve_operand_class;
struct sieve_operation;
struct sieve_coded_stringlist;

/* sieve-binary.h */
struct sieve_binary;
struct sieve_binary_block;
struct sieve_binary_debug_writer;
struct sieve_binary_debug_reader;

/* sieve-execute.h */
struct sieve_execute;

/* sieve-objects.h */
struct sieve_object_def;
struct sieve_object;

/* sieve-comparator.h */
struct sieve_comparator;

/* sieve-match-types.h */
struct sieve_match_type;

/* sieve-match.h */
struct sieve_match_context;

/* sieve-address.h */
struct sieve_address_list;

/* sieve-address-parts.h */
struct sieve_address_part_def;
struct sieve_address_part;

/* sieve-result.h */
struct sieve_result;
struct sieve_side_effects_list;
struct sieve_result_print_env;

/* sieve-actions.h */
struct sieve_action_exec_env;
struct sieve_action;
struct sieve_action_def;
struct sieve_side_effect;
struct sieve_side_effect_def;

/* sieve-script.h */
struct sieve_script;
struct sieve_script_sequence;

/* sieve-storage.h */
struct sieve_storage_class_registry;
struct sieve_storage;

/* sieve-message.h */
struct sieve_message_context;
struct sieve_message_override;
struct sieve_message_override_def;

/* sieve-plugins.h */
struct sieve_plugin;

/* sieve.c */
struct sieve_ast *sieve_parse
	(struct sieve_script *script, struct sieve_error_handler *ehandler,
		enum sieve_error *error_r);
bool sieve_validate
	(struct sieve_ast *ast, struct sieve_error_handler *ehandler,
		enum sieve_compile_flags flags, enum sieve_error *error_r);

/*
 * Parent category
 */

extern struct event_category event_category_sieve;

/*
 * Sieve engine instance
 */

#include "sieve-address-source.h"

struct sieve_instance {
	/* Main engine pool */
	pool_t pool;

	/* System environment */
	const char *hostname;
	const char *domainname;
	const char *base_dir;
	const char *temp_dir;

	/* User environment */
	const char *username;
	const char *home_dir;

	/* Flags */
	enum sieve_flag flags;

	/* Callbacks */
	const struct sieve_callbacks *callbacks;
	void *context;

	/* Logging, events, and debug */
	struct event *event;
	bool debug;

	/* Extension registry */
	struct sieve_extension_registry *ext_reg;

	/* Storage class registry */
	struct sieve_storage_class_registry *storage_reg;

	/* Plugin modules */
	struct sieve_plugin *plugins;
	enum sieve_env_location env_location;
	enum sieve_delivery_phase delivery_phase;

	/* Settings */
	size_t max_script_size;
	unsigned int max_actions;
	unsigned int max_redirects;
	unsigned int max_cpu_time_secs;
	unsigned int resource_usage_timeout_secs;
	const struct smtp_address *user_email, *user_email_implicit;
	struct sieve_address_source redirect_from;
	unsigned int redirect_duplicate_period;
};

/*
 * Script trace log
 */

void sieve_trace_log_write_line
	(struct sieve_trace_log *trace_log, const string_t *line)
	ATTR_NULL(2);

/*
 * User e-mail address
 */

const struct smtp_address *sieve_get_user_email
	(struct sieve_instance *svinst);

/*
 * Postmaster address 
 */

const struct message_address *
sieve_get_postmaster(const struct sieve_script_env *senv);
const struct smtp_address *
sieve_get_postmaster_smtp(const struct sieve_script_env *senv);
const char *
sieve_get_postmaster_address(const struct sieve_script_env *senv);

#endif