Commit e5b11edf e5b11edf9793f392bc9da33ddc4fd0639376df43 by Sergey Poznyakoff

Finish namespace cleanup in libsieve.

* libsieve/actions.c, libsieve/comparator.c, libsieve/conf.c,
libsieve/load.c, libsieve/prog.c, libsieve/register.c,
libsieve/relational.c, libsieve/require.c, libsieve/runtime.c,
libsieve/sieve.h, libsieve/sieve.l, libsieve/sieve.y,
libsieve/tests.c, libsieve/util.c: Prefix all external
identifiers, that are not intended for use by application
programs, with mu_sv_.
1 parent 69b1db83
1 2008-07-19 Sergey Poznyakoff <gray@gnu.org.ua> 1 2008-07-19 Sergey Poznyakoff <gray@gnu.org.ua>
2 2
3 Finish namespace cleanup in libsieve.
4
5 * libsieve/actions.c, libsieve/comparator.c, libsieve/conf.c,
6 libsieve/load.c, libsieve/prog.c, libsieve/register.c,
7 libsieve/relational.c, libsieve/require.c, libsieve/runtime.c,
8 libsieve/sieve.h, libsieve/sieve.l, libsieve/sieve.y,
9 libsieve/tests.c, libsieve/util.c: Prefix all external
10 identifiers, that are not intended for use by application
11 programs, with mu_sv_.
12
3 Minor fixes. 13 Minor fixes.
4 14
5 * NEWS, configure.ac: Raise version to 1.9.91 15 * NEWS, configure.ac: Raise version to 1.9.91
......
...@@ -31,7 +31,7 @@ extern "C" { ...@@ -31,7 +31,7 @@ extern "C" {
31 #define __s_cat3__(a,b,c) a ## b ## c 31 #define __s_cat3__(a,b,c) a ## b ## c
32 #define SIEVE_EXPORT(module,name) __s_cat3__(module,_LTX_,name) 32 #define SIEVE_EXPORT(module,name) __s_cat3__(module,_LTX_,name)
33 33
34 typedef struct sieve_machine *mu_sieve_machine_t; 34 typedef struct mu_sieve_machine *mu_sieve_machine_t;
35 35
36 typedef struct 36 typedef struct
37 { 37 {
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2005, 2 Copyright (C) 1999, 2000, 2001, 2002, 2005,
3 2006, 2007 Free Software Foundation, Inc. 3 2006, 2007, 2008 Free Software Foundation, Inc.
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
...@@ -27,7 +27,27 @@ ...@@ -27,7 +27,27 @@
27 #include <string.h> 27 #include <string.h>
28 #include <sieve.h> 28 #include <sieve.h>
29 29
30 int 30 static int
31 sieve_mark_deleted (mu_message_t msg, int deleted)
32 {
33 mu_attribute_t attr = 0;
34 int rc;
35
36 rc = mu_message_get_attribute (msg, &attr);
37
38 if (!rc)
39 {
40 if (deleted)
41 rc = mu_attribute_set_deleted (attr);
42 else
43 rc = mu_attribute_unset_deleted (attr);
44 }
45
46 return rc;
47 }
48
49
50 static int
31 sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) 51 sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
32 { 52 {
33 mu_sieve_log_action (mach, "STOP", NULL); 53 mu_sieve_log_action (mach, "STOP", NULL);
...@@ -35,7 +55,7 @@ sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) ...@@ -35,7 +55,7 @@ sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
35 return 0; 55 return 0;
36 } 56 }
37 57
38 int 58 static int
39 sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) 59 sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
40 { 60 {
41 mu_sieve_log_action (mach, "KEEP", NULL); 61 mu_sieve_log_action (mach, "KEEP", NULL);
...@@ -45,7 +65,7 @@ sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) ...@@ -45,7 +65,7 @@ sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
45 return 0; 65 return 0;
46 } 66 }
47 67
48 int 68 static int
49 sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) 69 sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
50 { 70 {
51 mu_sieve_log_action (mach, "DISCARD", _("marking as deleted")); 71 mu_sieve_log_action (mach, "DISCARD", _("marking as deleted"));
...@@ -55,7 +75,7 @@ sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) ...@@ -55,7 +75,7 @@ sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
55 return 0; 75 return 0;
56 } 76 }
57 77
58 int 78 static int
59 sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) 79 sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
60 { 80 {
61 int rc; 81 int rc;
...@@ -253,7 +273,7 @@ build_mime (mu_mime_t *pmime, mu_message_t msg, const char *text) ...@@ -253,7 +273,7 @@ build_mime (mu_mime_t *pmime, mu_message_t msg, const char *text)
253 return 0; 273 return 0;
254 } 274 }
255 275
256 int 276 static int
257 sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) 277 sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
258 { 278 {
259 mu_mime_t mime = NULL; 279 mu_mime_t mime = NULL;
...@@ -370,7 +390,7 @@ check_redirect_loop (mu_message_t msg) ...@@ -370,7 +390,7 @@ check_redirect_loop (mu_message_t msg)
370 return loop; 390 return loop;
371 } 391 }
372 392
373 int 393 static int
374 sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) 394 sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags)
375 { 395 {
376 mu_message_t msg, newmsg = NULL; 396 mu_message_t msg, newmsg = NULL;
...@@ -487,7 +507,7 @@ mu_sieve_data_type fileinto_args[] = { ...@@ -487,7 +507,7 @@ mu_sieve_data_type fileinto_args[] = {
487 }; 507 };
488 508
489 void 509 void
490 sieve_register_standard_actions (mu_sieve_machine_t mach) 510 mu_sv_register_standard_actions (mu_sieve_machine_t mach)
491 { 511 {
492 mu_sieve_register_action (mach, "stop", sieve_action_stop, NULL, NULL, 1); 512 mu_sieve_register_action (mach, "stop", sieve_action_stop, NULL, NULL, 1);
493 mu_sieve_register_action (mach, "keep", sieve_action_keep, NULL, NULL, 1); 513 mu_sieve_register_action (mach, "keep", sieve_action_keep, NULL, NULL, 1);
......
...@@ -40,7 +40,8 @@ int ...@@ -40,7 +40,8 @@ int
40 mu_sieve_register_comparator (mu_sieve_machine_t mach, 40 mu_sieve_register_comparator (mu_sieve_machine_t mach,
41 const char *name, 41 const char *name,
42 int required, 42 int required,
43 mu_sieve_comparator_t is, mu_sieve_comparator_t contains, 43 mu_sieve_comparator_t is,
44 mu_sieve_comparator_t contains,
44 mu_sieve_comparator_t matches, 45 mu_sieve_comparator_t matches,
45 mu_sieve_comparator_t regex, 46 mu_sieve_comparator_t regex,
46 mu_sieve_comparator_t eq) 47 mu_sieve_comparator_t eq)
...@@ -103,7 +104,8 @@ mu_sieve_require_comparator (mu_sieve_machine_t mach, const char *name) ...@@ -103,7 +104,8 @@ mu_sieve_require_comparator (mu_sieve_machine_t mach, const char *name)
103 } 104 }
104 105
105 mu_sieve_comparator_t 106 mu_sieve_comparator_t
106 mu_sieve_comparator_lookup (mu_sieve_machine_t mach, const char *name, int matchtype) 107 mu_sieve_comparator_lookup (mu_sieve_machine_t mach, const char *name,
108 int matchtype)
107 { 109 {
108 sieve_comparator_record_t *reg = _lookup (mach->comp_list, name); 110 sieve_comparator_record_t *reg = _lookup (mach->comp_list, name);
109 if (reg && reg->comp[matchtype]) 111 if (reg && reg->comp[matchtype])
...@@ -159,7 +161,7 @@ _regex_compile (void *item, void *data) ...@@ -159,7 +161,7 @@ _regex_compile (void *item, void *data)
159 { 161 {
160 struct regex_data *rd = data; 162 struct regex_data *rd = data;
161 int rc; 163 int rc;
162 regex_t *preg = mu_sieve_malloc (sieve_machine, sizeof (*preg)); 164 regex_t *preg = mu_sieve_malloc (mu_sieve_machine, sizeof (*preg));
163 165
164 rc = regcomp (preg, (char*)item, rd->flags); 166 rc = regcomp (preg, (char*)item, rd->flags);
165 if (rc) 167 if (rc)
...@@ -169,11 +171,11 @@ _regex_compile (void *item, void *data) ...@@ -169,11 +171,11 @@ _regex_compile (void *item, void *data)
169 if (errbuf) 171 if (errbuf)
170 { 172 {
171 regerror (rc, preg, errbuf, size); 173 regerror (rc, preg, errbuf, size);
172 sieve_compile_error (&mu_sieve_locus, _("Regex error: %s"), errbuf); 174 mu_sv_compile_error (&mu_sieve_locus, _("Regex error: %s"), errbuf);
173 free (errbuf); 175 free (errbuf);
174 } 176 }
175 else 177 else
176 sieve_compile_error (&mu_sieve_locus, _("Regex error")); 178 mu_sv_compile_error (&mu_sieve_locus, _("Regex error"));
177 return rc; 179 return rc;
178 } 180 }
179 181
...@@ -204,7 +206,7 @@ comp_false (const char *pattern, const char *text) ...@@ -204,7 +206,7 @@ comp_false (const char *pattern, const char *text)
204 } 206 }
205 207
206 int 208 int
207 mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) 209 mu_sv_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
208 { 210 {
209 mu_iterator_t itr; 211 mu_iterator_t itr;
210 mu_sieve_runtime_tag_t *match = NULL; 212 mu_sieve_runtime_tag_t *match = NULL;
...@@ -234,7 +236,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) ...@@ -234,7 +236,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
234 { 236 {
235 if (match) 237 if (match)
236 { 238 {
237 sieve_compile_error (&mu_sieve_locus, 239 mu_sv_compile_error (&mu_sieve_locus,
238 _("match type specified twice in call to `%s'"), 240 _("match type specified twice in call to `%s'"),
239 name); 241 name);
240 err = 1; 242 err = 1;
...@@ -270,7 +272,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) ...@@ -270,7 +272,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
270 272
271 if (comp && strcmp (comp->arg->v.string, "i;ascii-numeric")) 273 if (comp && strcmp (comp->arg->v.string, "i;ascii-numeric"))
272 { 274 {
273 sieve_compile_error (&mu_sieve_locus, 275 mu_sv_compile_error (&mu_sieve_locus,
274 /* TRANSLATORS: Do not translate ':count'. 276 /* TRANSLATORS: Do not translate ':count'.
275 It is the name of a Sieve tag */ 277 It is the name of a Sieve tag */
276 _("comparator %s is incompatible with " 278 _("comparator %s is incompatible with "
...@@ -289,7 +291,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) ...@@ -289,7 +291,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
289 mu_list_count (val->v.list, &count); 291 mu_list_count (val->v.list, &count);
290 if (count > 1) 292 if (count > 1)
291 { 293 {
292 sieve_compile_error (&mu_sieve_locus, 294 mu_sv_compile_error (&mu_sieve_locus,
293 _("second argument must be a list of one element")); 295 _("second argument must be a list of one element"));
294 return 1; 296 return 1;
295 } 297 }
...@@ -297,7 +299,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) ...@@ -297,7 +299,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
297 count = strtoul (str, &str, 10); 299 count = strtoul (str, &str, 10);
298 if (*str) 300 if (*str)
299 { 301 {
300 sieve_compile_error (&mu_sieve_locus, 302 mu_sv_compile_error (&mu_sieve_locus,
301 _("second argument cannot be converted to number")); 303 _("second argument cannot be converted to number"));
302 return 1; 304 return 1;
303 } 305 }
...@@ -307,7 +309,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) ...@@ -307,7 +309,7 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
307 309
308 if (mu_sieve_str_to_relcmp (str, NULL, NULL)) 310 if (mu_sieve_str_to_relcmp (str, NULL, NULL))
309 { 311 {
310 sieve_compile_error (&mu_sieve_locus, 312 mu_sv_compile_error (&mu_sieve_locus,
311 _("invalid relational match `%s' in call to `%s'"), 313 _("invalid relational match `%s' in call to `%s'"),
312 str, name); 314 str, name);
313 return 1; 315 return 1;
...@@ -317,17 +319,18 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) ...@@ -317,17 +319,18 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
317 if (!compfun) 319 if (!compfun)
318 { 320 {
319 compname = comp ? comp->arg->v.string : "i;ascii-casemap"; 321 compname = comp ? comp->arg->v.string : "i;ascii-casemap";
320 compfun = mu_sieve_comparator_lookup (sieve_machine, compname, matchtype); 322 compfun = mu_sieve_comparator_lookup (mu_sieve_machine, compname,
323 matchtype);
321 if (!compfun) 324 if (!compfun)
322 { 325 {
323 sieve_compile_error (&mu_sieve_locus, 326 mu_sv_compile_error (&mu_sieve_locus,
324 _("comparator `%s' is incompatible with match type `%s' in call to `%s'"), 327 _("comparator `%s' is incompatible with match type `%s' in call to `%s'"),
325 compname, match ? match->tag : "is", name); 328 compname, match ? match->tag : "is", name);
326 return 1; 329 return 1;
327 } 330 }
328 } 331 }
329 332
330 tmp = mu_sieve_malloc (sieve_machine, sizeof (*tmp)); 333 tmp = mu_sieve_malloc (mu_sieve_machine, sizeof (*tmp));
331 tmp->tag = TAG_COMPFUN; 334 tmp->tag = TAG_COMPFUN;
332 tmp->arg = mu_sieve_value_create (SVT_POINTER, compfun); 335 tmp->arg = mu_sieve_value_create (SVT_POINTER, compfun);
333 mu_list_append (tags, tmp); 336 mu_list_append (tags, tmp);
...@@ -351,7 +354,8 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args) ...@@ -351,7 +354,8 @@ mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args)
351 354
352 rc = mu_sieve_vlist_do (val, _regex_compile, &rd); 355 rc = mu_sieve_vlist_do (val, _regex_compile, &rd);
353 356
354 mu_sieve_machine_add_destructor (sieve_machine, _free_reglist, rd.list); 357 mu_sieve_machine_add_destructor (mu_sieve_machine, _free_reglist,
358 rd.list);
355 359
356 if (rc) 360 if (rc)
357 return rc; 361 return rc;
...@@ -489,7 +493,7 @@ i_ascii_numeric_eq (const char *pattern, const char *text) ...@@ -489,7 +493,7 @@ i_ascii_numeric_eq (const char *pattern, const char *text)
489 } 493 }
490 494
491 void 495 void
492 sieve_register_standard_comparators (mu_sieve_machine_t mach) 496 mu_sv_register_standard_comparators (mu_sieve_machine_t mach)
493 { 497 {
494 mu_sieve_register_comparator (mach, 498 mu_sieve_register_comparator (mach,
495 "i;octet", 499 "i;octet",
......
...@@ -63,7 +63,7 @@ mu_sieve_module_init (void *data) ...@@ -63,7 +63,7 @@ mu_sieve_module_init (void *data)
63 if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH) 63 if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH)
64 mu_list_destroy (&mu_sieve_library_path); 64 mu_list_destroy (&mu_sieve_library_path);
65 mu_list_do (p->library_path, _path_append, &mu_sieve_library_path); 65 mu_list_do (p->library_path, _path_append, &mu_sieve_library_path);
66 sieve_load_add_path (mu_sieve_library_path); 66 mu_sv_load_add_path (mu_sieve_library_path);
67 mu_list_destroy (&p->library_path); 67 mu_list_destroy (&p->library_path);
68 mu_list_destroy (&p->include_path); 68 mu_list_destroy (&p->include_path);
69 return 0; 69 return 0;
......
...@@ -135,7 +135,7 @@ _add_load_dir (void *item, void *unused) ...@@ -135,7 +135,7 @@ _add_load_dir (void *item, void *unused)
135 } 135 }
136 136
137 int 137 int
138 sieve_load_add_path (mu_list_t path) 138 mu_sv_load_add_path (mu_list_t path)
139 { 139 {
140 if (sieve_init_load_path ()) 140 if (sieve_init_load_path ())
141 return 1; 141 return 1;
...@@ -143,11 +143,12 @@ sieve_load_add_path (mu_list_t path) ...@@ -143,11 +143,12 @@ sieve_load_add_path (mu_list_t path)
143 } 143 }
144 144
145 int 145 int
146 sieve_load_add_dir (mu_sieve_machine_t mach, const char *name) 146 mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name)
147 { 147 {
148 if (sieve_init_load_path ()) 148 if (sieve_init_load_path ())
149 return 1; 149 return 1;
150 mu_sieve_machine_add_destructor (mach, (mu_sieve_destructor_t) lt_dlexit, NULL); 150 mu_sieve_machine_add_destructor (mach, (mu_sieve_destructor_t) lt_dlexit,
151 NULL);
151 return lt_dladdsearchdir (name); 152 return lt_dladdsearchdir (name);
152 } 153 }
153 154
...@@ -161,13 +162,13 @@ mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name) ...@@ -161,13 +162,13 @@ mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name)
161 } 162 }
162 163
163 int 164 int
164 sieve_load_add_path (mu_list_t path) 165 mu_sv_load_add_path (mu_list_t path)
165 { 166 {
166 return 1; 167 return 1;
167 } 168 }
168 169
169 int 170 int
170 sieve_load_add_dir (mu_sieve_machine_t mach, const char *name) 171 mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name)
171 { 172 {
172 return 1; 173 return 1;
173 } 174 }
......
...@@ -26,69 +26,70 @@ ...@@ -26,69 +26,70 @@
26 #include <sieve.h> 26 #include <sieve.h>
27 27
28 int 28 int
29 sieve_code (sieve_op_t *op) 29 mu_sv_code (sieve_op_t *op)
30 { 30 {
31 if (sieve_machine->pc >= sieve_machine->progsize) 31 if (mu_sieve_machine->pc >= mu_sieve_machine->progsize)
32 { 32 {
33 size_t newsize = sieve_machine->progsize + SIEVE_CODE_INCR; 33 size_t newsize = mu_sieve_machine->progsize + SIEVE_CODE_INCR;
34 sieve_op_t *newprog = mu_sieve_mrealloc (sieve_machine, sieve_machine->prog, 34 sieve_op_t *newprog = mu_sieve_mrealloc (mu_sieve_machine,
35 newsize * 35 mu_sieve_machine->prog,
36 sizeof sieve_machine->prog[0]); 36 newsize *
37 sizeof mu_sieve_machine->prog[0]);
37 if (!newprog) 38 if (!newprog)
38 { 39 {
39 sieve_compile_error (&mu_sieve_locus, _("out of memory!")); 40 mu_sv_compile_error (&mu_sieve_locus, _("out of memory!"));
40 return 1; 41 return 1;
41 } 42 }
42 sieve_machine->prog = newprog; 43 mu_sieve_machine->prog = newprog;
43 sieve_machine->progsize = newsize; 44 mu_sieve_machine->progsize = newsize;
44 } 45 }
45 sieve_machine->prog[sieve_machine->pc++] = *op; 46 mu_sieve_machine->prog[mu_sieve_machine->pc++] = *op;
46 return 0; 47 return 0;
47 } 48 }
48 49
49 int 50 int
50 sieve_code_instr (sieve_instr_t instr) 51 mu_sv_code_instr (sieve_instr_t instr)
51 { 52 {
52 sieve_op_t op; 53 sieve_op_t op;
53 54
54 op.instr = instr; 55 op.instr = instr;
55 return sieve_code (&op); 56 return mu_sv_code (&op);
56 } 57 }
57 58
58 int 59 int
59 sieve_code_handler (mu_sieve_handler_t handler) 60 mu_sv_code_handler (mu_sieve_handler_t handler)
60 { 61 {
61 sieve_op_t op; 62 sieve_op_t op;
62 63
63 op.handler = handler; 64 op.handler = handler;
64 return sieve_code (&op); 65 return mu_sv_code (&op);
65 } 66 }
66 67
67 int 68 int
68 sieve_code_list (mu_list_t list) 69 mu_sv_code_list (mu_list_t list)
69 { 70 {
70 sieve_op_t op; 71 sieve_op_t op;
71 72
72 op.list = list; 73 op.list = list;
73 return sieve_code (&op); 74 return mu_sv_code (&op);
74 } 75 }
75 76
76 int 77 int
77 sieve_code_number (long num) 78 mu_sv_code_number (long num)
78 { 79 {
79 sieve_op_t op; 80 sieve_op_t op;
80 81
81 op.number = num; 82 op.number = num;
82 return sieve_code (&op); 83 return mu_sv_code (&op);
83 } 84 }
84 85
85 int 86 int
86 sieve_code_string (const char *string) 87 mu_sv_code_string (const char *string)
87 { 88 {
88 sieve_op_t op; 89 sieve_op_t op;
89 90
90 op.string = string; 91 op.string = string;
91 return sieve_code (&op); 92 return mu_sv_code (&op);
92 } 93 }
93 94
94 mu_sieve_tag_def_t * 95 mu_sieve_tag_def_t *
...@@ -133,7 +134,7 @@ _run_checker (void *item, void *data) ...@@ -133,7 +134,7 @@ _run_checker (void *item, void *data)
133 } 134 }
134 135
135 int 136 int
136 sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) 137 mu_sv_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
137 { 138 {
138 mu_iterator_t itr; 139 mu_iterator_t itr;
139 mu_list_t arg_list = NULL; 140 mu_list_t arg_list = NULL;
...@@ -143,7 +144,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -143,7 +144,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
143 int rc, err = 0; 144 int rc, err = 0;
144 static mu_sieve_data_type empty[] = { SVT_VOID }; 145 static mu_sieve_data_type empty[] = { SVT_VOID };
145 146
146 if (sieve_code_handler (reg->handler)) 147 if (mu_sv_code_handler (reg->handler))
147 return 1; 148 return 1;
148 149
149 exp_arg = reg->req_args ? reg->req_args : empty; 150 exp_arg = reg->req_args ? reg->req_args : empty;
...@@ -154,7 +155,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -154,7 +155,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
154 155
155 if (rc) 156 if (rc)
156 { 157 {
157 sieve_compile_error (&mu_sieve_locus, 158 mu_sv_compile_error (&mu_sieve_locus,
158 _("cannot create iterator: %s"), 159 _("cannot create iterator: %s"),
159 mu_strerror (rc)); 160 mu_strerror (rc));
160 return 1; 161 return 1;
...@@ -173,7 +174,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -173,7 +174,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
173 mu_sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string, &cf); 174 mu_sieve_tag_def_t *tag = find_tag (reg->tags, val->v.string, &cf);
174 if (!tag) 175 if (!tag)
175 { 176 {
176 sieve_compile_error (&mu_sieve_locus, 177 mu_sv_compile_error (&mu_sieve_locus,
177 _("invalid tag name `%s' for `%s'"), 178 _("invalid tag name `%s' for `%s'"),
178 val->v.string, reg->name); 179 val->v.string, reg->name);
179 err = 1; 180 err = 1;
...@@ -182,7 +183,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -182,7 +183,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
182 183
183 if (!tag_list && (rc = mu_list_create (&tag_list))) 184 if (!tag_list && (rc = mu_list_create (&tag_list)))
184 { 185 {
185 sieve_compile_error (&mu_sieve_locus, 186 mu_sv_compile_error (&mu_sieve_locus,
186 _("cannot create tag list: %s"), 187 _("cannot create tag list: %s"),
187 mu_strerror (rc)); 188 mu_strerror (rc));
188 err = 1; 189 err = 1;
...@@ -195,7 +196,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -195,7 +196,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
195 mu_iterator_next (itr); 196 mu_iterator_next (itr);
196 if (mu_iterator_is_done (itr)) 197 if (mu_iterator_is_done (itr))
197 { 198 {
198 sieve_compile_error (&mu_sieve_locus, 199 mu_sv_compile_error (&mu_sieve_locus,
199 _("required argument for tag %s is missing"), 200 _("required argument for tag %s is missing"),
200 tag->name); 201 tag->name);
201 err = 1; 202 err = 1;
...@@ -206,7 +207,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -206,7 +207,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
206 else 207 else
207 tagrec.arg = NULL; 208 tagrec.arg = NULL;
208 209
209 tagptr = mu_sieve_malloc (sieve_machine, sizeof (*tagptr)); 210 tagptr = mu_sieve_malloc (mu_sieve_machine, sizeof (*tagptr));
210 *tagptr = tagrec; 211 *tagptr = tagrec;
211 mu_list_append (tag_list, tagptr); 212 mu_list_append (tag_list, tagptr);
212 213
...@@ -214,7 +215,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -214,7 +215,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
214 { 215 {
215 if (!chk_list && (rc = mu_list_create (&chk_list))) 216 if (!chk_list && (rc = mu_list_create (&chk_list)))
216 { 217 {
217 sieve_compile_error (&mu_sieve_locus, 218 mu_sv_compile_error (&mu_sieve_locus,
218 _("cannot create check list: %s"), 219 _("cannot create check list: %s"),
219 mu_strerror (rc)); 220 mu_strerror (rc));
220 err = 1; 221 err = 1;
...@@ -226,7 +227,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -226,7 +227,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
226 } 227 }
227 else if (*exp_arg == SVT_VOID) 228 else if (*exp_arg == SVT_VOID)
228 { 229 {
229 sieve_compile_error (&mu_sieve_locus, 230 mu_sv_compile_error (&mu_sieve_locus,
230 _("too many arguments in call to `%s'"), 231 _("too many arguments in call to `%s'"),
231 reg->name); 232 reg->name);
232 err = 1; 233 err = 1;
...@@ -242,16 +243,16 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -242,16 +243,16 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
242 243
243 mu_list_create (&list); 244 mu_list_create (&list);
244 mu_list_append (list, val->v.string); 245 mu_list_append (list, val->v.string);
245 mu_sieve_mfree (sieve_machine, val); 246 mu_sieve_mfree (mu_sieve_machine, val);
246 val = mu_sieve_value_create (SVT_STRING_LIST, list); 247 val = mu_sieve_value_create (SVT_STRING_LIST, list);
247 } 248 }
248 else 249 else
249 { 250 {
250 sieve_compile_error (&mu_sieve_locus, 251 mu_sv_compile_error (&mu_sieve_locus,
251 _("type mismatch in argument %d to `%s'"), 252 _("type mismatch in argument %d to `%s'"),
252 exp_arg - reg->req_args + 1, 253 exp_arg - reg->req_args + 1,
253 reg->name); 254 reg->name);
254 sieve_compile_error (&mu_sieve_locus, 255 mu_sv_compile_error (&mu_sieve_locus,
255 _("expected %s but passed %s"), 256 _("expected %s but passed %s"),
256 mu_sieve_type_str (*exp_arg), 257 mu_sieve_type_str (*exp_arg),
257 mu_sieve_type_str (val->type)); 258 mu_sieve_type_str (val->type));
...@@ -262,7 +263,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -262,7 +263,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
262 263
263 if (!arg_list && (rc = mu_list_create (&arg_list))) 264 if (!arg_list && (rc = mu_list_create (&arg_list)))
264 { 265 {
265 sieve_compile_error (&mu_sieve_locus, 266 mu_sv_compile_error (&mu_sieve_locus,
266 _("cannot create arg list: %s"), 267 _("cannot create arg list: %s"),
267 mu_strerror (rc)); 268 mu_strerror (rc));
268 err = 1; 269 err = 1;
...@@ -280,7 +281,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -280,7 +281,7 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
280 { 281 {
281 if (*exp_arg != SVT_VOID) 282 if (*exp_arg != SVT_VOID)
282 { 283 {
283 sieve_compile_error (&mu_sieve_locus, 284 mu_sv_compile_error (&mu_sieve_locus,
284 _("too few arguments in call to `%s'"), 285 _("too few arguments in call to `%s'"),
285 reg->name); 286 reg->name);
286 err = 1; 287 err = 1;
...@@ -298,9 +299,9 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -298,9 +299,9 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
298 } 299 }
299 300
300 if (!err) 301 if (!err)
301 err = sieve_code_list (arg_list) 302 err = mu_sv_code_list (arg_list)
302 || sieve_code_list (tag_list) 303 || mu_sv_code_list (tag_list)
303 || sieve_code_string (reg->name); 304 || mu_sv_code_string (reg->name);
304 305
305 if (err) 306 if (err)
306 { 307 {
...@@ -313,34 +314,35 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist) ...@@ -313,34 +314,35 @@ sieve_code_command (mu_sieve_register_t *reg, mu_list_t arglist)
313 } 314 }
314 315
315 int 316 int
316 sieve_code_source (const char *name) 317 mu_sv_code_source (const char *name)
317 { 318 {
318 char *s; 319 char *s;
319 320
320 if (mu_list_locate (sieve_machine->source_list, (void*) name, (void **) &s)) 321 if (mu_list_locate (mu_sieve_machine->source_list,
322 (void*) name, (void **) &s))
321 { 323 {
322 s = mu_sieve_mstrdup (sieve_machine, name); 324 s = mu_sieve_mstrdup (mu_sieve_machine, name);
323 mu_list_append (sieve_machine->source_list, s); 325 mu_list_append (mu_sieve_machine->source_list, s);
324 } 326 }
325 327
326 return sieve_code_instr (_mu_sv_instr_source) 328 return mu_sv_code_instr (_mu_sv_instr_source)
327 || sieve_code_string (s); 329 || mu_sv_code_string (s);
328 } 330 }
329 331
330 int 332 int
331 sieve_code_line (size_t line) 333 mu_sv_code_line (size_t line)
332 { 334 {
333 sieve_op_t op; 335 sieve_op_t op;
334 336
335 op.line = line; 337 op.line = line;
336 return sieve_code_instr (_mu_sv_instr_line) 338 return mu_sv_code_instr (_mu_sv_instr_line)
337 || sieve_code (&op); 339 || mu_sv_code (&op);
338 } 340 }
339 341
340 static int sieve_source_changed; 342 static int sieve_source_changed;
341 343
342 void 344 void
343 sieve_change_source () 345 mu_sv_change_source ()
344 { 346 {
345 sieve_source_changed = 1; 347 sieve_source_changed = 1;
346 } 348 }
...@@ -351,56 +353,56 @@ sieve_check_source_changed () ...@@ -351,56 +353,56 @@ sieve_check_source_changed ()
351 if (sieve_source_changed) 353 if (sieve_source_changed)
352 { 354 {
353 sieve_source_changed = 0; 355 sieve_source_changed = 0;
354 return sieve_code_source (mu_sieve_locus.source_file); 356 return mu_sv_code_source (mu_sieve_locus.source_file);
355 } 357 }
356 return 0; 358 return 0;
357 } 359 }
358 360
359 int 361 int
360 sieve_code_action (mu_sieve_register_t *reg, mu_list_t arglist) 362 mu_sv_code_action (mu_sieve_register_t *reg, mu_list_t arglist)
361 { 363 {
362 return sieve_check_source_changed () 364 return sieve_check_source_changed ()
363 || sieve_code_line (mu_sieve_locus.source_line) 365 || mu_sv_code_line (mu_sieve_locus.source_line)
364 || sieve_code_instr (_mu_sv_instr_action) 366 || mu_sv_code_instr (_mu_sv_instr_action)
365 || sieve_code_command (reg, arglist); 367 || mu_sv_code_command (reg, arglist);
366 } 368 }
367 369
368 int 370 int
369 sieve_code_test (mu_sieve_register_t *reg, mu_list_t arglist) 371 mu_sv_code_test (mu_sieve_register_t *reg, mu_list_t arglist)
370 { 372 {
371 return sieve_check_source_changed () 373 return sieve_check_source_changed ()
372 || sieve_code_line (mu_sieve_locus.source_line) 374 || mu_sv_code_line (mu_sieve_locus.source_line)
373 || sieve_code_instr (_mu_sv_instr_test) 375 || mu_sv_code_instr (_mu_sv_instr_test)
374 || sieve_code_command (reg, arglist); 376 || mu_sv_code_command (reg, arglist);
375 } 377 }
376 378
377 void 379 void
378 sieve_code_anyof (size_t start) 380 mu_sv_code_anyof (size_t start)
379 { 381 {
380 size_t end = sieve_machine->pc; 382 size_t end = mu_sieve_machine->pc;
381 while (sieve_machine->prog[start+1].pc != 0) 383 while (mu_sieve_machine->prog[start+1].pc != 0)
382 { 384 {
383 size_t next = sieve_machine->prog[start+1].pc; 385 size_t next = mu_sieve_machine->prog[start+1].pc;
384 sieve_machine->prog[start].instr = _mu_sv_instr_brnz; 386 mu_sieve_machine->prog[start].instr = _mu_sv_instr_brnz;
385 sieve_machine->prog[start+1].pc = end - start - 2; 387 mu_sieve_machine->prog[start+1].pc = end - start - 2;
386 start = next; 388 start = next;
387 } 389 }
388 sieve_machine->prog[start].instr = _mu_sv_instr_nop; 390 mu_sieve_machine->prog[start].instr = _mu_sv_instr_nop;
389 sieve_machine->prog[start+1].instr = _mu_sv_instr_nop; 391 mu_sieve_machine->prog[start+1].instr = _mu_sv_instr_nop;
390 } 392 }
391 393
392 void 394 void
393 sieve_code_allof (size_t start) 395 mu_sv_code_allof (size_t start)
394 { 396 {
395 size_t end = sieve_machine->pc; 397 size_t end = mu_sieve_machine->pc;
396 398
397 while (sieve_machine->prog[start+1].pc != 0) 399 while (mu_sieve_machine->prog[start+1].pc != 0)
398 { 400 {
399 size_t next = sieve_machine->prog[start+1].pc; 401 size_t next = mu_sieve_machine->prog[start+1].pc;
400 sieve_machine->prog[start+1].pc = end - start - 2; 402 mu_sieve_machine->prog[start+1].pc = end - start - 2;
401 start = next; 403 start = next;
402 } 404 }
403 sieve_machine->prog[start].instr = _mu_sv_instr_nop; 405 mu_sieve_machine->prog[start].instr = _mu_sv_instr_nop;
404 sieve_machine->prog[start+1].instr = _mu_sv_instr_nop; 406 mu_sieve_machine->prog[start+1].instr = _mu_sv_instr_nop;
405 } 407 }
406 408
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2004, 2 Copyright (C) 1999, 2000, 2001, 2002, 2004,
3 2005, 2007 Free Software Foundation, Inc. 3 2005, 2007, 2008 Free Software Foundation, Inc.
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 2003, 2005, 2007 Free Software Foundation, Inc. 2 Copyright (C) 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public 5 modify it under the terms of the GNU Lesser General Public
......
...@@ -36,7 +36,7 @@ mu_sieve_require (mu_list_t slist) ...@@ -36,7 +36,7 @@ mu_sieve_require (mu_list_t slist)
36 status = mu_list_get_iterator (slist, &itr); 36 status = mu_list_get_iterator (slist, &itr);
37 if (status) 37 if (status)
38 { 38 {
39 sieve_compile_error (&mu_sieve_locus, 39 mu_sv_compile_error (&mu_sieve_locus,
40 _("cannot create iterator: %s"), 40 _("cannot create iterator: %s"),
41 mu_strerror (status)); 41 mu_strerror (status));
42 return; 42 return;
...@@ -74,9 +74,9 @@ mu_sieve_require (mu_list_t slist) ...@@ -74,9 +74,9 @@ mu_sieve_require (mu_list_t slist)
74 text = _("required action"); 74 text = _("required action");
75 } 75 }
76 76
77 if (reqfn (sieve_machine, name)) 77 if (reqfn (mu_sieve_machine, name))
78 { 78 {
79 sieve_compile_error (&mu_sieve_locus, 79 mu_sv_compile_error (&mu_sieve_locus,
80 _("source for the %s %s is not available"), 80 _("source for the %s %s is not available"),
81 text, 81 text,
82 name); 82 name);
......
...@@ -76,9 +76,9 @@ instr_run (mu_sieve_machine_t mach) ...@@ -76,9 +76,9 @@ instr_run (mu_sieve_machine_t mach)
76 if (INSTR_DEBUG (mach)) 76 if (INSTR_DEBUG (mach))
77 { 77 {
78 mu_sieve_debug (mach, "Arguments: "); 78 mu_sieve_debug (mach, "Arguments: ");
79 sieve_print_value_list (arg_list, mach->debug_printer, mach->data); 79 mu_sv_print_value_list (arg_list, mach->debug_printer, mach->data);
80 mu_sieve_debug (mach, "\nTags:"); 80 mu_sieve_debug (mach, "\nTags:");
81 sieve_print_tag_list (tag_list, mach->debug_printer, mach->data); 81 mu_sv_print_tag_list (tag_list, mach->debug_printer, mach->data);
82 mu_sieve_debug (mach, "\n"); 82 mu_sieve_debug (mach, "\n");
83 } 83 }
84 84
......
...@@ -37,7 +37,7 @@ typedef union { ...@@ -37,7 +37,7 @@ typedef union {
37 size_t line; 37 size_t line;
38 } sieve_op_t; 38 } sieve_op_t;
39 39
40 struct sieve_machine { 40 struct mu_sieve_machine {
41 /* Static data */ 41 /* Static data */
42 mu_sieve_locus_t locus; /* Approximate location in the code */ 42 mu_sieve_locus_t locus; /* Approximate location in the code */
43 43
...@@ -81,51 +81,42 @@ struct sieve_machine { ...@@ -81,51 +81,42 @@ struct sieve_machine {
81 }; 81 };
82 82
83 extern mu_sieve_locus_t mu_sieve_locus; 83 extern mu_sieve_locus_t mu_sieve_locus;
84 extern mu_sieve_machine_t sieve_machine; 84 extern mu_sieve_machine_t mu_sieve_machine;
85 extern int sieve_error_count; 85 extern int mu_sieve_error_count;
86 86
87 #define TAG_COMPFUN "__compfun__" 87 #define TAG_COMPFUN "__compfun__"
88 #define TAG_RELFUN "__relfun__" 88 #define TAG_RELFUN "__relfun__"
89 89
90 void sieve_compile_error (mu_sieve_locus_t *locus, 90 void mu_sv_compile_error (mu_sieve_locus_t *locus,
91 const char *fmt, ...) MU_PRINTFLIKE(2,3); 91 const char *fmt, ...) MU_PRINTFLIKE(2,3);
92 void sieve_debug_internal (mu_sieve_printf_t printer, void *data, 92 void mu_sv_print_value_list (mu_list_t list, mu_sieve_printf_t printer,
93 const char *fmt, ...) MU_PRINTFLIKE(3,4);
94 void sieve_print_value (mu_sieve_value_t *val, mu_sieve_printf_t printer,
95 void *data);
96 void sieve_print_value_list (mu_list_t list, mu_sieve_printf_t printer,
97 void *data); 93 void *data);
98 void sieve_print_tag_list (mu_list_t list, mu_sieve_printf_t printer, 94 void mu_sv_print_tag_list (mu_list_t list, mu_sieve_printf_t printer,
99 void *data); 95 void *data);
100 96
101 int _sieve_default_error_printer (void *data, const char *fmt, va_list ap); 97 int mu_sv_lex_begin (const char *name);
102 int _sieve_default_parse_error (void *unused, 98 int mu_sv_lex_begin_string (const char *buf, int bufsize,
103 const char *filename, int lineno,
104 const char *fmt, va_list ap);
105
106 int sieve_lex_begin (const char *name);
107 int sieve_lex_begin_string (const char *buf, int bufsize,
108 const char *fname, int line); 99 const char *fname, int line);
109 void sieve_lex_finish (void); 100 void mu_sv_lex_finish (void);
110 int mu_sieve_yyerror (char *s); 101 int mu_sieve_yyerror (char *s);
111 int mu_sieve_yylex (); 102 int mu_sieve_yylex ();
112 103
113 void sieve_register_standard_actions (mu_sieve_machine_t mach); 104 void mu_sv_register_standard_actions (mu_sieve_machine_t mach);
114 void sieve_register_standard_tests (mu_sieve_machine_t mach); 105 void mu_sv_register_standard_tests (mu_sieve_machine_t mach);
115 void sieve_register_standard_comparators (mu_sieve_machine_t mach); 106 void mu_sv_register_standard_comparators (mu_sieve_machine_t mach);
116 107
117 int sieve_code (sieve_op_t *op); 108 int mu_sv_code (sieve_op_t *op);
118 int sieve_code_instr (sieve_instr_t instr); 109 int mu_sv_code_instr (sieve_instr_t instr);
119 int sieve_code_handler (mu_sieve_handler_t handler); 110 int mu_sv_code_handler (mu_sieve_handler_t handler);
120 int sieve_code_list (mu_list_t list); 111 int mu_sv_code_list (mu_list_t list);
121 int sieve_code_number (long num); 112 int mu_sv_code_number (long num);
122 int sieve_code_test (mu_sieve_register_t *reg, mu_list_t arglist); 113 int mu_sv_code_test (mu_sieve_register_t *reg, mu_list_t arglist);
123 int sieve_code_action (mu_sieve_register_t *reg, mu_list_t arglist); 114 int mu_sv_code_action (mu_sieve_register_t *reg, mu_list_t arglist);
124 void sieve_code_anyof (size_t start); 115 void mu_sv_code_anyof (size_t start);
125 void sieve_code_allof (size_t start); 116 void mu_sv_code_allof (size_t start);
126 int sieve_code_source (const char *name); 117 int mu_sv_code_source (const char *name);
127 int sieve_code_line (size_t line); 118 int mu_sv_code_line (size_t line);
128 void sieve_change_source (void); 119 void mu_sv_change_source (void);
129 120
130 void _mu_sv_instr_action (mu_sieve_machine_t mach); 121 void _mu_sv_instr_action (mu_sieve_machine_t mach);
131 void _mu_sv_instr_test (mu_sieve_machine_t mach); 122 void _mu_sv_instr_test (mu_sieve_machine_t mach);
...@@ -139,10 +130,8 @@ void _mu_sv_instr_nop (mu_sieve_machine_t mach); ...@@ -139,10 +130,8 @@ void _mu_sv_instr_nop (mu_sieve_machine_t mach);
139 void _mu_sv_instr_source (mu_sieve_machine_t mach); 130 void _mu_sv_instr_source (mu_sieve_machine_t mach);
140 void _mu_sv_instr_line (mu_sieve_machine_t mach); 131 void _mu_sv_instr_line (mu_sieve_machine_t mach);
141 132
142 int sieve_mark_deleted (mu_message_t msg, int deleted); 133 int mu_sv_match_part_checker (const char *name, mu_list_t tags,
143 134 mu_list_t args);
144 int mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args);
145 int sieve_relational_checker (const char *name, mu_list_t tags, mu_list_t args);
146 135
147 int sieve_load_add_path (mu_list_t path); 136 int mu_sv_load_add_path (mu_list_t path);
148 int sieve_load_add_dir (mu_sieve_machine_t mach, const char *name); 137 int mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name);
......
...@@ -124,7 +124,7 @@ push_source (const char *name) ...@@ -124,7 +124,7 @@ push_source (const char *name)
124 124
125 if (stat (name, &st)) 125 if (stat (name, &st))
126 { 126 {
127 sieve_compile_error (&mu_sieve_locus, 127 mu_sv_compile_error (&mu_sieve_locus,
128 _("cannot stat `%s': %s"), name, strerror (errno)); 128 _("cannot stat `%s': %s"), name, strerror (errno));
129 return 1; 129 return 1;
130 } 130 }
...@@ -138,11 +138,11 @@ push_source (const char *name) ...@@ -138,11 +138,11 @@ push_source (const char *name)
138 { 138 {
139 yyerror (_("recursive inclusion")); 139 yyerror (_("recursive inclusion"));
140 if (ctx->prev) 140 if (ctx->prev)
141 sieve_compile_error (&ctx->prev->locus, 141 mu_sv_compile_error (&ctx->prev->locus,
142 _("`%s' already included here"), 142 _("`%s' already included here"),
143 name); 143 name);
144 else 144 else
145 sieve_compile_error (&mu_sieve_locus, 145 mu_sv_compile_error (&mu_sieve_locus,
146 _("`%s' already included at top level"), 146 _("`%s' already included at top level"),
147 name); 147 name);
148 return 1; 148 return 1;
...@@ -151,7 +151,7 @@ push_source (const char *name) ...@@ -151,7 +151,7 @@ push_source (const char *name)
151 fp = fopen (name, "r"); 151 fp = fopen (name, "r");
152 if (!fp) 152 if (!fp)
153 { 153 {
154 sieve_compile_error (&mu_sieve_locus, 154 mu_sv_compile_error (&mu_sieve_locus,
155 _("cannot open `%s': %s"), name, strerror (errno)); 155 _("cannot open `%s': %s"), name, strerror (errno));
156 return 1; 156 return 1;
157 } 157 }
...@@ -177,7 +177,7 @@ push_source (const char *name) ...@@ -177,7 +177,7 @@ push_source (const char *name)
177 mu_sieve_locus.source_line = 1; 177 mu_sieve_locus.source_line = 1;
178 sieve_source_inode = st.st_ino; 178 sieve_source_inode = st.st_ino;
179 179
180 sieve_change_source (); 180 mu_sv_change_source ();
181 181
182 return 0; 182 return 0;
183 } 183 }
...@@ -207,7 +207,7 @@ pop_source () ...@@ -207,7 +207,7 @@ pop_source ()
207 free (context_stack); 207 free (context_stack);
208 context_stack = ctx; 208 context_stack = ctx;
209 209
210 sieve_change_source (); 210 mu_sv_change_source ();
211 211
212 return 0; 212 return 0;
213 } 213 }
...@@ -410,19 +410,19 @@ sieve_searchpath () ...@@ -410,19 +410,19 @@ sieve_searchpath ()
410 name = get_file_name (p, endp, NULL); 410 name = get_file_name (p, endp, NULL);
411 if (name) 411 if (name)
412 { 412 {
413 sieve_load_add_dir (sieve_machine, name); 413 mu_sv_load_add_dir (mu_sieve_machine, name);
414 free (name); 414 free (name);
415 } 415 }
416 } 416 }
417 417
418 int 418 int
419 sieve_lex_begin (const char *name) 419 mu_sv_lex_begin (const char *name)
420 { 420 {
421 return push_source (name); 421 return push_source (name);
422 } 422 }
423 423
424 int 424 int
425 sieve_lex_begin_string (const char *buf, int bufsize, 425 mu_sv_lex_begin_string (const char *buf, int bufsize,
426 const char *fname, int line) 426 const char *fname, int line)
427 { 427 {
428 if (!fname) 428 if (!fname)
...@@ -435,12 +435,12 @@ sieve_lex_begin_string (const char *buf, int bufsize, ...@@ -435,12 +435,12 @@ sieve_lex_begin_string (const char *buf, int bufsize,
435 mu_sieve_locus.source_line = line; 435 mu_sieve_locus.source_line = line;
436 sieve_source_inode = 0; 436 sieve_source_inode = 0;
437 437
438 sieve_change_source (); 438 mu_sv_change_source ();
439 return 0; 439 return 0;
440 } 440 }
441 441
442 void 442 void
443 sieve_lex_finish () 443 mu_sv_lex_finish ()
444 { 444 {
445 while (pop_source () == 0) 445 while (pop_source () == 0)
446 ; 446 ;
...@@ -473,7 +473,7 @@ number () ...@@ -473,7 +473,7 @@ number ()
473 static int 473 static int
474 string () 474 string ()
475 { 475 {
476 yylval.string = mu_sieve_malloc (sieve_machine, yyleng - 1); 476 yylval.string = mu_sieve_malloc (mu_sieve_machine, yyleng - 1);
477 memcpy (yylval.string, yytext + 1, yyleng - 2); 477 memcpy (yylval.string, yytext + 1, yyleng - 2);
478 yylval.string[yyleng - 2] = 0; 478 yylval.string[yyleng - 2] = 0;
479 return STRING; 479 return STRING;
...@@ -532,7 +532,7 @@ line_begin () ...@@ -532,7 +532,7 @@ line_begin ()
532 status = mu_list_create (&string_list); 532 status = mu_list_create (&string_list);
533 if (status) 533 if (status)
534 { 534 {
535 sieve_compile_error (&mu_sieve_locus, 535 mu_sv_compile_error (&mu_sieve_locus,
536 "mu_list_create: %s", mu_strerror (status)); 536 "mu_list_create: %s", mu_strerror (status));
537 exit (1); 537 exit (1);
538 } 538 }
...@@ -597,9 +597,10 @@ line_finish () ...@@ -597,9 +597,10 @@ line_finish ()
597 } 597 }
598 598
599 /* Copy the contents */ 599 /* Copy the contents */
600 yylval.string = mu_sieve_malloc (sieve_machine, length + 1); 600 yylval.string = mu_sieve_malloc (mu_sieve_machine, length + 1);
601 p = yylval.string; 601 p = yylval.string;
602 for (mu_iterator_first (itr); !mu_iterator_is_done (itr); mu_iterator_next (itr)) 602 for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
603 mu_iterator_next (itr))
603 { 604 {
604 char *s; 605 char *s;
605 mu_iterator_current (itr, (void **)&s); 606 mu_iterator_current (itr, (void **)&s);
......
...@@ -26,10 +26,13 @@ ...@@ -26,10 +26,13 @@
26 #include <assert.h> 26 #include <assert.h>
27 #include <sieve.h> 27 #include <sieve.h>
28 28
29 mu_sieve_machine_t sieve_machine; 29 mu_sieve_machine_t mu_sieve_machine;
30 int sieve_error_count; 30 int mu_sieve_error_count;
31 31
32 static void branch_fixup (size_t start, size_t end); 32 static void branch_fixup (size_t start, size_t end);
33 static int _sieve_default_error_printer (void *, const char *, va_list);
34 static int _sieve_default_parse_error (void *, const char *, int,
35 const char *, va_list);
33 %} 36 %}
34 37
35 %union { 38 %union {
...@@ -83,32 +86,32 @@ statement : REQUIRE stringorlist ';' ...@@ -83,32 +86,32 @@ statement : REQUIRE stringorlist ';'
83 /* All the items in $2 are registered in memory_pool, 86 /* All the items in $2 are registered in memory_pool,
84 so we don't free them */ 87 so we don't free them */
85 mu_list_destroy (&$2); 88 mu_list_destroy (&$2);
86 $$ = sieve_machine->pc; 89 $$ = mu_sieve_machine->pc;
87 } 90 }
88 | action ';' 91 | action ';'
89 /* 1 2 3 4 */ 92 /* 1 2 3 4 */
90 | if cond block else_part 93 | if cond block else_part
91 { 94 {
92 sieve_machine->prog[$2].pc = $4.begin - $2 - 1; 95 mu_sieve_machine->prog[$2].pc = $4.begin - $2 - 1;
93 if ($4.branch) 96 if ($4.branch)
94 branch_fixup ($4.branch, sieve_machine->pc); 97 branch_fixup ($4.branch, mu_sieve_machine->pc);
95 } 98 }
96 ; 99 ;
97 100
98 if : IF 101 if : IF
99 { 102 {
100 $$ = sieve_machine->pc; 103 $$ = mu_sieve_machine->pc;
101 } 104 }
102 ; 105 ;
103 106
104 else_part : maybe_elsif 107 else_part : maybe_elsif
105 { 108 {
106 if ($1.begin) 109 if ($1.begin)
107 sieve_machine->prog[$1.cond].pc = 110 mu_sieve_machine->prog[$1.cond].pc =
108 sieve_machine->pc - $1.cond - 1; 111 mu_sieve_machine->pc - $1.cond - 1;
109 else 112 else
110 { 113 {
111 $$.begin = sieve_machine->pc; 114 $$.begin = mu_sieve_machine->pc;
112 $$.branch = 0; 115 $$.branch = 0;
113 } 116 }
114 } 117 }
...@@ -116,8 +119,8 @@ else_part : maybe_elsif ...@@ -116,8 +119,8 @@ else_part : maybe_elsif
116 { 119 {
117 if ($1.begin) 120 if ($1.begin)
118 { 121 {
119 sieve_machine->prog[$1.cond].pc = $3 - $1.cond - 1; 122 mu_sieve_machine->prog[$1.cond].pc = $3 - $1.cond - 1;
120 sieve_machine->prog[$2].pc = $1.branch; 123 mu_sieve_machine->prog[$2].pc = $1.branch;
121 $$.begin = $1.begin; 124 $$.begin = $1.begin;
122 $$.branch = $2; 125 $$.branch = $2;
123 } 126 }
...@@ -144,8 +147,8 @@ elsif_branch : elsif begin cond block ...@@ -144,8 +147,8 @@ elsif_branch : elsif begin cond block
144 } 147 }
145 | elsif_branch elsif begin cond block 148 | elsif_branch elsif begin cond block
146 { 149 {
147 sieve_machine->prog[$1.cond].pc = $3 - $1.cond - 1; 150 mu_sieve_machine->prog[$1.cond].pc = $3 - $1.cond - 1;
148 sieve_machine->prog[$2].pc = $1.branch; 151 mu_sieve_machine->prog[$2].pc = $1.branch;
149 $$.begin = $1.begin; 152 $$.begin = $1.begin;
150 $$.branch = $2; 153 $$.branch = $2;
151 $$.cond = $4; 154 $$.cond = $4;
...@@ -154,17 +157,17 @@ elsif_branch : elsif begin cond block ...@@ -154,17 +157,17 @@ elsif_branch : elsif begin cond block
154 157
155 elsif : ELSIF 158 elsif : ELSIF
156 { 159 {
157 sieve_code_instr (_mu_sv_instr_branch); 160 mu_sv_code_instr (_mu_sv_instr_branch);
158 $$ = sieve_machine->pc; 161 $$ = mu_sieve_machine->pc;
159 sieve_code_number (0); 162 mu_sv_code_number (0);
160 } 163 }
161 ; 164 ;
162 165
163 else : ELSE 166 else : ELSE
164 { 167 {
165 sieve_code_instr (_mu_sv_instr_branch); 168 mu_sv_code_instr (_mu_sv_instr_branch);
166 $$ = sieve_machine->pc; 169 $$ = mu_sieve_machine->pc;
167 sieve_code_number (0); 170 mu_sv_code_number (0);
168 } 171 }
169 ; 172 ;
170 173
...@@ -176,17 +179,17 @@ block : '{' list '}' ...@@ -176,17 +179,17 @@ block : '{' list '}'
176 179
177 testlist : cond_expr 180 testlist : cond_expr
178 { 181 {
179 $$.start = $$.end = sieve_machine->pc; 182 $$.start = $$.end = mu_sieve_machine->pc;
180 if (sieve_code_instr (_mu_sv_instr_brz) 183 if (mu_sv_code_instr (_mu_sv_instr_brz)
181 || sieve_code_number (0)) 184 || mu_sv_code_number (0))
182 YYERROR; 185 YYERROR;
183 } 186 }
184 | testlist ',' cond_expr 187 | testlist ',' cond_expr
185 { 188 {
186 sieve_machine->prog[$1.end+1].pc = sieve_machine->pc; 189 mu_sieve_machine->prog[$1.end+1].pc = mu_sieve_machine->pc;
187 $1.end = sieve_machine->pc; 190 $1.end = mu_sieve_machine->pc;
188 if (sieve_code_instr (_mu_sv_instr_brz) 191 if (mu_sv_code_instr (_mu_sv_instr_brz)
189 || sieve_code_number (0)) 192 || mu_sv_code_number (0))
190 YYERROR; 193 YYERROR;
191 $$ = $1; 194 $$ = $1;
192 } 195 }
...@@ -194,9 +197,9 @@ testlist : cond_expr ...@@ -194,9 +197,9 @@ testlist : cond_expr
194 197
195 cond : cond_expr 198 cond : cond_expr
196 { 199 {
197 sieve_code_instr (_mu_sv_instr_brz); 200 mu_sv_code_instr (_mu_sv_instr_brz);
198 $$ = sieve_machine->pc; 201 $$ = mu_sieve_machine->pc;
199 sieve_code_number (0); 202 mu_sv_code_number (0);
200 } 203 }
201 ; 204 ;
202 205
...@@ -204,40 +207,40 @@ cond_expr : test ...@@ -204,40 +207,40 @@ cond_expr : test
204 { /* to placate bison */ } 207 { /* to placate bison */ }
205 | ANYOF '(' testlist ')' 208 | ANYOF '(' testlist ')'
206 { 209 {
207 sieve_code_anyof ($3.start); 210 mu_sv_code_anyof ($3.start);
208 } 211 }
209 | ALLOF '(' testlist ')' 212 | ALLOF '(' testlist ')'
210 { 213 {
211 sieve_code_allof ($3.start); 214 mu_sv_code_allof ($3.start);
212 } 215 }
213 | NOT cond_expr 216 | NOT cond_expr
214 { 217 {
215 if (sieve_code_instr (_mu_sv_instr_not)) 218 if (mu_sv_code_instr (_mu_sv_instr_not))
216 YYERROR; 219 YYERROR;
217 } 220 }
218 ; 221 ;
219 222
220 begin : /* empty */ 223 begin : /* empty */
221 { 224 {
222 $$ = sieve_machine->pc; 225 $$ = mu_sieve_machine->pc;
223 } 226 }
224 ; 227 ;
225 228
226 test : command 229 test : command
227 { 230 {
228 mu_sieve_register_t *reg = mu_sieve_test_lookup (sieve_machine, 231 mu_sieve_register_t *reg =
229 $1.ident); 232 mu_sieve_test_lookup (mu_sieve_machine, $1.ident);
230 $$ = sieve_machine->pc; 233 $$ = mu_sieve_machine->pc;
231 234
232 if (!reg) 235 if (!reg)
233 sieve_compile_error (&mu_sieve_locus, 236 mu_sv_compile_error (&mu_sieve_locus,
234 _("unknown test: %s"), 237 _("unknown test: %s"),
235 $1.ident); 238 $1.ident);
236 else if (!reg->required) 239 else if (!reg->required)
237 sieve_compile_error (&mu_sieve_locus, 240 mu_sv_compile_error (&mu_sieve_locus,
238 _("test `%s' has not been required"), 241 _("test `%s' has not been required"),
239 $1.ident); 242 $1.ident);
240 else if (sieve_code_test (reg, $1.args)) 243 else if (mu_sv_code_test (reg, $1.args))
241 YYERROR; 244 YYERROR;
242 } 245 }
243 ; 246 ;
...@@ -251,19 +254,19 @@ command : IDENT maybe_arglist ...@@ -251,19 +254,19 @@ command : IDENT maybe_arglist
251 254
252 action : command 255 action : command
253 { 256 {
254 mu_sieve_register_t *reg = mu_sieve_action_lookup (sieve_machine, 257 mu_sieve_register_t *reg =
255 $1.ident); 258 mu_sieve_action_lookup (mu_sieve_machine, $1.ident);
256 259
257 $$ = sieve_machine->pc; 260 $$ = mu_sieve_machine->pc;
258 if (!reg) 261 if (!reg)
259 sieve_compile_error (&mu_sieve_locus, 262 mu_sv_compile_error (&mu_sieve_locus,
260 _("unknown action: %s"), 263 _("unknown action: %s"),
261 $1.ident); 264 $1.ident);
262 else if (!reg->required) 265 else if (!reg->required)
263 sieve_compile_error (&mu_sieve_locus, 266 mu_sv_compile_error (&mu_sieve_locus,
264 _("action `%s' has not been required"), 267 _("action `%s' has not been required"),
265 $1.ident); 268 $1.ident);
266 else if (sieve_code_action (reg, $1.args)) 269 else if (mu_sv_code_action (reg, $1.args))
267 YYERROR; 270 YYERROR;
268 } 271 }
269 ; 272 ;
...@@ -340,7 +343,7 @@ slist : STRING ...@@ -340,7 +343,7 @@ slist : STRING
340 int 343 int
341 yyerror (char *s) 344 yyerror (char *s)
342 { 345 {
343 sieve_compile_error (&mu_sieve_locus, "%s", s); 346 mu_sv_compile_error (&mu_sieve_locus, "%s", s);
344 return 0; 347 return 0;
345 } 348 }
346 349
...@@ -587,22 +590,22 @@ string_comp (const void *item, const void *value) ...@@ -587,22 +590,22 @@ string_comp (const void *item, const void *value)
587 void 590 void
588 mu_sieve_machine_begin (mu_sieve_machine_t mach, const char *file) 591 mu_sieve_machine_begin (mu_sieve_machine_t mach, const char *file)
589 { 592 {
590 sieve_machine = mach; 593 mu_sieve_machine = mach;
591 sieve_error_count = 0; 594 mu_sieve_error_count = 0;
592 sieve_code_instr (NULL); 595 mu_sv_code_instr (NULL);
593 596
594 mu_list_create (&mach->source_list); 597 mu_list_create (&mach->source_list);
595 mu_list_set_comparator (mach->source_list, string_comp); 598 mu_list_set_comparator (mach->source_list, string_comp);
596 599
597 sieve_register_standard_actions (mach); 600 mu_sv_register_standard_actions (mach);
598 sieve_register_standard_tests (mach); 601 mu_sv_register_standard_tests (mach);
599 sieve_register_standard_comparators (mach); 602 mu_sv_register_standard_comparators (mach);
600 } 603 }
601 604
602 void 605 void
603 mu_sieve_machine_finish (mu_sieve_machine_t mach) 606 mu_sieve_machine_finish (mu_sieve_machine_t mach)
604 { 607 {
605 sieve_code_instr (NULL); 608 mu_sv_code_instr (NULL);
606 } 609 }
607 610
608 int 611 int
...@@ -612,12 +615,12 @@ mu_sieve_compile (mu_sieve_machine_t mach, const char *name) ...@@ -612,12 +615,12 @@ mu_sieve_compile (mu_sieve_machine_t mach, const char *name)
612 615
613 mu_sieve_machine_begin (mach, name); 616 mu_sieve_machine_begin (mach, name);
614 617
615 if (sieve_lex_begin (name) == 0) 618 if (mu_sv_lex_begin (name) == 0)
616 { 619 {
617 rc = yyparse (); 620 rc = yyparse ();
618 if (sieve_error_count) 621 if (mu_sieve_error_count)
619 rc = 1; 622 rc = 1;
620 sieve_lex_finish (); 623 mu_sv_lex_finish ();
621 } 624 }
622 else 625 else
623 rc = 1; 626 rc = 1;
...@@ -637,12 +640,12 @@ mu_sieve_compile_buffer (mu_sieve_machine_t mach, ...@@ -637,12 +640,12 @@ mu_sieve_compile_buffer (mu_sieve_machine_t mach,
637 640
638 mu_sieve_machine_begin (mach, fname); 641 mu_sieve_machine_begin (mach, fname);
639 642
640 if (sieve_lex_begin_string (buf, bufsize, fname, line) == 0) 643 if (mu_sv_lex_begin_string (buf, bufsize, fname, line) == 0)
641 { 644 {
642 rc = yyparse (); 645 rc = yyparse ();
643 if (sieve_error_count) 646 if (mu_sieve_error_count)
644 rc = 1; 647 rc = 1;
645 sieve_lex_finish (); 648 mu_sv_lex_finish ();
646 } 649 }
647 else 650 else
648 rc = 1; 651 rc = 1;
...@@ -656,16 +659,38 @@ mu_sieve_compile_buffer (mu_sieve_machine_t mach, ...@@ -656,16 +659,38 @@ mu_sieve_compile_buffer (mu_sieve_machine_t mach,
656 static void 659 static void
657 _branch_fixup (size_t start, size_t end) 660 _branch_fixup (size_t start, size_t end)
658 { 661 {
659 size_t prev = sieve_machine->prog[start].pc; 662 size_t prev = mu_sieve_machine->prog[start].pc;
660 if (!prev) 663 if (!prev)
661 return; 664 return;
662 branch_fixup (prev, end); 665 branch_fixup (prev, end);
663 sieve_machine->prog[prev].pc = end - prev - 1; 666 mu_sieve_machine->prog[prev].pc = end - prev - 1;
664 } 667 }
665 668
666 void 669 static void
667 branch_fixup (size_t start, size_t end) 670 branch_fixup (size_t start, size_t end)
668 { 671 {
669 _branch_fixup (start, end); 672 _branch_fixup (start, end);
670 sieve_machine->prog[start].pc = end - start - 1; 673 mu_sieve_machine->prog[start].pc = end - start - 1;
674 }
675
676 static int
677 _sieve_default_error_printer (void *unused, const char *fmt, va_list ap)
678 {
679 return mu_verror (fmt, ap);
671 } 680 }
681
682 static int
683 _sieve_default_parse_error (void *unused, const char *filename, int lineno,
684 const char *fmt, va_list ap)
685 {
686 mu_debug_t debug;
687
688 mu_diag_get_debug (&debug);
689 if (filename)
690 mu_debug_set_locus (debug, filename, lineno);
691 mu_diag_vprintf (MU_DIAG_ERROR, fmt, ap);
692 mu_diag_printf (MU_DIAG_ERROR, "\n");
693 mu_debug_set_locus (debug, NULL, 0);
694 return 0;
695 }
696
......
1 /* GNU Mailutils -- a suite of utilities for electronic mail 1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2 Copyright (C) 1999, 2000, 2001, 2002, 2003,
3 2004, 2005, 2007 Free Software Foundation, Inc. 3 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 6 modify it under the terms of the GNU Lesser General Public
...@@ -407,7 +407,7 @@ static mu_sieve_tag_def_t mime_tags[] = { ...@@ -407,7 +407,7 @@ static mu_sieve_tag_def_t mime_tags[] = {
407 { address_part_tags, NULL } 407 { address_part_tags, NULL }
408 408
409 #define MATCH_PART_GROUP \ 409 #define MATCH_PART_GROUP \
410 { match_part_tags, mu_sieve_match_part_checker } 410 { match_part_tags, mu_sv_match_part_checker }
411 411
412 #define SIZE_GROUP { size_tags, NULL } 412 #define SIZE_GROUP { size_tags, NULL }
413 413
...@@ -454,7 +454,7 @@ mu_sieve_tag_group_t header_tag_groups[] = { ...@@ -454,7 +454,7 @@ mu_sieve_tag_group_t header_tag_groups[] = {
454 }; 454 };
455 455
456 void 456 void
457 sieve_register_standard_tests (mu_sieve_machine_t mach) 457 mu_sv_register_standard_tests (mu_sieve_machine_t mach)
458 { 458 {
459 mu_sieve_register_test (mach, "false", sieve_test_false, NULL, NULL, 1); 459 mu_sieve_register_test (mach, "false", sieve_test_false, NULL, NULL, 1);
460 mu_sieve_register_test (mach, "true", sieve_test_true, NULL, NULL, 1); 460 mu_sieve_register_test (mach, "true", sieve_test_true, NULL, NULL, 1);
......
...@@ -173,7 +173,7 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data) ...@@ -173,7 +173,7 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data)
173 break; 173 break;
174 174
175 default: 175 default:
176 sieve_compile_error (&mu_sieve_locus, _("invalid data type")); 176 mu_sv_compile_error (&mu_sieve_locus, _("invalid data type"));
177 abort (); 177 abort ();
178 } 178 }
179 return val; 179 return val;
...@@ -188,16 +188,16 @@ mu_sieve_value_get (mu_list_t vlist, size_t index) ...@@ -188,16 +188,16 @@ mu_sieve_value_get (mu_list_t vlist, size_t index)
188 } 188 }
189 189
190 void 190 void
191 sieve_compile_error (mu_sieve_locus_t *ploc, const char *fmt, ...) 191 mu_sv_compile_error (mu_sieve_locus_t *ploc, const char *fmt, ...)
192 { 192 {
193 va_list ap; 193 va_list ap;
194 194
195 va_start (ap, fmt); 195 va_start (ap, fmt);
196 sieve_error_count++; 196 mu_sieve_error_count++;
197 sieve_machine->parse_error_printer (sieve_machine->data, 197 mu_sieve_machine->parse_error_printer (mu_sieve_machine->data,
198 ploc->source_file, 198 ploc->source_file,
199 ploc->source_line, 199 ploc->source_line,
200 fmt, ap); 200 fmt, ap);
201 va_end (ap); 201 va_end (ap);
202 } 202 }
203 203
...@@ -233,8 +233,12 @@ mu_sieve_arg_error (mu_sieve_machine_t mach, int n) ...@@ -233,8 +233,12 @@ mu_sieve_arg_error (mu_sieve_machine_t mach, int n)
233 mu_sieve_error (mach, _("cannot retrieve argument %d"), n); 233 mu_sieve_error (mach, _("cannot retrieve argument %d"), n);
234 } 234 }
235 235
236 void 236 static void sieve_debug_internal (mu_sieve_printf_t printer, void *data,
237 sieve_debug_internal (mu_sieve_printf_t printer, void *data, const char *fmt, ...) 237 const char *fmt, ...) MU_PRINTFLIKE(3,4);
238
239 static void
240 sieve_debug_internal (mu_sieve_printf_t printer, void *data,
241 const char *fmt, ...)
238 { 242 {
239 va_list ap; 243 va_list ap;
240 244
...@@ -267,28 +271,6 @@ mu_sieve_log_action (mu_sieve_machine_t mach, const char *action, ...@@ -267,28 +271,6 @@ mu_sieve_log_action (mu_sieve_machine_t mach, const char *action,
267 va_end (ap); 271 va_end (ap);
268 } 272 }
269 273
270
271 int
272 _sieve_default_error_printer (void *unused, const char *fmt, va_list ap)
273 {
274 return mu_verror (fmt, ap);
275 }
276
277 int
278 _sieve_default_parse_error (void *unused, const char *filename, int lineno,
279 const char *fmt, va_list ap)
280 {
281 mu_debug_t debug;
282
283 mu_diag_get_debug (&debug);
284 if (filename)
285 mu_debug_set_locus (debug, filename, lineno);
286 mu_diag_vprintf (MU_DIAG_ERROR, fmt, ap);
287 mu_diag_printf (MU_DIAG_ERROR, "\n");
288 mu_debug_set_locus (debug, NULL, 0);
289 return 0;
290 }
291
292 const char * 274 const char *
293 mu_sieve_type_str (mu_sieve_data_type type) 275 mu_sieve_type_str (mu_sieve_data_type type)
294 { 276 {
...@@ -334,6 +316,9 @@ string_printer (char *s, struct debug_data *dbg) ...@@ -334,6 +316,9 @@ string_printer (char *s, struct debug_data *dbg)
334 return 0; 316 return 0;
335 } 317 }
336 318
319 static void sieve_print_value (mu_sieve_value_t *, mu_sieve_printf_t,
320 void *);
321
337 static int 322 static int
338 value_printer (mu_sieve_value_t *val, struct debug_data *dbg) 323 value_printer (mu_sieve_value_t *val, struct debug_data *dbg)
339 { 324 {
...@@ -342,8 +327,9 @@ value_printer (mu_sieve_value_t *val, struct debug_data *dbg) ...@@ -342,8 +327,9 @@ value_printer (mu_sieve_value_t *val, struct debug_data *dbg)
342 return 0; 327 return 0;
343 } 328 }
344 329
345 void 330 static void
346 sieve_print_value (mu_sieve_value_t *val, mu_sieve_printf_t printer, void *data) 331 sieve_print_value (mu_sieve_value_t *val, mu_sieve_printf_t printer,
332 void *data)
347 { 333 {
348 struct debug_data dbg; 334 struct debug_data dbg;
349 335
...@@ -381,7 +367,7 @@ sieve_print_value (mu_sieve_value_t *val, mu_sieve_printf_t printer, void *data) ...@@ -381,7 +367,7 @@ sieve_print_value (mu_sieve_value_t *val, mu_sieve_printf_t printer, void *data)
381 } 367 }
382 368
383 void 369 void
384 sieve_print_value_list (mu_list_t list, mu_sieve_printf_t printer, void *data) 370 mu_sv_print_value_list (mu_list_t list, mu_sieve_printf_t printer, void *data)
385 { 371 {
386 mu_sieve_value_t val; 372 mu_sieve_value_t val;
387 373
...@@ -405,7 +391,7 @@ tag_printer (mu_sieve_runtime_tag_t *val, struct debug_data *dbg) ...@@ -405,7 +391,7 @@ tag_printer (mu_sieve_runtime_tag_t *val, struct debug_data *dbg)
405 } 391 }
406 392
407 void 393 void
408 sieve_print_tag_list (mu_list_t list, mu_sieve_printf_t printer, void *data) 394 mu_sv_print_tag_list (mu_list_t list, mu_sieve_printf_t printer, void *data)
409 { 395 {
410 struct debug_data dbg; 396 struct debug_data dbg;
411 397
...@@ -444,25 +430,6 @@ mu_sieve_tag_lookup (mu_list_t taglist, char *name, mu_sieve_value_t **arg) ...@@ -444,25 +430,6 @@ mu_sieve_tag_lookup (mu_list_t taglist, char *name, mu_sieve_value_t **arg)
444 } 430 }
445 431
446 int 432 int
447 sieve_mark_deleted (mu_message_t msg, int deleted)
448 {
449 mu_attribute_t attr = 0;
450 int rc;
451
452 rc = mu_message_get_attribute (msg, &attr);
453
454 if (!rc)
455 {
456 if (deleted)
457 rc = mu_attribute_set_deleted (attr);
458 else
459 rc = mu_attribute_unset_deleted (attr);
460 }
461
462 return rc;
463 }
464
465 int
466 mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t *ac, void *data) 433 mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t *ac, void *data)
467 { 434 {
468 switch (val->type) 435 switch (val->type)
......