~ubuntu-branches/ubuntu/feisty/dovecot/feisty

« back to all changes in this revision

Viewing changes to dovecot-sieve/src/libsieve/sieve_interface.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2006-11-27 20:47:11 UTC
  • mfrom: (1.10.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20061127204711-z7alg32xp4tnftjs
Tags: 1.0.rc15-1ubuntu1
* Merge from debian unstable. Remaining changes:
  - snakeoil ssl
  - Remove stop script symlinks from rc0 and rc6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 $
 
3
 */
 
4
/***********************************************************
 
5
        Copyright 1999 by Carnegie Mellon University
 
6
 
 
7
                      All Rights Reserved
 
8
 
 
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
 
16
permission.
 
17
 
 
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
******************************************************************/
 
26
 
 
27
#ifndef SIEVE_H
 
28
#define SIEVE_H
 
29
 
 
30
#include <stdio.h>
 
31
 
 
32
#define SIEVE_VERSION "CMU Sieve 2.2"
 
33
 
 
34
/* error codes */
 
35
#define SIEVE_OK (0)
 
36
 
 
37
#include "sieve_err.h"
 
38
 
 
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;
 
44
 
 
45
typedef int sieve_callback(void *action_context, void *interp_context, 
 
46
                           void *script_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, 
 
50
                             const char *header,
 
51
                             const char ***contents);
 
52
typedef int sieve_get_envelope(void *message_context, 
 
53
                               const char *field,
 
54
                               const char ***contents);
 
55
 
 
56
typedef struct sieve_vacation {
 
57
    int min_response;           /* 0 -> defaults to 3 */
 
58
    int max_response;           /* 0 -> defaults to 90 */
 
59
 
 
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;
 
64
 
 
65
    /* mail the response */
 
66
    sieve_callback *send_response;
 
67
} sieve_vacation_t;
 
68
 
 
69
typedef struct sieve_imapflags {
 
70
    char **flag;                /* NULL -> defaults to \flagged */
 
71
    int nflags;
 
72
} sieve_imapflags_t;
 
73
 
 
74
typedef struct sieve_redirect_context {
 
75
    const char *addr;
 
76
} sieve_redirect_context_t;
 
77
 
 
78
typedef struct sieve_reject_context {
 
79
    const char *msg;
 
80
} sieve_reject_context_t;
 
81
 
 
82
typedef struct sieve_fileinto_context {
 
83
    const char *mailbox;
 
84
    sieve_imapflags_t *imapflags;
 
85
} sieve_fileinto_context_t;
 
86
 
 
87
typedef struct sieve_keep_context {
 
88
    sieve_imapflags_t *imapflags;
 
89
} sieve_keep_context_t;
 
90
 
 
91
typedef struct sieve_notify_context {
 
92
    const char *method;
 
93
    const char **options;
 
94
    const char *priority;
 
95
    const char *message;
 
96
} sieve_notify_context_t;
 
97
 
 
98
typedef struct sieve_autorespond_context {
 
99
    unsigned char *hash;
 
100
    int len;
 
101
    int days;
 
102
} sieve_autorespond_context_t;
 
103
 
 
104
typedef struct sieve_send_response_context {
 
105
    char *addr;
 
106
    char *fromaddr;
 
107
    const char *msg;
 
108
    char *subj;
 
109
    int mime;
 
110
} sieve_send_response_context_t;
 
111
 
 
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);
 
115
 
 
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);
 
126
 
 
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);
 
132
 
 
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);
 
137
 
 
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);
 
142
 
 
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);
 
146
 
 
147
/* given a bytecode file descriptor, setup the sieve_bytecode_t */
 
148
int sieve_script_load(const char *fname, sieve_bytecode_t **ret);
 
149
 
 
150
/* Unload a sieve_bytecode_t */
 
151
int sieve_script_unload(sieve_bytecode_t **s);
 
152
 
 
153
/* Free a sieve_script_t */
 
154
int sieve_script_free(sieve_script_t **s);
 
155
 
 
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);
 
159
 
 
160
/* Get space separated list of extensions supported by the implementation */
 
161
const char *sieve_listextensions(void);
 
162
 
 
163
/* Create a bytecode structure given a parsed commandlist */
 
164
int sieve_generate_bytecode(bytecode_info_t **retval, sieve_script_t *s);
 
165
 
 
166
/* Emit bytecode to a file descriptor */
 
167
int sieve_emit_bytecode(int fd, bytecode_info_t *bc);
 
168
 
 
169
/* Free a bytecode_info_t */
 
170
void sieve_free_bytecode(bytecode_info_t **p);
 
171
 
 
172
#endif