(MU_SIEVE_CHARSET): New define
Showing
1 changed file
with
62 additions
and
42 deletions
... | @@ -32,10 +32,12 @@ extern "C" { | ... | @@ -32,10 +32,12 @@ extern "C" { |
32 | 32 | ||
33 | typedef struct sieve_machine *mu_sieve_machine_t; | 33 | typedef struct sieve_machine *mu_sieve_machine_t; |
34 | 34 | ||
35 | typedef struct { | 35 | typedef struct |
36 | { | ||
36 | const char *source_file; | 37 | const char *source_file; |
37 | size_t source_line; | 38 | size_t source_line; |
38 | } mu_sieve_locus_t; | 39 | } |
40 | mu_sieve_locus_t; | ||
39 | 41 | ||
40 | typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach, | 42 | typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach, |
41 | mu_list_t args, mu_list_t tags); | 43 | mu_list_t args, mu_list_t tags); |
... | @@ -44,7 +46,7 @@ typedef int (*mu_sieve_parse_error_t) (void *data, | ... | @@ -44,7 +46,7 @@ typedef int (*mu_sieve_parse_error_t) (void *data, |
44 | const char *filename, int lineno, | 46 | const char *filename, int lineno, |
45 | const char *fmt, va_list ap); | 47 | const char *fmt, va_list ap); |
46 | typedef void (*mu_sieve_action_log_t) (void *data, | 48 | typedef void (*mu_sieve_action_log_t) (void *data, |
47 | const mu_sieve_locus_t *locus, | 49 | const mu_sieve_locus_t * locus, |
48 | size_t msgno, mu_message_t msg, | 50 | size_t msgno, mu_message_t msg, |
49 | const char *action, | 51 | const char *action, |
50 | const char *fmt, va_list ap); | 52 | const char *fmt, va_list ap); |
... | @@ -52,12 +54,14 @@ typedef void (*mu_sieve_action_log_t) (void *data, | ... | @@ -52,12 +54,14 @@ typedef void (*mu_sieve_action_log_t) (void *data, |
52 | typedef int (*mu_sieve_relcmp_t) (int, int); | 54 | typedef int (*mu_sieve_relcmp_t) (int, int); |
53 | typedef int (*mu_sieve_relcmpn_t) (size_t, size_t); | 55 | typedef int (*mu_sieve_relcmpn_t) (size_t, size_t); |
54 | typedef int (*mu_sieve_comparator_t) (const char *, const char *); | 56 | typedef int (*mu_sieve_comparator_t) (const char *, const char *); |
55 | typedef int (*mu_sieve_retrieve_t) (void *item, void *data, int idx, char **pval); | 57 | typedef int (*mu_sieve_retrieve_t) (void *item, void *data, int idx, |
58 | char **pval); | ||
56 | typedef void (*mu_sieve_destructor_t) (void *data); | 59 | typedef void (*mu_sieve_destructor_t) (void *data); |
57 | typedef int (*mu_sieve_tag_checker_t) (const char *name, | 60 | typedef int (*mu_sieve_tag_checker_t) (const char *name, |
58 | mu_list_t tags, mu_list_t args); | 61 | mu_list_t tags, mu_list_t args); |
59 | 62 | ||
60 | typedef enum { | 63 | typedef enum |
64 | { | ||
61 | SVT_VOID, | 65 | SVT_VOID, |
62 | SVT_NUMBER, | 66 | SVT_NUMBER, |
63 | SVT_STRING, | 67 | SVT_STRING, |
... | @@ -66,13 +70,16 @@ typedef enum { | ... | @@ -66,13 +70,16 @@ typedef enum { |
66 | SVT_IDENT, | 70 | SVT_IDENT, |
67 | SVT_VALUE_LIST, | 71 | SVT_VALUE_LIST, |
68 | SVT_POINTER | 72 | SVT_POINTER |
69 | } mu_sieve_data_type; | 73 | } |
74 | mu_sieve_data_type; | ||
70 | 75 | ||
71 | typedef struct mu_sieve_runtime_tag mu_sieve_runtime_tag_t; | 76 | typedef struct mu_sieve_runtime_tag mu_sieve_runtime_tag_t; |
72 | 77 | ||
73 | typedef struct { | 78 | typedef struct |
79 | { | ||
74 | mu_sieve_data_type type; | 80 | mu_sieve_data_type type; |
75 | union { | 81 | union |
82 | { | ||
76 | char *string; | 83 | char *string; |
77 | size_t number; | 84 | size_t number; |
78 | mu_list_t list; | 85 | mu_list_t list; |
... | @@ -81,22 +88,26 @@ typedef struct { | ... | @@ -81,22 +88,26 @@ typedef struct { |
81 | } v; | 88 | } v; |
82 | } mu_sieve_value_t; | 89 | } mu_sieve_value_t; |
83 | 90 | ||
84 | typedef struct { | 91 | typedef struct |
92 | { | ||
85 | char *name; | 93 | char *name; |
86 | mu_sieve_data_type argtype; | 94 | mu_sieve_data_type argtype; |
87 | } mu_sieve_tag_def_t; | 95 | } mu_sieve_tag_def_t; |
88 | 96 | ||
89 | typedef struct { | 97 | typedef struct |
98 | { | ||
90 | mu_sieve_tag_def_t *tags; | 99 | mu_sieve_tag_def_t *tags; |
91 | mu_sieve_tag_checker_t checker; | 100 | mu_sieve_tag_checker_t checker; |
92 | } mu_sieve_tag_group_t; | 101 | } mu_sieve_tag_group_t; |
93 | 102 | ||
94 | struct mu_sieve_runtime_tag { | 103 | struct mu_sieve_runtime_tag |
104 | { | ||
95 | char *tag; | 105 | char *tag; |
96 | mu_sieve_value_t *arg; | 106 | mu_sieve_value_t *arg; |
97 | }; | 107 | }; |
98 | 108 | ||
99 | typedef struct { | 109 | typedef struct |
110 | { | ||
100 | const char *name; | 111 | const char *name; |
101 | int required; | 112 | int required; |
102 | mu_sieve_handler_t handler; | 113 | mu_sieve_handler_t handler; |
... | @@ -104,6 +115,8 @@ typedef struct { | ... | @@ -104,6 +115,8 @@ typedef struct { |
104 | mu_sieve_tag_group_t *tags; | 115 | mu_sieve_tag_group_t *tags; |
105 | } mu_sieve_register_t; | 116 | } mu_sieve_register_t; |
106 | 117 | ||
118 | #define MU_SIEVE_CHARSET "UTF-8" | ||
119 | |||
107 | #define MU_SIEVE_MATCH_IS 1 | 120 | #define MU_SIEVE_MATCH_IS 1 |
108 | #define MU_SIEVE_MATCH_CONTAINS 2 | 121 | #define MU_SIEVE_MATCH_CONTAINS 2 |
109 | #define MU_SIEVE_MATCH_MATCHES 3 | 122 | #define MU_SIEVE_MATCH_MATCHES 3 |
... | @@ -123,10 +136,10 @@ extern mu_list_t mu_sieve_library_path; | ... | @@ -123,10 +136,10 @@ extern mu_list_t mu_sieve_library_path; |
123 | 136 | ||
124 | /* Memory allocation functions */ | 137 | /* Memory allocation functions */ |
125 | void *mu_sieve_alloc (size_t size); | 138 | void *mu_sieve_alloc (size_t size); |
126 | void *mu_sieve_palloc (mu_list_t *pool, size_t size); | 139 | void *mu_sieve_palloc (mu_list_t * pool, size_t size); |
127 | void *mu_sieve_prealloc (mu_list_t *pool, void *ptr, size_t size); | 140 | void *mu_sieve_prealloc (mu_list_t * pool, void *ptr, size_t size); |
128 | void mu_sieve_pfree (mu_list_t *pool, void *ptr); | 141 | void mu_sieve_pfree (mu_list_t * pool, void *ptr); |
129 | char *mu_sieve_pstrdup (mu_list_t *pool, const char *str); | 142 | char *mu_sieve_pstrdup (mu_list_t * pool, const char *str); |
130 | 143 | ||
131 | void *mu_sieve_malloc (mu_sieve_machine_t mach, size_t size); | 144 | void *mu_sieve_malloc (mu_sieve_machine_t mach, size_t size); |
132 | char *mu_sieve_mstrdup (mu_sieve_machine_t mach, const char *str); | 145 | char *mu_sieve_mstrdup (mu_sieve_machine_t mach, const char *str); |
... | @@ -134,7 +147,7 @@ void *mu_sieve_mrealloc (mu_sieve_machine_t mach, void *ptr, size_t size); | ... | @@ -134,7 +147,7 @@ void *mu_sieve_mrealloc (mu_sieve_machine_t mach, void *ptr, size_t size); |
134 | void mu_sieve_mfree (mu_sieve_machine_t mach, void *ptr); | 147 | void mu_sieve_mfree (mu_sieve_machine_t mach, void *ptr); |
135 | 148 | ||
136 | mu_sieve_value_t *mu_sieve_value_create (mu_sieve_data_type type, void *data); | 149 | mu_sieve_value_t *mu_sieve_value_create (mu_sieve_data_type type, void *data); |
137 | void mu_sieve_slist_destroy (mu_list_t *plist); | 150 | void mu_sieve_slist_destroy (mu_list_t * plist); |
138 | 151 | ||
139 | /* Symbol space functions */ | 152 | /* Symbol space functions */ |
140 | mu_sieve_register_t *mu_sieve_test_lookup (mu_sieve_machine_t mach, | 153 | mu_sieve_register_t *mu_sieve_test_lookup (mu_sieve_machine_t mach, |
... | @@ -143,12 +156,12 @@ mu_sieve_register_t *mu_sieve_action_lookup (mu_sieve_machine_t mach, | ... | @@ -143,12 +156,12 @@ mu_sieve_register_t *mu_sieve_action_lookup (mu_sieve_machine_t mach, |
143 | const char *name); | 156 | const char *name); |
144 | int mu_sieve_register_test (mu_sieve_machine_t mach, | 157 | int mu_sieve_register_test (mu_sieve_machine_t mach, |
145 | const char *name, mu_sieve_handler_t handler, | 158 | const char *name, mu_sieve_handler_t handler, |
146 | mu_sieve_data_type *arg_types, | 159 | mu_sieve_data_type * arg_types, |
147 | mu_sieve_tag_group_t *tags, int required); | 160 | mu_sieve_tag_group_t * tags, int required); |
148 | int mu_sieve_register_action (mu_sieve_machine_t mach, | 161 | int mu_sieve_register_action (mu_sieve_machine_t mach, |
149 | const char *name, mu_sieve_handler_t handler, | 162 | const char *name, mu_sieve_handler_t handler, |
150 | mu_sieve_data_type *arg_types, | 163 | mu_sieve_data_type * arg_types, |
151 | mu_sieve_tag_group_t *tags, int required); | 164 | mu_sieve_tag_group_t * tags, int required); |
152 | int mu_sieve_register_comparator (mu_sieve_machine_t mach, const char *name, | 165 | int mu_sieve_register_comparator (mu_sieve_machine_t mach, const char *name, |
153 | int required, mu_sieve_comparator_t is, | 166 | int required, mu_sieve_comparator_t is, |
154 | mu_sieve_comparator_t contains, | 167 | mu_sieve_comparator_t contains, |
... | @@ -164,31 +177,34 @@ mu_sieve_comparator_t mu_sieve_comparator_lookup (mu_sieve_machine_t mach, | ... | @@ -164,31 +177,34 @@ mu_sieve_comparator_t mu_sieve_comparator_lookup (mu_sieve_machine_t mach, |
164 | const char *name, | 177 | const char *name, |
165 | int matchtype); | 178 | int matchtype); |
166 | 179 | ||
167 | mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach, mu_list_t tags); | 180 | mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach, |
168 | int mu_sieve_str_to_relcmp (const char *str, | 181 | mu_list_t tags); |
169 | mu_sieve_relcmp_t *test, mu_sieve_relcmpn_t *stest); | 182 | int mu_sieve_str_to_relcmp (const char *str, mu_sieve_relcmp_t * test, |
170 | mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach, mu_list_t tags); | 183 | mu_sieve_relcmpn_t * stest); |
184 | mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach, | ||
185 | mu_list_t tags); | ||
171 | 186 | ||
172 | void mu_sieve_require (mu_list_t slist); | 187 | void mu_sieve_require (mu_list_t slist); |
173 | int mu_sieve_tag_lookup (mu_list_t taglist, char *name, mu_sieve_value_t **arg); | 188 | int mu_sieve_tag_lookup (mu_list_t taglist, char *name, |
189 | mu_sieve_value_t ** arg); | ||
174 | int mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name); | 190 | int mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name); |
175 | int mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args); | 191 | int mu_sieve_match_part_checker (const char *name, mu_list_t tags, |
192 | mu_list_t args); | ||
176 | 193 | ||
177 | /* Operations in value lists */ | 194 | /* Operations in value lists */ |
178 | mu_sieve_value_t *mu_sieve_value_get (mu_list_t vlist, size_t index); | 195 | mu_sieve_value_t *mu_sieve_value_get (mu_list_t vlist, size_t index); |
179 | int mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t *ac, void *data); | 196 | int mu_sieve_vlist_do (mu_sieve_value_t * val, mu_list_action_t * ac, |
180 | int mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b, | 197 | void *data); |
181 | mu_sieve_comparator_t comp, mu_sieve_relcmp_t test, | 198 | int mu_sieve_vlist_compare (mu_sieve_value_t * a, mu_sieve_value_t * b, |
182 | mu_sieve_retrieve_t ac, | 199 | mu_sieve_comparator_t comp, |
183 | void *data, | 200 | mu_sieve_relcmp_t test, mu_sieve_retrieve_t ac, |
184 | size_t *count); | 201 | void *data, size_t * count); |
185 | 202 | ||
186 | /* Functions to create and destroy sieve machine */ | 203 | /* Functions to create and destroy sieve machine */ |
187 | int mu_sieve_machine_init (mu_sieve_machine_t *mach, void *data); | 204 | int mu_sieve_machine_init (mu_sieve_machine_t * mach, void *data); |
188 | void mu_sieve_machine_destroy (mu_sieve_machine_t *pmach); | 205 | void mu_sieve_machine_destroy (mu_sieve_machine_t * pmach); |
189 | int mu_sieve_machine_add_destructor (mu_sieve_machine_t mach, | 206 | int mu_sieve_machine_add_destructor (mu_sieve_machine_t mach, |
190 | mu_sieve_destructor_t destr, | 207 | mu_sieve_destructor_t destr, void *ptr); |
191 | void *ptr); | ||
192 | 208 | ||
193 | /* Functions for accessing sieve machine internals */ | 209 | /* Functions for accessing sieve machine internals */ |
194 | void *mu_sieve_get_data (mu_sieve_machine_t mach); | 210 | void *mu_sieve_get_data (mu_sieve_machine_t mach); |
... | @@ -201,11 +217,15 @@ int mu_sieve_get_locus (mu_sieve_machine_t mach, mu_sieve_locus_t *); | ... | @@ -201,11 +217,15 @@ int mu_sieve_get_locus (mu_sieve_machine_t mach, mu_sieve_locus_t *); |
201 | char *mu_sieve_get_daemon_email (mu_sieve_machine_t mach); | 217 | char *mu_sieve_get_daemon_email (mu_sieve_machine_t mach); |
202 | const char *mu_sieve_get_identifier (mu_sieve_machine_t mach); | 218 | const char *mu_sieve_get_identifier (mu_sieve_machine_t mach); |
203 | 219 | ||
204 | void mu_sieve_set_error (mu_sieve_machine_t mach, mu_sieve_printf_t error_printer); | 220 | void mu_sieve_set_error (mu_sieve_machine_t mach, |
205 | void mu_sieve_set_parse_error (mu_sieve_machine_t mach, mu_sieve_parse_error_t p); | 221 | mu_sieve_printf_t error_printer); |
222 | void mu_sieve_set_parse_error (mu_sieve_machine_t mach, | ||
223 | mu_sieve_parse_error_t p); | ||
206 | void mu_sieve_set_debug (mu_sieve_machine_t mach, mu_sieve_printf_t debug); | 224 | void mu_sieve_set_debug (mu_sieve_machine_t mach, mu_sieve_printf_t debug); |
207 | void mu_sieve_set_debug_level (mu_sieve_machine_t mach, mu_debug_t dbg, int level); | 225 | void mu_sieve_set_debug_level (mu_sieve_machine_t mach, mu_debug_t dbg, |
208 | void mu_sieve_set_logger (mu_sieve_machine_t mach, mu_sieve_action_log_t logger); | 226 | int level); |
227 | void mu_sieve_set_logger (mu_sieve_machine_t mach, | ||
228 | mu_sieve_action_log_t logger); | ||
209 | void mu_sieve_set_ticket (mu_sieve_machine_t mach, mu_ticket_t ticket); | 229 | void mu_sieve_set_ticket (mu_sieve_machine_t mach, mu_ticket_t ticket); |
210 | void mu_sieve_set_mailer (mu_sieve_machine_t mach, mu_mailer_t mailer); | 230 | void mu_sieve_set_mailer (mu_sieve_machine_t mach, mu_mailer_t mailer); |
211 | void mu_sieve_set_daemon_email (mu_sieve_machine_t mach, const char *email); | 231 | void mu_sieve_set_daemon_email (mu_sieve_machine_t mach, const char *email); |
... | @@ -219,7 +239,7 @@ void mu_sieve_debug (mu_sieve_machine_t mach, const char *fmt, ...); | ... | @@ -219,7 +239,7 @@ void mu_sieve_debug (mu_sieve_machine_t mach, const char *fmt, ...); |
219 | void mu_sieve_log_action (mu_sieve_machine_t mach, const char *action, | 239 | void mu_sieve_log_action (mu_sieve_machine_t mach, const char *action, |
220 | const char *fmt, ...); | 240 | const char *fmt, ...); |
221 | void mu_sieve_abort (mu_sieve_machine_t mach); | 241 | void mu_sieve_abort (mu_sieve_machine_t mach); |
222 | int mu_stream_printf (mu_stream_t stream, size_t *off, const char *fmt, ...); | 242 | int mu_stream_printf (mu_stream_t stream, size_t * off, const char *fmt, ...); |
223 | void mu_sieve_arg_error (mu_sieve_machine_t mach, int n); | 243 | void mu_sieve_arg_error (mu_sieve_machine_t mach, int n); |
224 | 244 | ||
225 | int mu_sieve_is_dry_run (mu_sieve_machine_t mach); | 245 | int mu_sieve_is_dry_run (mu_sieve_machine_t mach); | ... | ... |
-
Please register or sign in to post a comment