1
/* sieve_interface.h -- interface for deliver
2
* $Id: sieve_interface.h,v 1.1.1.1 2006-06-11 11:03:54 cras Exp $
4
/***********************************************************
5
Copyright 1999 by Carnegie Mellon University
9
Permission to use, copy, modify, and distribute this software and its
10
documentation for any purpose and without fee is hereby granted,
11
provided that the above copyright notice appear in all copies and that
12
both that copyright notice and this permission notice appear in
13
supporting documentation, and that the name of Carnegie Mellon
14
University not be used in advertising or publicity pertaining to
15
distribution of the software without specific, written prior
18
CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
19
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
20
FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE FOR
21
ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
23
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
24
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
******************************************************************/
32
#define SIEVE_VERSION "CMU Sieve 2.2"
37
#include "sieve_err.h"
39
/* external sieve types */
40
typedef struct sieve_interp sieve_interp_t;
41
typedef struct sieve_script sieve_script_t;
42
typedef struct sieve_bytecode sieve_bytecode_t;
43
typedef struct bytecode_info bytecode_info_t;
45
typedef int sieve_callback(void *action_context, void *interp_context,
47
void *message_context, const char **errmsg);
48
typedef int sieve_get_size(void *message_context, int *size);
49
typedef int sieve_get_header(void *message_context,
51
const char ***contents);
52
typedef int sieve_get_envelope(void *message_context,
54
const char ***contents);
56
typedef struct sieve_vacation {
57
int min_response; /* 0 -> defaults to 3 */
58
int max_response; /* 0 -> defaults to 90 */
60
/* given a hash, say whether we've already responded to it in the last
61
days days. return SIEVE_OK if we SHOULD autorespond (have not already)
62
or SIEVE_DONE if we SHOULD NOT. */
63
sieve_callback *autorespond;
65
/* mail the response */
66
sieve_callback *send_response;
69
typedef struct sieve_imapflags {
70
char **flag; /* NULL -> defaults to \flagged */
74
typedef struct sieve_redirect_context {
76
} sieve_redirect_context_t;
78
typedef struct sieve_reject_context {
80
} sieve_reject_context_t;
82
typedef struct sieve_fileinto_context {
84
sieve_imapflags_t *imapflags;
85
} sieve_fileinto_context_t;
87
typedef struct sieve_keep_context {
88
sieve_imapflags_t *imapflags;
89
} sieve_keep_context_t;
91
typedef struct sieve_notify_context {
96
} sieve_notify_context_t;
98
typedef struct sieve_autorespond_context {
102
} sieve_autorespond_context_t;
104
typedef struct sieve_send_response_context {
110
} sieve_send_response_context_t;
112
/* build a sieve interpretor */
113
int sieve_interp_alloc(sieve_interp_t **interp, void *interp_context);
114
int sieve_interp_free(sieve_interp_t **interp);
116
/* add the callbacks for actions. undefined behavior results if these
117
are called after sieve_script_parse is called! */
118
int sieve_register_redirect(sieve_interp_t *interp, sieve_callback *f);
119
int sieve_register_discard(sieve_interp_t *interp, sieve_callback *f);
120
int sieve_register_reject(sieve_interp_t *interp, sieve_callback *f);
121
int sieve_register_fileinto(sieve_interp_t *interp, sieve_callback *f);
122
int sieve_register_keep(sieve_interp_t *interp, sieve_callback *f);
123
int sieve_register_vacation(sieve_interp_t *interp, sieve_vacation_t *v);
124
int sieve_register_imapflags(sieve_interp_t *interp, sieve_imapflags_t *mark);
125
int sieve_register_notify(sieve_interp_t *interp, sieve_callback *f);
127
/* add the callbacks for messages. again, undefined if used after
128
sieve_script_parse */
129
int sieve_register_size(sieve_interp_t *interp, sieve_get_size *f);
130
int sieve_register_header(sieve_interp_t *interp, sieve_get_header *f);
131
int sieve_register_envelope(sieve_interp_t *interp, sieve_get_envelope *f);
133
typedef int sieve_parse_error(int lineno, const char *msg,
134
void *interp_context,
135
void *script_context);
136
int sieve_register_parse_error(sieve_interp_t *interp, sieve_parse_error *f);
138
typedef int sieve_execute_error(const char *msg, void *interp_context,
139
void *script_context, void *message_context);
140
int sieve_register_execute_error(sieve_interp_t *interp,
141
sieve_execute_error *f);
143
/* given an interpretor and a script, produce an executable script */
144
int sieve_script_parse(sieve_interp_t *interp, FILE *script,
145
void *script_context, sieve_script_t **ret);
147
/* given a bytecode file descriptor, setup the sieve_bytecode_t */
148
int sieve_script_load(const char *fname, sieve_bytecode_t **ret);
150
/* Unload a sieve_bytecode_t */
151
int sieve_script_unload(sieve_bytecode_t **s);
153
/* Free a sieve_script_t */
154
int sieve_script_free(sieve_script_t **s);
156
/* execute bytecode on a message */
157
int sieve_execute_bytecode(sieve_bytecode_t *script, sieve_interp_t *interp,
158
void *script_context, void *message_context);
160
/* Get space separated list of extensions supported by the implementation */
161
const char *sieve_listextensions(void);
163
/* Create a bytecode structure given a parsed commandlist */
164
int sieve_generate_bytecode(bytecode_info_t **retval, sieve_script_t *s);
166
/* Emit bytecode to a file descriptor */
167
int sieve_emit_bytecode(int fd, bytecode_info_t *bc);
169
/* Free a bytecode_info_t */
170
void sieve_free_bytecode(bytecode_info_t **p);