sieve: more improvements to the argument/tag runtime access API
* include/mailutils/sieve.h (mu_sieve_handler_t): Change signature: remove args and tags arguments, they are contained in struct mu_sieve_machine now. (mu_sieve_get_comparator) (mu_sieve_relcmpn_t): Change signature. (mu_sieve_tag_lookup,mu_sieve_tag_lookup_untyped): Remove (mu_sieve_get_tag,mu_sieve_get_tag_untyped): New protos. (mu_sieve_value_get_optional): Replace by mu_sieve_get_arg_optional. (mu_sieve_value_get_untyped): Replace by mu_sieve_get_arg_untyped. (mu_sieve_value_get): Replace by mu_sieve_get_arg. All uses changed. * libmu_sieve/sieve-priv.h (mu_sieve_machine): New members: arg_list and tag_list * libmu_sieve/runtime.c (instr_run): Set up identifier, arg_list, and tag_list in mu_sieve_machine_t before calling the handler. Reset them afterward. * libmu_sieve/util.c (mu_sieve_value_get_optional): Replace by mu_sieve_get_arg_optional. (mu_sieve_value_get_untyped): Replace by mu_sieve_get_arg_untyped. (mu_sieve_value_get): Replace by mu_sieve_get_arg. (mu_sieve_tag_lookup): Replace by mu_sieve_get_tag (mu_sieve_tag_lookup_untyped): Replace by mu_sieve_get_tag_untyped
Showing
17 changed files
with
183 additions
and
195 deletions
... | @@ -78,7 +78,7 @@ _count_items (void *item, void *data) | ... | @@ -78,7 +78,7 @@ _count_items (void *item, void *data) |
78 | 78 | ||
79 | /* Handler for the numaddr test */ | 79 | /* Handler for the numaddr test */ |
80 | static int | 80 | static int |
81 | numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 81 | numaddr_test (mu_sieve_machine_t mach) |
82 | { | 82 | { |
83 | mu_sieve_value_t *h; | 83 | mu_sieve_value_t *h; |
84 | struct val_ctr vc; | 84 | struct val_ctr vc; |
... | @@ -86,9 +86,9 @@ numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -86,9 +86,9 @@ numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
86 | 86 | ||
87 | /* Retrieve required arguments: */ | 87 | /* Retrieve required arguments: */ |
88 | /* First argument: list of header names */ | 88 | /* First argument: list of header names */ |
89 | h = mu_sieve_value_get_untyped (mach, args, 0); | 89 | h = mu_sieve_get_arg_untyped (mach, 0); |
90 | /* Second argument: Limit on the number of addresses */ | 90 | /* Second argument: Limit on the number of addresses */ |
91 | mu_sieve_value_get (mach, args, 1, SVT_NUMBER, &vc.limit); | 91 | mu_sieve_get_arg (mach, 1, SVT_NUMBER, &vc.limit); |
92 | 92 | ||
93 | /* Fill in the val_ctr structure */ | 93 | /* Fill in the val_ctr structure */ |
94 | mu_message_get_header (mu_sieve_get_message (mach), &vc.hdr); | 94 | mu_message_get_header (mu_sieve_get_message (mach), &vc.hdr); |
... | @@ -99,7 +99,7 @@ numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -99,7 +99,7 @@ numaddr_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
99 | 99 | ||
100 | /* Here rc >= 1 iff the counted number of addresses is greater or equal | 100 | /* Here rc >= 1 iff the counted number of addresses is greater or equal |
101 | to vc.limit. If `:under' tag was given we reverse the return value */ | 101 | to vc.limit. If `:under' tag was given we reverse the return value */ |
102 | if (mu_sieve_tag_lookup (mach, tags, "under", SVT_VOID, NULL)) | 102 | if (mu_sieve_get_tag (mach, "under", SVT_VOID, NULL)) |
103 | rc = !rc; | 103 | rc = !rc; |
104 | 104 | ||
105 | return rc; | 105 | return rc; | ... | ... |
gint @ fd86bf7d
... | @@ -33,8 +33,7 @@ extern "C" { | ... | @@ -33,8 +33,7 @@ extern "C" { |
33 | 33 | ||
34 | typedef struct mu_sieve_machine *mu_sieve_machine_t; | 34 | typedef struct mu_sieve_machine *mu_sieve_machine_t; |
35 | 35 | ||
36 | typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach, | 36 | typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach); |
37 | mu_list_t args, mu_list_t tags); | ||
38 | typedef void (*mu_sieve_action_log_t) (mu_sieve_machine_t mach, | 37 | typedef void (*mu_sieve_action_log_t) (mu_sieve_machine_t mach, |
39 | const char *action, | 38 | const char *action, |
40 | const char *fmt, va_list ap); | 39 | const char *fmt, va_list ap); |
... | @@ -175,20 +174,17 @@ mu_sieve_comparator_t mu_sieve_comparator_lookup (mu_sieve_machine_t mach, | ... | @@ -175,20 +174,17 @@ mu_sieve_comparator_t mu_sieve_comparator_lookup (mu_sieve_machine_t mach, |
175 | const char *name, | 174 | const char *name, |
176 | int matchtype); | 175 | int matchtype); |
177 | 176 | ||
178 | mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach, | 177 | mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach); |
179 | mu_list_t tags); | ||
180 | int mu_sieve_str_to_relcmp (const char *str, mu_sieve_relcmp_t *test, | 178 | int mu_sieve_str_to_relcmp (const char *str, mu_sieve_relcmp_t *test, |
181 | mu_sieve_relcmpn_t *stest); | 179 | mu_sieve_relcmpn_t *stest); |
182 | mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach, | 180 | mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach); |
183 | mu_list_t tags); | ||
184 | 181 | ||
185 | void mu_sieve_require (mu_sieve_machine_t mach, mu_list_t slist); | 182 | void mu_sieve_require (mu_sieve_machine_t mach, mu_list_t slist); |
186 | 183 | ||
187 | int mu_sieve_tag_lookup (mu_sieve_machine_t mach, | 184 | int mu_sieve_get_tag (mu_sieve_machine_t mach, char *name, |
188 | mu_list_t taglist, char *name, | 185 | mu_sieve_data_type type, void *ret); |
189 | mu_sieve_data_type type, void *ret); | 186 | int mu_sieve_get_tag_untyped (mu_sieve_machine_t mach, |
190 | int mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist, | 187 | char *name, mu_sieve_value_t **ret); |
191 | char *name, mu_sieve_value_t **ret); | ||
192 | 188 | ||
193 | int mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name); | 189 | int mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name); |
194 | int mu_sieve_match_part_checker (mu_sieve_machine_t mach, | 190 | int mu_sieve_match_part_checker (mu_sieve_machine_t mach, |
... | @@ -198,15 +194,12 @@ int mu_sieve_match_part_checker (mu_sieve_machine_t mach, | ... | @@ -198,15 +194,12 @@ int mu_sieve_match_part_checker (mu_sieve_machine_t mach, |
198 | const char *name, mu_list_t tags, | 194 | const char *name, mu_list_t tags, |
199 | mu_list_t args); | 195 | mu_list_t args); |
200 | /* Operations on value lists */ | 196 | /* Operations on value lists */ |
201 | mu_sieve_value_t *mu_sieve_value_get_optional (mu_sieve_machine_t mach, | 197 | mu_sieve_value_t *mu_sieve_get_arg_optional (mu_sieve_machine_t mach, |
202 | mu_list_t vlist, | 198 | size_t index); |
203 | size_t index); | 199 | mu_sieve_value_t *mu_sieve_get_arg_untyped (mu_sieve_machine_t mach, |
204 | mu_sieve_value_t *mu_sieve_value_get_untyped (mu_sieve_machine_t mach, | 200 | size_t index); |
205 | mu_list_t vlist, | 201 | int mu_sieve_get_arg (mu_sieve_machine_t mach, size_t index, |
206 | size_t index); | 202 | mu_sieve_data_type type, void *ret); |
207 | int mu_sieve_value_get (mu_sieve_machine_t mach, mu_list_t vlist, | ||
208 | size_t index, | ||
209 | mu_sieve_data_type type, void *ret); | ||
210 | int mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t ac, | 203 | int mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t ac, |
211 | void *data); | 204 | void *data); |
212 | int mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b, | 205 | int mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b, | ... | ... |
... | @@ -47,7 +47,7 @@ sieve_mark_deleted (mu_message_t msg, int deleted) | ... | @@ -47,7 +47,7 @@ sieve_mark_deleted (mu_message_t msg, int deleted) |
47 | 47 | ||
48 | 48 | ||
49 | static int | 49 | static int |
50 | sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 50 | sieve_action_stop (mu_sieve_machine_t mach) |
51 | { | 51 | { |
52 | mu_sieve_log_action (mach, "STOP", NULL); | 52 | mu_sieve_log_action (mach, "STOP", NULL); |
53 | mach->pc = 0; | 53 | mach->pc = 0; |
... | @@ -55,7 +55,7 @@ sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -55,7 +55,7 @@ sieve_action_stop (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
55 | } | 55 | } |
56 | 56 | ||
57 | static int | 57 | static int |
58 | sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 58 | sieve_action_keep (mu_sieve_machine_t mach) |
59 | { | 59 | { |
60 | mu_sieve_log_action (mach, "KEEP", NULL); | 60 | mu_sieve_log_action (mach, "KEEP", NULL); |
61 | if (mu_sieve_is_dry_run (mach)) | 61 | if (mu_sieve_is_dry_run (mach)) |
... | @@ -65,7 +65,7 @@ sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -65,7 +65,7 @@ sieve_action_keep (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
65 | } | 65 | } |
66 | 66 | ||
67 | static int | 67 | static int |
68 | sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 68 | sieve_action_discard (mu_sieve_machine_t mach) |
69 | { | 69 | { |
70 | mu_sieve_log_action (mach, "DISCARD", _("marking as deleted")); | 70 | mu_sieve_log_action (mach, "DISCARD", _("marking as deleted")); |
71 | if (mu_sieve_is_dry_run (mach)) | 71 | if (mu_sieve_is_dry_run (mach)) |
... | @@ -75,16 +75,16 @@ sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -75,16 +75,16 @@ sieve_action_discard (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
75 | } | 75 | } |
76 | 76 | ||
77 | static int | 77 | static int |
78 | sieve_action_fileinto (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 78 | sieve_action_fileinto (mu_sieve_machine_t mach) |
79 | { | 79 | { |
80 | int rc; | 80 | int rc; |
81 | int mbflags = 0; | 81 | int mbflags = 0; |
82 | char *filename; | 82 | char *filename; |
83 | char *perms; | 83 | char *perms; |
84 | 84 | ||
85 | mu_sieve_value_get (mach, args, 0, SVT_STRING, &filename); | 85 | mu_sieve_get_arg (mach, 0, SVT_STRING, &filename); |
86 | 86 | ||
87 | if (mu_sieve_tag_lookup (mach, tags, "permissions", SVT_STRING, &perms)) | 87 | if (mu_sieve_get_tag (mach, "permissions", SVT_STRING, &perms)) |
88 | { | 88 | { |
89 | const char *p; | 89 | const char *p; |
90 | 90 | ||
... | @@ -281,7 +281,7 @@ build_mime (mu_mime_t *pmime, mu_message_t msg, const char *text) | ... | @@ -281,7 +281,7 @@ build_mime (mu_mime_t *pmime, mu_message_t msg, const char *text) |
281 | } | 281 | } |
282 | 282 | ||
283 | static int | 283 | static int |
284 | sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 284 | sieve_action_reject (mu_sieve_machine_t mach) |
285 | { | 285 | { |
286 | mu_mime_t mime = NULL; | 286 | mu_mime_t mime = NULL; |
287 | mu_mailer_t mailer = mu_sieve_get_mailer (mach); | 287 | mu_mailer_t mailer = mu_sieve_get_mailer (mach); |
... | @@ -292,7 +292,7 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -292,7 +292,7 @@ sieve_action_reject (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
292 | mu_header_t hdr; | 292 | mu_header_t hdr; |
293 | char *text; | 293 | char *text; |
294 | 294 | ||
295 | mu_sieve_value_get (mach, args, 0, SVT_STRING, &text); | 295 | mu_sieve_get_arg (mach, 0, SVT_STRING, &text); |
296 | mu_sieve_log_action (mach, "REJECT", NULL); | 296 | mu_sieve_log_action (mach, "REJECT", NULL); |
297 | if (mu_sieve_is_dry_run (mach)) | 297 | if (mu_sieve_is_dry_run (mach)) |
298 | return 0; | 298 | return 0; |
... | @@ -398,7 +398,7 @@ check_redirect_loop (mu_message_t msg) | ... | @@ -398,7 +398,7 @@ check_redirect_loop (mu_message_t msg) |
398 | } | 398 | } |
399 | 399 | ||
400 | static int | 400 | static int |
401 | sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 401 | sieve_action_redirect (mu_sieve_machine_t mach) |
402 | { | 402 | { |
403 | mu_message_t msg, newmsg = NULL; | 403 | mu_message_t msg, newmsg = NULL; |
404 | mu_address_t addr = NULL, from = NULL; | 404 | mu_address_t addr = NULL, from = NULL; |
... | @@ -408,7 +408,7 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -408,7 +408,7 @@ sieve_action_redirect (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
408 | mu_mailer_t mailer = mu_sieve_get_mailer (mach); | 408 | mu_mailer_t mailer = mu_sieve_get_mailer (mach); |
409 | char *addrstr; | 409 | char *addrstr; |
410 | 410 | ||
411 | mu_sieve_value_get (mach, args, 0, SVT_STRING, &addrstr); | 411 | mu_sieve_get_arg (mach, 0, SVT_STRING, &addrstr); |
412 | 412 | ||
413 | rc = mu_address_create (&addr, addrstr); | 413 | rc = mu_address_create (&addr, addrstr); |
414 | if (rc) | 414 | if (rc) | ... | ... |
... | @@ -127,14 +127,14 @@ _find_comparator (void *item, void *data) | ... | @@ -127,14 +127,14 @@ _find_comparator (void *item, void *data) |
127 | } | 127 | } |
128 | 128 | ||
129 | mu_sieve_comparator_t | 129 | mu_sieve_comparator_t |
130 | mu_sieve_get_comparator (mu_sieve_machine_t mach, mu_list_t tags) | 130 | mu_sieve_get_comparator (mu_sieve_machine_t mach) |
131 | { | 131 | { |
132 | mu_sieve_comparator_t comp = NULL; | 132 | mu_sieve_comparator_t comp = NULL; |
133 | 133 | ||
134 | mu_list_foreach (tags, _find_comparator, &comp); | 134 | mu_list_foreach (mach->tag_list, _find_comparator, &comp); |
135 | return comp ? comp : mu_sieve_comparator_lookup (mach, | 135 | return comp ? comp : mu_sieve_comparator_lookup (mach, |
136 | "i;ascii-casemap", | 136 | "i;ascii-casemap", |
137 | MU_SIEVE_MATCH_IS); | 137 | MU_SIEVE_MATCH_IS); |
138 | } | 138 | } |
139 | 139 | ||
140 | /* Compile time support */ | 140 | /* Compile time support */ | ... | ... |
... | @@ -31,7 +31,7 @@ | ... | @@ -31,7 +31,7 @@ |
31 | /* Syntax: addheader [:last] <field-name: string> <value: string> | 31 | /* Syntax: addheader [:last] <field-name: string> <value: string> |
32 | */ | 32 | */ |
33 | int | 33 | int |
34 | sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 34 | sieve_addheader (mu_sieve_machine_t mach) |
35 | { | 35 | { |
36 | const char *field_name; | 36 | const char *field_name; |
37 | const char *field_value; | 37 | const char *field_value; |
... | @@ -39,8 +39,8 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -39,8 +39,8 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
39 | mu_header_t hdr; | 39 | mu_header_t hdr; |
40 | int rc; | 40 | int rc; |
41 | 41 | ||
42 | mu_sieve_value_get (mach, args, 0, SVT_STRING, &field_name); | 42 | mu_sieve_get_arg (mach, 0, SVT_STRING, &field_name); |
43 | mu_sieve_value_get (mach, args, 1, SVT_STRING, &field_value); | 43 | mu_sieve_get_arg (mach, 1, SVT_STRING, &field_value); |
44 | 44 | ||
45 | mu_sieve_log_action (mach, "ADDHEADER", "%s: %s", field_name, field_value); | 45 | mu_sieve_log_action (mach, "ADDHEADER", "%s: %s", field_name, field_value); |
46 | 46 | ||
... | @@ -58,7 +58,7 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -58,7 +58,7 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
58 | mu_sieve_abort (mach); | 58 | mu_sieve_abort (mach); |
59 | } | 59 | } |
60 | 60 | ||
61 | rc = (mu_sieve_tag_lookup (mach, tags, "last", SVT_VOID, NULL) ? | 61 | rc = (mu_sieve_get_tag (mach, "last", SVT_VOID, NULL) ? |
62 | mu_header_append : mu_header_prepend) (hdr, field_name, field_value); | 62 | mu_header_append : mu_header_prepend) (hdr, field_name, field_value); |
63 | if (rc) | 63 | if (rc) |
64 | { | 64 | { |
... | @@ -77,7 +77,7 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -77,7 +77,7 @@ sieve_addheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
77 | [<value-patterns: string-list>] | 77 | [<value-patterns: string-list>] |
78 | */ | 78 | */ |
79 | int | 79 | int |
80 | sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 80 | sieve_deleteheader (mu_sieve_machine_t mach) |
81 | { | 81 | { |
82 | mu_sieve_value_t *val; | 82 | mu_sieve_value_t *val; |
83 | const char *field_name; | 83 | const char *field_name; |
... | @@ -89,8 +89,8 @@ sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -89,8 +89,8 @@ sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
89 | mu_iterator_t itr; | 89 | mu_iterator_t itr; |
90 | size_t i, idx = 0; | 90 | size_t i, idx = 0; |
91 | 91 | ||
92 | mu_sieve_value_get (mach, args, 0, SVT_STRING, &field_name); | 92 | mu_sieve_get_arg (mach, 0, SVT_STRING, &field_name); |
93 | val = mu_sieve_value_get_optional (mach, args, 1); | 93 | val = mu_sieve_get_arg_optional (mach, 1); |
94 | if (!val) | 94 | if (!val) |
95 | { | 95 | { |
96 | field_pattern = NULL; | 96 | field_pattern = NULL; |
... | @@ -142,14 +142,14 @@ sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -142,14 +142,14 @@ sieve_deleteheader (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
142 | } | 142 | } |
143 | 143 | ||
144 | mu_header_get_iterator (hdr, &itr); | 144 | mu_header_get_iterator (hdr, &itr); |
145 | if (mu_sieve_tag_lookup (mach, tags, "last", SVT_VOID, NULL)) | 145 | if (mu_sieve_get_tag (mach, "last", SVT_VOID, NULL)) |
146 | { | 146 | { |
147 | int backwards = 1; | 147 | int backwards = 1; |
148 | mu_iterator_ctl (itr, mu_itrctl_set_direction, &backwards); | 148 | mu_iterator_ctl (itr, mu_itrctl_set_direction, &backwards); |
149 | } | 149 | } |
150 | comp = mu_sieve_get_comparator (mach, tags); | 150 | comp = mu_sieve_get_comparator (mach); |
151 | 151 | ||
152 | mu_sieve_tag_lookup (mach, tags, "index", SVT_NUMBER, &idx); | 152 | mu_sieve_get_tag (mach, "index", SVT_NUMBER, &idx); |
153 | 153 | ||
154 | for (i = 0, mu_iterator_first (itr); !mu_iterator_is_done (itr); | 154 | for (i = 0, mu_iterator_first (itr); !mu_iterator_is_done (itr); |
155 | mu_iterator_next (itr)) | 155 | mu_iterator_next (itr)) | ... | ... |
... | @@ -145,22 +145,22 @@ list_retrieve_header (void *item, void *data, int idx, char **pval) | ... | @@ -145,22 +145,22 @@ list_retrieve_header (void *item, void *data, int idx, char **pval) |
145 | */ | 145 | */ |
146 | 146 | ||
147 | static int | 147 | static int |
148 | list_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 148 | list_test (mu_sieve_machine_t mach) |
149 | { | 149 | { |
150 | mu_sieve_value_t *h, *v; | 150 | mu_sieve_value_t *h, *v; |
151 | mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags); | 151 | mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach); |
152 | struct header_closure clos; | 152 | struct header_closure clos; |
153 | int result; | 153 | int result; |
154 | 154 | ||
155 | memset (&clos, 0, sizeof clos); | 155 | memset (&clos, 0, sizeof clos); |
156 | if (!mu_sieve_tag_lookup (mach, tags, "delim", SVT_STRING, &clos.delim)) | 156 | if (!mu_sieve_get_tag (mach, "delim", SVT_STRING, &clos.delim)) |
157 | clos.delim = ","; | 157 | clos.delim = ","; |
158 | 158 | ||
159 | h = mu_sieve_value_get_untyped (mach, args, 0); | 159 | h = mu_sieve_get_arg_untyped (mach, 0); |
160 | v = mu_sieve_value_get_untyped (mach, args, 1); | 160 | v = mu_sieve_get_arg_untyped (mach, 1); |
161 | mu_message_get_header (mu_sieve_get_message (mach), &clos.header); | 161 | mu_message_get_header (mu_sieve_get_message (mach), &clos.header); |
162 | result = mu_sieve_vlist_compare (h, v, comp, | 162 | result = mu_sieve_vlist_compare (h, v, comp, |
163 | mu_sieve_get_relcmp (mach, tags), | 163 | mu_sieve_get_relcmp (mach), |
164 | list_retrieve_header, | 164 | list_retrieve_header, |
165 | &clos, NULL) > 0; | 165 | &clos, NULL) > 0; |
166 | cleanup (&clos); | 166 | cleanup (&clos); | ... | ... |
... | @@ -74,7 +74,7 @@ | ... | @@ -74,7 +74,7 @@ |
74 | #include <stdlib.h> | 74 | #include <stdlib.h> |
75 | 75 | ||
76 | static int | 76 | static int |
77 | moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags, | 77 | moderator_filter_message (mu_sieve_machine_t mach, |
78 | mu_message_t msg, int *pdiscard) | 78 | mu_message_t msg, int *pdiscard) |
79 | { | 79 | { |
80 | int rc; | 80 | int rc; |
... | @@ -82,7 +82,7 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags, | ... | @@ -82,7 +82,7 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags, |
82 | mu_attribute_t attr; | 82 | mu_attribute_t attr; |
83 | char *arg; | 83 | char *arg; |
84 | 84 | ||
85 | if (mu_sieve_tag_lookup (mach, tags, "source", SVT_STRING, &arg)) | 85 | if (mu_sieve_get_tag (mach, "source", SVT_STRING, &arg)) |
86 | { | 86 | { |
87 | rc = mu_sieve_machine_inherit (mach, &newmach); | 87 | rc = mu_sieve_machine_inherit (mach, &newmach); |
88 | if (rc) | 88 | if (rc) |
... | @@ -101,7 +101,7 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags, | ... | @@ -101,7 +101,7 @@ moderator_filter_message (mu_sieve_machine_t mach, mu_list_t tags, |
101 | if (rc) | 101 | if (rc) |
102 | mu_sieve_error (mach, _("cannot compile source `%s'"), arg); | 102 | mu_sieve_error (mach, _("cannot compile source `%s'"), arg); |
103 | } | 103 | } |
104 | else if (mu_sieve_tag_lookup (mach, tags, "program", SVT_STRING, &arg)) | 104 | else if (mu_sieve_get_tag (mach, "program", SVT_STRING, &arg)) |
105 | { | 105 | { |
106 | struct mu_locus locus; | 106 | struct mu_locus locus; |
107 | 107 | ||
... | @@ -265,7 +265,7 @@ moderator_message_get_part (mu_sieve_machine_t mach, | ... | @@ -265,7 +265,7 @@ moderator_message_get_part (mu_sieve_machine_t mach, |
265 | } | 265 | } |
266 | 266 | ||
267 | static int | 267 | static int |
268 | moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 268 | moderator_action (mu_sieve_machine_t mach) |
269 | { | 269 | { |
270 | mu_message_t msg, orig; | 270 | mu_message_t msg, orig; |
271 | int rc; | 271 | int rc; |
... | @@ -294,7 +294,7 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -294,7 +294,7 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
294 | if ((rc = moderator_message_get_part (mach, msg, 2, &orig))) | 294 | if ((rc = moderator_message_get_part (mach, msg, 2, &orig))) |
295 | mu_sieve_abort (mach); | 295 | mu_sieve_abort (mach); |
296 | 296 | ||
297 | rc = moderator_filter_message (mach, tags, orig, &discard); | 297 | rc = moderator_filter_message (mach, orig, &discard); |
298 | mu_message_unref (orig); | 298 | mu_message_unref (orig); |
299 | if (rc) | 299 | if (rc) |
300 | mu_sieve_abort (mach); | 300 | mu_sieve_abort (mach); |
... | @@ -311,13 +311,13 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -311,13 +311,13 @@ moderator_action (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
311 | mu_sieve_abort (mach); | 311 | mu_sieve_abort (mach); |
312 | } | 312 | } |
313 | 313 | ||
314 | mu_sieve_tag_lookup (mach, tags, "address", SVT_STRING, &from); | 314 | mu_sieve_get_tag (mach, "address", SVT_STRING, &from); |
315 | 315 | ||
316 | if (moderator_discard_message (mach, request, from)) | 316 | if (moderator_discard_message (mach, request, from)) |
317 | discard = 0; | 317 | discard = 0; |
318 | else | 318 | else |
319 | { | 319 | { |
320 | if (!mu_sieve_tag_lookup (mach, tags, "keep", SVT_VOID, NULL)) | 320 | if (!mu_sieve_get_tag (mach, "keep", SVT_VOID, NULL)) |
321 | { | 321 | { |
322 | mu_attribute_t attr = 0; | 322 | mu_attribute_t attr = 0; |
323 | 323 | ... | ... |
... | @@ -82,7 +82,7 @@ | ... | @@ -82,7 +82,7 @@ |
82 | #define PIPE_ALL (PIPE_ENVELOPE | PIPE_HEADERS | PIPE_BODY) | 82 | #define PIPE_ALL (PIPE_ENVELOPE | PIPE_HEADERS | PIPE_BODY) |
83 | 83 | ||
84 | int | 84 | int |
85 | sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) | 85 | sieve_pipe (mu_sieve_machine_t mach, int test) |
86 | { | 86 | { |
87 | int retval = 0; | 87 | int retval = 0; |
88 | int rc, result; | 88 | int rc, result; |
... | @@ -94,7 +94,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) | ... | @@ -94,7 +94,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) |
94 | const char *error_arg = NULL; | 94 | const char *error_arg = NULL; |
95 | int pipe_mask = 0; | 95 | int pipe_mask = 0; |
96 | 96 | ||
97 | mu_sieve_value_get (mach, args, 0, SVT_STRING, &cmd); | 97 | mu_sieve_get_arg (mach, 0, SVT_STRING, &cmd); |
98 | 98 | ||
99 | if (mu_sieve_is_dry_run (mach)) | 99 | if (mu_sieve_is_dry_run (mach)) |
100 | return 0; | 100 | return 0; |
... | @@ -102,11 +102,11 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) | ... | @@ -102,11 +102,11 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) |
102 | msg = mu_sieve_get_message (mach); | 102 | msg = mu_sieve_get_message (mach); |
103 | mu_message_get_envelope (msg, &env); | 103 | mu_message_get_envelope (msg, &env); |
104 | 104 | ||
105 | if (mu_sieve_tag_lookup (mach, tags, "envelope", SVT_VOID, NULL)) | 105 | if (mu_sieve_get_tag (mach, "envelope", SVT_VOID, NULL)) |
106 | pipe_mask |= PIPE_ENVELOPE; | 106 | pipe_mask |= PIPE_ENVELOPE; |
107 | if (mu_sieve_tag_lookup (mach, tags, "header", SVT_VOID, NULL)) | 107 | if (mu_sieve_get_tag (mach, "header", SVT_VOID, NULL)) |
108 | pipe_mask |= PIPE_HEADERS; | 108 | pipe_mask |= PIPE_HEADERS; |
109 | if (mu_sieve_tag_lookup (mach, tags, "body", SVT_VOID, NULL)) | 109 | if (mu_sieve_get_tag (mach, "body", SVT_VOID, NULL)) |
110 | pipe_mask |= PIPE_BODY; | 110 | pipe_mask |= PIPE_BODY; |
111 | if (pipe_mask == 0) | 111 | if (pipe_mask == 0) |
112 | pipe_mask = PIPE_ALL; | 112 | pipe_mask = PIPE_ALL; |
... | @@ -194,7 +194,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) | ... | @@ -194,7 +194,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) |
194 | mu_sieve_abort (mach); | 194 | mu_sieve_abort (mach); |
195 | } | 195 | } |
196 | 196 | ||
197 | if (mu_sieve_tag_lookup (mach, tags, "exit", SVT_NUMBER, &n)) | 197 | if (mu_sieve_get_tag (mach, "exit", SVT_NUMBER, &n)) |
198 | code = n; | 198 | code = n; |
199 | if (result == 0) | 199 | if (result == 0) |
200 | retval = code == 0; | 200 | retval = code == 0; |
... | @@ -204,7 +204,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) | ... | @@ -204,7 +204,7 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) |
204 | { | 204 | { |
205 | int signo = WTERMSIG (status); | 205 | int signo = WTERMSIG (status); |
206 | size_t n; | 206 | size_t n; |
207 | if (mu_sieve_tag_lookup (mach, tags, "signal", SVT_NUMBER, &n)) | 207 | if (mu_sieve_get_tag (mach, "signal", SVT_NUMBER, &n)) |
208 | retval = signo == n; | 208 | retval = signo == n; |
209 | else | 209 | else |
210 | { | 210 | { |
... | @@ -228,16 +228,16 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) | ... | @@ -228,16 +228,16 @@ sieve_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, int test) |
228 | } | 228 | } |
229 | 229 | ||
230 | int | 230 | int |
231 | sieve_action_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 231 | sieve_action_pipe (mu_sieve_machine_t mach) |
232 | { | 232 | { |
233 | mu_sieve_log_action (mach, "PIPE", NULL); | 233 | mu_sieve_log_action (mach, "PIPE", NULL); |
234 | return sieve_pipe (mach, args, tags, 0); | 234 | return sieve_pipe (mach, 0); |
235 | } | 235 | } |
236 | 236 | ||
237 | int | 237 | int |
238 | sieve_test_pipe (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 238 | sieve_test_pipe (mu_sieve_machine_t mach) |
239 | { | 239 | { |
240 | return sieve_pipe (mach, args, tags, 1); | 240 | return sieve_pipe (mach, 1); |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ... | ... |
... | @@ -353,7 +353,7 @@ get_real_message_size (mu_message_t msg, size_t *psize) | ... | @@ -353,7 +353,7 @@ get_real_message_size (mu_message_t msg, size_t *psize) |
353 | */ | 353 | */ |
354 | 354 | ||
355 | static int | 355 | static int |
356 | spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 356 | spamd_test (mu_sieve_machine_t mach) |
357 | { | 357 | { |
358 | char *buffer = NULL; | 358 | char *buffer = NULL; |
359 | size_t size; | 359 | size_t size; |
... | @@ -381,12 +381,12 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -381,12 +381,12 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
381 | mu_sieve_abort (mach); | 381 | mu_sieve_abort (mach); |
382 | } | 382 | } |
383 | 383 | ||
384 | if (!mu_sieve_tag_lookup (mach, tags, "host", SVT_STRING, &host)) | 384 | if (!mu_sieve_get_tag (mach, "host", SVT_STRING, &host)) |
385 | host = "127.0.0.1"; | 385 | host = "127.0.0.1"; |
386 | 386 | ||
387 | if (mu_sieve_tag_lookup (mach, tags, "port", SVT_NUMBER, &num)) | 387 | if (mu_sieve_get_tag (mach, "port", SVT_NUMBER, &num)) |
388 | result = spamd_connect_tcp (mach, &stream, host, num); | 388 | result = spamd_connect_tcp (mach, &stream, host, num); |
389 | else if (mu_sieve_tag_lookup (mach, tags, "socket", SVT_STRING, &str)) | 389 | else if (mu_sieve_get_tag (mach, "socket", SVT_STRING, &str)) |
390 | result = spamd_connect_socket (mach, &stream, str); | 390 | result = spamd_connect_socket (mach, &stream, str); |
391 | else | 391 | else |
392 | result = spamd_connect_tcp (mach, &stream, host, DEFAULT_SPAMD_PORT); | 392 | result = spamd_connect_tcp (mach, &stream, host, DEFAULT_SPAMD_PORT); |
... | @@ -421,7 +421,7 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -421,7 +421,7 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
421 | spamd_send_command (stream, "SYMBOLS SPAMC/1.2"); | 421 | spamd_send_command (stream, "SYMBOLS SPAMC/1.2"); |
422 | 422 | ||
423 | spamd_send_command (stream, "Content-length: %lu", (u_long) size); | 423 | spamd_send_command (stream, "Content-length: %lu", (u_long) size); |
424 | if (mu_sieve_tag_lookup (mach, tags, "user", SVT_STRING, &str)) | 424 | if (mu_sieve_get_tag (mach, "user", SVT_STRING, &str)) |
425 | spamd_send_command (stream, "User: %s", str); | 425 | spamd_send_command (stream, "User: %s", str); |
426 | else | 426 | else |
427 | { | 427 | { |
... | @@ -464,12 +464,12 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -464,12 +464,12 @@ spamd_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
464 | 464 | ||
465 | if (!result) | 465 | if (!result) |
466 | { | 466 | { |
467 | if (mu_sieve_tag_lookup (mach, tags, "over", SVT_STRING, &str)) | 467 | if (mu_sieve_get_tag (mach, "over", SVT_STRING, &str)) |
468 | { | 468 | { |
469 | decode_float (&limit, str, 3, NULL); | 469 | decode_float (&limit, str, 3, NULL); |
470 | result = score >= limit; | 470 | result = score >= limit; |
471 | } | 471 | } |
472 | else if (mu_sieve_tag_lookup (mach, tags, "under", SVT_STRING, &str)) | 472 | else if (mu_sieve_get_tag (mach, "under", SVT_STRING, &str)) |
473 | { | 473 | { |
474 | decode_float (&limit, str, 3, NULL); | 474 | decode_float (&limit, str, 3, NULL); |
475 | result = score <= limit; | 475 | result = score <= limit; | ... | ... |
... | @@ -48,7 +48,7 @@ | ... | @@ -48,7 +48,7 @@ |
48 | 48 | ||
49 | /* Handler for the timestamp test */ | 49 | /* Handler for the timestamp test */ |
50 | static int | 50 | static int |
51 | timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 51 | timestamp_test (mu_sieve_machine_t mach) |
52 | { | 52 | { |
53 | char const *hname; | 53 | char const *hname; |
54 | char const *date; | 54 | char const *date; |
... | @@ -60,9 +60,9 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -60,9 +60,9 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
60 | 60 | ||
61 | /* Retrieve required arguments: */ | 61 | /* Retrieve required arguments: */ |
62 | /* First argument: header name */ | 62 | /* First argument: header name */ |
63 | mu_sieve_value_get (mach, args, 0, SVT_STRING, &hname); | 63 | mu_sieve_get_arg (mach, 0, SVT_STRING, &hname); |
64 | /* Second argument: date displacement */ | 64 | /* Second argument: date displacement */ |
65 | mu_sieve_value_get (mach, args, 1, SVT_STRING, &date); | 65 | mu_sieve_get_arg (mach, 1, SVT_STRING, &date); |
66 | 66 | ||
67 | if (mu_parse_date (date, &tlimit, &now)) | 67 | if (mu_parse_date (date, &tlimit, &now)) |
68 | { | 68 | { |
... | @@ -93,7 +93,7 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -93,7 +93,7 @@ timestamp_test (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
93 | 93 | ||
94 | rc = tval > tlimit; | 94 | rc = tval > tlimit; |
95 | 95 | ||
96 | if (mu_sieve_tag_lookup (mach, tags, "before", SVT_VOID, NULL)) | 96 | if (mu_sieve_get_tag (mach, "before", SVT_VOID, NULL)) |
97 | rc = !rc; | 97 | rc = !rc; |
98 | 98 | ||
99 | return rc; | 99 | return rc; | ... | ... |
... | @@ -51,7 +51,7 @@ | ... | @@ -51,7 +51,7 @@ |
51 | is the message text. | 51 | is the message text. |
52 | */ | 52 | */ |
53 | static int | 53 | static int |
54 | build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime, | 54 | build_mime (mu_sieve_machine_t mach, mu_mime_t *pmime, |
55 | mu_message_t msg, const char *text) | 55 | mu_message_t msg, const char *text) |
56 | { | 56 | { |
57 | mu_mime_t mime = NULL; | 57 | mu_mime_t mime = NULL; |
... | @@ -78,7 +78,7 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime, | ... | @@ -78,7 +78,7 @@ build_mime (mu_sieve_machine_t mach, mu_list_t tags, mu_mime_t *pmime, |
78 | return 1; | 78 | return 1; |
79 | } | 79 | } |
80 | 80 | ||
81 | if (mu_sieve_tag_lookup (mach, tags, "mime", SVT_VOID, NULL)) | 81 | if (mu_sieve_get_tag (mach, "mime", SVT_VOID, NULL)) |
82 | { | 82 | { |
83 | mu_stream_t fstr; | 83 | mu_stream_t fstr; |
84 | rc = mu_filter_create (&fstr, input, "base64", | 84 | rc = mu_filter_create (&fstr, input, "base64", |
... | @@ -227,7 +227,7 @@ regex_comparator (void *item, void *data) | ... | @@ -227,7 +227,7 @@ regex_comparator (void *item, void *data) |
227 | /* Decide whether EMAIL address should not be responded to. | 227 | /* Decide whether EMAIL address should not be responded to. |
228 | */ | 228 | */ |
229 | static int | 229 | static int |
230 | noreply_address_p (mu_sieve_machine_t mach, mu_list_t tags, char *email) | 230 | noreply_address_p (mu_sieve_machine_t mach, char *email) |
231 | { | 231 | { |
232 | int i, rc = 0; | 232 | int i, rc = 0; |
233 | mu_sieve_value_t *arg; | 233 | mu_sieve_value_t *arg; |
... | @@ -249,7 +249,7 @@ noreply_address_p (mu_sieve_machine_t mach, mu_list_t tags, char *email) | ... | @@ -249,7 +249,7 @@ noreply_address_p (mu_sieve_machine_t mach, mu_list_t tags, char *email) |
249 | for (i = 0; rc == 0 && noreply_sender[i]; i++) | 249 | for (i = 0; rc == 0 && noreply_sender[i]; i++) |
250 | rc = regex_comparator (noreply_sender[i], &rd); | 250 | rc = regex_comparator (noreply_sender[i], &rd); |
251 | 251 | ||
252 | if (!rc && mu_sieve_tag_lookup_untyped (mach, tags, "noreply", &arg)) | 252 | if (!rc && mu_sieve_get_tag_untyped (mach, "noreply", &arg)) |
253 | rc = mu_sieve_vlist_do (arg, regex_comparator, &rd); | 253 | rc = mu_sieve_vlist_do (arg, regex_comparator, &rd); |
254 | 254 | ||
255 | return rc; | 255 | return rc; |
... | @@ -337,7 +337,7 @@ test_and_update_prop (mu_property_t prop, const char *from, | ... | @@ -337,7 +337,7 @@ test_and_update_prop (mu_property_t prop, const char *from, |
337 | be answered, 0 if it should not, and throw exception if an error | 337 | be answered, 0 if it should not, and throw exception if an error |
338 | occurs. */ | 338 | occurs. */ |
339 | static int | 339 | static int |
340 | check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from) | 340 | check_db (mu_sieve_machine_t mach, char *from) |
341 | { | 341 | { |
342 | mu_property_t prop; | 342 | mu_property_t prop; |
343 | char *file; | 343 | char *file; |
... | @@ -348,7 +348,7 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from) | ... | @@ -348,7 +348,7 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from) |
348 | const char *dbfile = "~/.vacation"; | 348 | const char *dbfile = "~/.vacation"; |
349 | size_t n; | 349 | size_t n; |
350 | 350 | ||
351 | if (mu_sieve_tag_lookup (mach, tags, "days", SVT_NUMBER, &n)) | 351 | if (mu_sieve_get_tag (mach, "days", SVT_NUMBER, &n)) |
352 | { | 352 | { |
353 | days = n; | 353 | days = n; |
354 | if (days > DAYS_MAX) | 354 | if (days > DAYS_MAX) |
... | @@ -357,7 +357,7 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from) | ... | @@ -357,7 +357,7 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from) |
357 | else | 357 | else |
358 | days = DAYS_DEFAULT; | 358 | days = DAYS_DEFAULT; |
359 | 359 | ||
360 | mu_sieve_tag_lookup (mach, tags, "database", SVT_STRING, &dbfile); | 360 | mu_sieve_get_tag (mach, "database", SVT_STRING, &dbfile); |
361 | 361 | ||
362 | file = mu_tilde_expansion (dbfile, MU_HIERARCHY_DELIMITER, NULL); | 362 | file = mu_tilde_expansion (dbfile, MU_HIERARCHY_DELIMITER, NULL); |
363 | if (!file) | 363 | if (!file) |
... | @@ -429,12 +429,12 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from) | ... | @@ -429,12 +429,12 @@ check_db (mu_sieve_machine_t mach, mu_list_t tags, char *from) |
429 | "reply_prefix" tag. | 429 | "reply_prefix" tag. |
430 | */ | 430 | */ |
431 | static void | 431 | static void |
432 | re_subject (mu_sieve_machine_t mach, mu_list_t tags, char **psubject) | 432 | re_subject (mu_sieve_machine_t mach, char **psubject) |
433 | { | 433 | { |
434 | char *subject; | 434 | char *subject; |
435 | char *prefix = "Re"; | 435 | char *prefix = "Re"; |
436 | 436 | ||
437 | mu_sieve_tag_lookup (mach, tags, "reply_prefix", SVT_STRING, &prefix); | 437 | mu_sieve_get_tag (mach, "reply_prefix", SVT_STRING, &prefix); |
438 | 438 | ||
439 | subject = malloc (strlen (*psubject) + strlen (prefix) + 3); | 439 | subject = malloc (strlen (*psubject) + strlen (prefix) + 3); |
440 | if (!subject) | 440 | if (!subject) |
... | @@ -459,7 +459,7 @@ re_subject (mu_sieve_machine_t mach, mu_list_t tags, char **psubject) | ... | @@ -459,7 +459,7 @@ re_subject (mu_sieve_machine_t mach, mu_list_t tags, char **psubject) |
459 | Otherwise, reply_prefix is prepended to it. */ | 459 | Otherwise, reply_prefix is prepended to it. */ |
460 | 460 | ||
461 | static void | 461 | static void |
462 | vacation_subject (mu_sieve_machine_t mach, mu_list_t tags, | 462 | vacation_subject (mu_sieve_machine_t mach, |
463 | mu_message_t msg, mu_header_t newhdr) | 463 | mu_message_t msg, mu_header_t newhdr) |
464 | { | 464 | { |
465 | char *value; | 465 | char *value; |
... | @@ -467,7 +467,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags, | ... | @@ -467,7 +467,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags, |
467 | int subject_allocated = 0; | 467 | int subject_allocated = 0; |
468 | mu_header_t hdr; | 468 | mu_header_t hdr; |
469 | 469 | ||
470 | if (mu_sieve_tag_lookup (mach, tags, "subject", SVT_STRING, &subject)) | 470 | if (mu_sieve_get_tag (mach, "subject", SVT_STRING, &subject)) |
471 | /* nothing */; | 471 | /* nothing */; |
472 | else if (mu_message_get_header (msg, &hdr) == 0 | 472 | else if (mu_message_get_header (msg, &hdr) == 0 |
473 | && mu_header_aget_value_unfold (hdr, MU_HEADER_SUBJECT, | 473 | && mu_header_aget_value_unfold (hdr, MU_HEADER_SUBJECT, |
... | @@ -488,7 +488,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags, | ... | @@ -488,7 +488,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags, |
488 | subject = p; | 488 | subject = p; |
489 | } | 489 | } |
490 | 490 | ||
491 | if (mu_sieve_tag_lookup (mach, tags, "reply_regex", SVT_STRING, &p)) | 491 | if (mu_sieve_get_tag (mach, "reply_regex", SVT_STRING, &p)) |
492 | { | 492 | { |
493 | char *err = NULL; | 493 | char *err = NULL; |
494 | 494 | ||
... | @@ -504,7 +504,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags, | ... | @@ -504,7 +504,7 @@ vacation_subject (mu_sieve_machine_t mach, mu_list_t tags, |
504 | } | 504 | } |
505 | 505 | ||
506 | if (mu_unre_subject (subject, NULL)) | 506 | if (mu_unre_subject (subject, NULL)) |
507 | re_subject (mach, tags, &subject); | 507 | re_subject (mach, &subject); |
508 | 508 | ||
509 | free (value); | 509 | free (value); |
510 | } | 510 | } |
... | @@ -601,7 +601,7 @@ add_header (void *item, void *data) | ... | @@ -601,7 +601,7 @@ add_header (void *item, void *data) |
601 | 601 | ||
602 | /* Generate and send the reply message */ | 602 | /* Generate and send the reply message */ |
603 | static int | 603 | static int |
604 | vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | 604 | vacation_reply (mu_sieve_machine_t mach, mu_message_t msg, |
605 | char const *text, char const *to, char const *from) | 605 | char const *text, char const *to, char const *from) |
606 | { | 606 | { |
607 | mu_mime_t mime = NULL; | 607 | mu_mime_t mime = NULL; |
... | @@ -613,7 +613,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -613,7 +613,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
613 | int rc; | 613 | int rc; |
614 | mu_sieve_value_t *val; | 614 | mu_sieve_value_t *val; |
615 | 615 | ||
616 | if (mu_sieve_tag_lookup (mach, tags, "file", SVT_VOID, NULL)) | 616 | if (mu_sieve_get_tag (mach, "file", SVT_VOID, NULL)) |
617 | { | 617 | { |
618 | mu_stream_t instr; | 618 | mu_stream_t instr; |
619 | 619 | ||
... | @@ -628,7 +628,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -628,7 +628,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
628 | return -1; | 628 | return -1; |
629 | } | 629 | } |
630 | 630 | ||
631 | if (mu_sieve_tag_lookup (mach, tags, "rfc2822", SVT_VOID, NULL)) | 631 | if (mu_sieve_get_tag (mach, "rfc2822", SVT_VOID, NULL)) |
632 | { | 632 | { |
633 | rc = mu_stream_to_message (instr, &newmsg); | 633 | rc = mu_stream_to_message (instr, &newmsg); |
634 | mu_stream_unref (instr); | 634 | mu_stream_unref (instr); |
... | @@ -684,7 +684,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -684,7 +684,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
684 | return -1; | 684 | return -1; |
685 | } | 685 | } |
686 | 686 | ||
687 | if (build_mime (mach, tags, &mime, msg, (char const *) trans[0])) | 687 | if (build_mime (mach, &mime, msg, (char const *) trans[0])) |
688 | { | 688 | { |
689 | mu_stream_unref (text_stream); | 689 | mu_stream_unref (text_stream); |
690 | return -1; | 690 | return -1; |
... | @@ -696,7 +696,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -696,7 +696,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
696 | } | 696 | } |
697 | else | 697 | else |
698 | { | 698 | { |
699 | if (build_mime (mach, tags, &mime, msg, text)) | 699 | if (build_mime (mach, &mime, msg, text)) |
700 | return -1; | 700 | return -1; |
701 | mu_mime_get_message (mime, &newmsg); | 701 | mu_mime_get_message (mime, &newmsg); |
702 | mu_message_unref (newmsg); | 702 | mu_message_unref (newmsg); |
... | @@ -716,7 +716,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -716,7 +716,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
716 | { | 716 | { |
717 | mu_header_set_value (newhdr, MU_HEADER_TO, to, 0); | 717 | mu_header_set_value (newhdr, MU_HEADER_TO, to, 0); |
718 | 718 | ||
719 | if (mu_sieve_tag_lookup_untyped (mach, tags, "header", &val)) | 719 | if (mu_sieve_get_tag_untyped (mach, "header", &val)) |
720 | { | 720 | { |
721 | struct header_closure hc; | 721 | struct header_closure hc; |
722 | hc.mach = mach; | 722 | hc.mach = mach; |
... | @@ -724,7 +724,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -724,7 +724,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
724 | mu_sieve_vlist_do (val, add_header, &hc); | 724 | mu_sieve_vlist_do (val, add_header, &hc); |
725 | } | 725 | } |
726 | 726 | ||
727 | vacation_subject (mach, tags, msg, newhdr); | 727 | vacation_subject (mach, msg, newhdr); |
728 | 728 | ||
729 | if (from) | 729 | if (from) |
730 | { | 730 | { |
... | @@ -763,7 +763,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, | ... | @@ -763,7 +763,7 @@ vacation_reply (mu_sieve_machine_t mach, mu_list_t tags, mu_message_t msg, |
763 | } | 763 | } |
764 | 764 | ||
765 | int | 765 | int |
766 | sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 766 | sieve_action_vacation (mu_sieve_machine_t mach) |
767 | { | 767 | { |
768 | int rc; | 768 | int rc; |
769 | char *text, *from = NULL; | 769 | char *text, *from = NULL; |
... | @@ -775,12 +775,12 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -775,12 +775,12 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
775 | if (diag (mach)) | 775 | if (diag (mach)) |
776 | return 0; | 776 | return 0; |
777 | 777 | ||
778 | mu_sieve_value_get (mach, args, 0, SVT_STRING, &text); | 778 | mu_sieve_get_arg (mach, 0, SVT_STRING, &text); |
779 | 779 | ||
780 | msg = mu_sieve_get_message (mach); | 780 | msg = mu_sieve_get_message (mach); |
781 | mu_message_get_header (msg, &hdr); | 781 | mu_message_get_header (msg, &hdr); |
782 | 782 | ||
783 | if (mu_sieve_tag_lookup (mach, tags, "sender", SVT_STRING, &from)) | 783 | if (mu_sieve_get_tag (mach, "sender", SVT_STRING, &from)) |
784 | { | 784 | { |
785 | /* Debugging hook: :sender sets fake reply address */ | 785 | /* Debugging hook: :sender sets fake reply address */ |
786 | from = strdup (from); | 786 | from = strdup (from); |
... | @@ -803,12 +803,12 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -803,12 +803,12 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
803 | 803 | ||
804 | my_address = mu_get_user_email (NULL); | 804 | my_address = mu_get_user_email (NULL); |
805 | 805 | ||
806 | if (mu_sieve_tag_lookup (mach, tags, "always_reply", SVT_VOID, NULL)) | 806 | if (mu_sieve_get_tag (mach, "always_reply", SVT_VOID, NULL)) |
807 | return_address = my_address; | 807 | return_address = my_address; |
808 | else | 808 | else |
809 | { | 809 | { |
810 | mu_sieve_value_t *val = NULL; | 810 | mu_sieve_value_t *val = NULL; |
811 | mu_sieve_tag_lookup_untyped (mach, tags, "aliases", &val); | 811 | mu_sieve_get_tag_untyped (mach, "aliases", &val); |
812 | if (match_addresses (hdr, my_address, val, &return_address) == 0) | 812 | if (match_addresses (hdr, my_address, val, &return_address) == 0) |
813 | { | 813 | { |
814 | free (my_address); | 814 | free (my_address); |
... | @@ -816,19 +816,19 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -816,19 +816,19 @@ sieve_action_vacation (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
816 | } | 816 | } |
817 | } | 817 | } |
818 | 818 | ||
819 | if (noreply_address_p (mach, tags, from) | 819 | if (noreply_address_p (mach, from) |
820 | || bulk_precedence_p (hdr) | 820 | || bulk_precedence_p (hdr) |
821 | || check_db (mach, tags, from)) | 821 | || check_db (mach, from)) |
822 | { | 822 | { |
823 | free (from); | 823 | free (from); |
824 | free (my_address); | 824 | free (my_address); |
825 | return 0; | 825 | return 0; |
826 | } | 826 | } |
827 | 827 | ||
828 | mu_sieve_tag_lookup (mach, tags, "return_address", SVT_STRING, | 828 | mu_sieve_get_tag (mach, "return_address", SVT_STRING, |
829 | &return_address); | 829 | &return_address); |
830 | 830 | ||
831 | rc = vacation_reply (mach, tags, msg, text, from, return_address); | 831 | rc = vacation_reply (mach, msg, text, from, return_address); |
832 | free (from); | 832 | free (from); |
833 | free (my_address); | 833 | free (my_address); |
834 | if (rc == -1) | 834 | if (rc == -1) | ... | ... |
... | @@ -81,12 +81,12 @@ mu_sieve_str_to_relcmp (const char *str, | ... | @@ -81,12 +81,12 @@ mu_sieve_str_to_relcmp (const char *str, |
81 | } | 81 | } |
82 | 82 | ||
83 | mu_sieve_relcmp_t | 83 | mu_sieve_relcmp_t |
84 | mu_sieve_get_relcmp (mu_sieve_machine_t mach, mu_list_t tags) | 84 | mu_sieve_get_relcmp (mu_sieve_machine_t mach) |
85 | { | 85 | { |
86 | char *str; | 86 | char *str; |
87 | mu_sieve_relcmp_t test = NULL; | 87 | mu_sieve_relcmp_t test = NULL; |
88 | 88 | ||
89 | if (mu_sieve_tag_lookup (mach, tags, "value", SVT_STRING, &str) == 0) | 89 | if (mu_sieve_get_tag (mach, "value", SVT_STRING, &str) == 0) |
90 | return op_ne; | 90 | return op_ne; |
91 | mu_sieve_str_to_relcmp (str, &test, NULL); | 91 | mu_sieve_str_to_relcmp (str, &test, NULL); |
92 | return test; | 92 | return test; | ... | ... |
... | @@ -30,7 +30,7 @@ | ... | @@ -30,7 +30,7 @@ |
30 | #define INSTR_DISASS(m) ((m)->state == mu_sieve_state_disass) | 30 | #define INSTR_DISASS(m) ((m)->state == mu_sieve_state_disass) |
31 | #define INSTR_DEBUG(m) \ | 31 | #define INSTR_DEBUG(m) \ |
32 | (INSTR_DISASS(m) || mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE9)) | 32 | (INSTR_DISASS(m) || mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE9)) |
33 | 33 | ||
34 | void | 34 | void |
35 | _mu_i_sv_instr_source (mu_sieve_machine_t mach) | 35 | _mu_i_sv_instr_source (mu_sieve_machine_t mach) |
36 | { | 36 | { |
... | @@ -59,39 +59,38 @@ _mu_i_sv_instr_line (mu_sieve_machine_t mach) | ... | @@ -59,39 +59,38 @@ _mu_i_sv_instr_line (mu_sieve_machine_t mach) |
59 | static int | 59 | static int |
60 | instr_run (mu_sieve_machine_t mach, char const *what) | 60 | instr_run (mu_sieve_machine_t mach, char const *what) |
61 | { | 61 | { |
62 | mu_sieve_handler_t han = SIEVE_ARG (mach, 0, handler); | ||
63 | mu_list_t arg_list = SIEVE_ARG (mach, 1, list); | ||
64 | mu_list_t tag_list = SIEVE_ARG (mach, 2, list); | ||
65 | int rc = 0; | 62 | int rc = 0; |
63 | mu_sieve_handler_t han = SIEVE_ARG (mach, 0, handler); | ||
64 | mach->arg_list = SIEVE_ARG (mach, 1, list); | ||
65 | mach->tag_list = SIEVE_ARG (mach, 2, list); | ||
66 | mach->identifier = SIEVE_ARG (mach, 3, string); | ||
66 | 67 | ||
67 | SIEVE_ADJUST(mach, 4); | 68 | SIEVE_ADJUST (mach, 4); |
68 | 69 | ||
69 | if (INSTR_DEBUG (mach)) | 70 | if (INSTR_DEBUG (mach)) |
70 | mu_i_sv_debug_command (mach, mach->pc - 1, | 71 | mu_i_sv_debug_command (mach, mach->pc - 1, what); |
71 | what, tag_list, arg_list); | ||
72 | else | 72 | else |
73 | mu_i_sv_trace (mach, what, tag_list, arg_list); | 73 | mu_i_sv_trace (mach, what); |
74 | 74 | ||
75 | if (!INSTR_DISASS(mach)) | 75 | if (!INSTR_DISASS (mach)) |
76 | rc = han (mach, arg_list, tag_list); | 76 | rc = han (mach); |
77 | mach->arg_list = NULL; | ||
78 | mach->tag_list = NULL; | ||
79 | mach->identifier = NULL; | ||
77 | return rc; | 80 | return rc; |
78 | } | 81 | } |
79 | 82 | ||
80 | void | 83 | void |
81 | _mu_i_sv_instr_action (mu_sieve_machine_t mach) | 84 | _mu_i_sv_instr_action (mu_sieve_machine_t mach) |
82 | { | 85 | { |
83 | mach->identifier = SIEVE_ARG (mach, 3, string); | ||
84 | mach->action_count++; | 86 | mach->action_count++; |
85 | instr_run (mach, "ACTION"); | 87 | instr_run (mach, "ACTION"); |
86 | mach->identifier = NULL; | ||
87 | } | 88 | } |
88 | 89 | ||
89 | void | 90 | void |
90 | _mu_i_sv_instr_test (mu_sieve_machine_t mach) | 91 | _mu_i_sv_instr_test (mu_sieve_machine_t mach) |
91 | { | 92 | { |
92 | mach->identifier = SIEVE_ARG (mach, 3, string); | ||
93 | mach->reg = instr_run (mach, "TEST"); | 93 | mach->reg = instr_run (mach, "TEST"); |
94 | mach->identifier = NULL; | ||
95 | } | 94 | } |
96 | 95 | ||
97 | void | 96 | void | ... | ... |
... | @@ -83,9 +83,13 @@ struct mu_sieve_machine | ... | @@ -83,9 +83,13 @@ struct mu_sieve_machine |
83 | long reg; /* Numeric register */ | 83 | long reg; /* Numeric register */ |
84 | mu_list_t stack; /* Runtime stack */ | 84 | mu_list_t stack; /* Runtime stack */ |
85 | 85 | ||
86 | /* Call environment */ | ||
87 | const char *identifier; /* Name of action or test being executed */ | ||
88 | mu_list_t arg_list; /* Positional arguments */ | ||
89 | mu_list_t tag_list; /* Tagged arguments */ | ||
90 | |||
86 | int dry_run; /* Dry-run mode */ | 91 | int dry_run; /* Dry-run mode */ |
87 | jmp_buf errbuf; /* Target location for non-local exits */ | 92 | jmp_buf errbuf; /* Target location for non-local exits */ |
88 | const char *identifier; /* Name of action or test being executed */ | ||
89 | 93 | ||
90 | mu_mailbox_t mailbox; /* Mailbox to operate upon */ | 94 | mu_mailbox_t mailbox; /* Mailbox to operate upon */ |
91 | size_t msgno; /* Current message number */ | 95 | size_t msgno; /* Current message number */ |
... | @@ -195,12 +199,9 @@ void mu_i_sv_error (mu_sieve_machine_t mach); | ... | @@ -195,12 +199,9 @@ void mu_i_sv_error (mu_sieve_machine_t mach); |
195 | 199 | ||
196 | void mu_i_sv_debug (mu_sieve_machine_t mach, size_t pc, const char *fmt, ...) | 200 | void mu_i_sv_debug (mu_sieve_machine_t mach, size_t pc, const char *fmt, ...) |
197 | MU_PRINTFLIKE(3,4); | 201 | MU_PRINTFLIKE(3,4); |
198 | void mu_i_sv_debug_command (mu_sieve_machine_t mach, | 202 | void mu_i_sv_debug_command (mu_sieve_machine_t mach, size_t pc, |
199 | size_t pc, | 203 | char const *what); |
200 | char const *what, | 204 | void mu_i_sv_trace (mu_sieve_machine_t mach, const char *what); |
201 | mu_list_t taglist, mu_list_t arglist); | ||
202 | void mu_i_sv_trace (mu_sieve_machine_t mach, const char *what, | ||
203 | mu_list_t taglist, mu_list_t arglist); | ||
204 | 205 | ||
205 | void mu_i_sv_argf (mu_stream_t str, mu_list_t list); | 206 | void mu_i_sv_argf (mu_stream_t str, mu_list_t list); |
206 | void mu_i_sv_valf (mu_stream_t str, mu_sieve_value_t *val); | 207 | void mu_i_sv_valf (mu_stream_t str, mu_sieve_value_t *val); | ... | ... |
... | @@ -64,19 +64,18 @@ struct address_closure | ... | @@ -64,19 +64,18 @@ struct address_closure |
64 | }; | 64 | }; |
65 | 65 | ||
66 | static int | 66 | static int |
67 | do_count (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags, | 67 | do_count (mu_sieve_machine_t mach, size_t count, int retval) |
68 | size_t count, int retval) | ||
69 | { | 68 | { |
70 | char *relcmp; | 69 | char *relcmp; |
71 | 70 | ||
72 | if (mu_sieve_tag_lookup (mach, tags, "count", SVT_STRING, &relcmp)) | 71 | if (mu_sieve_get_tag (mach, "count", SVT_STRING, &relcmp)) |
73 | { | 72 | { |
74 | size_t limit; | 73 | size_t limit; |
75 | char *str; | 74 | char *str; |
76 | mu_list_t list; | 75 | mu_list_t list; |
77 | mu_sieve_relcmpn_t stest; | 76 | mu_sieve_relcmpn_t stest; |
78 | 77 | ||
79 | mu_sieve_value_get (mach, args, 1, SVT_STRING_LIST, &list); | 78 | mu_sieve_get_arg (mach, 1, SVT_STRING_LIST, &list); |
80 | mu_list_get (list, 0, (void **) &str); | 79 | mu_list_get (list, 0, (void **) &str); |
81 | limit = strtoul (str, &str, 10); | 80 | limit = strtoul (str, &str, 10); |
82 | 81 | ||
... | @@ -110,27 +109,28 @@ retrieve_address (void *item, void *data, int idx, char **pval) | ... | @@ -110,27 +109,28 @@ retrieve_address (void *item, void *data, int idx, char **pval) |
110 | } | 109 | } |
111 | 110 | ||
112 | int | 111 | int |
113 | sieve_test_address (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 112 | sieve_test_address (mu_sieve_machine_t mach) |
114 | { | 113 | { |
115 | mu_sieve_value_t *h, *v; | 114 | mu_sieve_value_t *h, *v; |
116 | mu_header_t header = NULL; | 115 | mu_header_t header = NULL; |
117 | mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags); | 116 | mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach); |
118 | mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach, tags); | 117 | mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach); |
119 | struct address_closure clos; | 118 | struct address_closure clos; |
120 | int rc; | 119 | int rc; |
121 | size_t count; | 120 | size_t count; |
122 | 121 | ||
123 | h = mu_sieve_value_get_untyped (mach, args, 0); | 122 | h = mu_sieve_get_arg_untyped (mach, 0); |
124 | v = mu_sieve_value_get_untyped (mach, args, 1); | 123 | v = mu_sieve_get_arg_untyped (mach, 1); |
125 | 124 | ||
126 | mu_message_get_header (mu_sieve_get_message (mach), &header); | 125 | mu_message_get_header (mu_sieve_get_message (mach), &header); |
127 | clos.data = header; | 126 | clos.data = header; |
128 | clos.aget = sieve_get_address_part (tags); | 127 | clos.aget = sieve_get_address_part (mach->tag_list); |
129 | clos.addr = NULL; | 128 | clos.addr = NULL; |
130 | rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_address, &clos, &count); | 129 | rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_address, &clos, |
130 | &count); | ||
131 | mu_address_destroy (&clos.addr); | 131 | mu_address_destroy (&clos.addr); |
132 | 132 | ||
133 | return do_count (mach, args, tags, count, rc); | 133 | return do_count (mach, count, rc); |
134 | } | 134 | } |
135 | 135 | ||
136 | struct header_closure | 136 | struct header_closure |
... | @@ -164,18 +164,18 @@ retrieve_header (void *item, void *data, int idx, char **pval) | ... | @@ -164,18 +164,18 @@ retrieve_header (void *item, void *data, int idx, char **pval) |
164 | } | 164 | } |
165 | 165 | ||
166 | int | 166 | int |
167 | sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 167 | sieve_test_header (mu_sieve_machine_t mach) |
168 | { | 168 | { |
169 | mu_sieve_value_t *h, *v; | 169 | mu_sieve_value_t *h, *v; |
170 | mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags); | 170 | mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach); |
171 | mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach, tags); | 171 | mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach); |
172 | size_t count, mcount = 0; | 172 | size_t count, mcount = 0; |
173 | struct header_closure clos; | 173 | struct header_closure clos; |
174 | 174 | ||
175 | h = mu_sieve_value_get_untyped (mach, args, 0); | 175 | h = mu_sieve_get_arg_untyped (mach, 0); |
176 | v = mu_sieve_value_get_untyped (mach, args, 1); | 176 | v = mu_sieve_get_arg_untyped (mach, 1); |
177 | 177 | ||
178 | if (mu_sieve_tag_lookup (mach, tags, "mime", SVT_VOID, NULL)) | 178 | if (mu_sieve_get_tag (mach, "mime", SVT_VOID, NULL)) |
179 | { | 179 | { |
180 | int ismime = 0; | 180 | int ismime = 0; |
181 | 181 | ||
... | @@ -204,7 +204,7 @@ sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | ... | @@ -204,7 +204,7 @@ sieve_test_header (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) |
204 | &count)) | 204 | &count)) |
205 | return 1; | 205 | return 1; |
206 | 206 | ||
207 | return do_count (mach, args, tags, count + mcount, 0); | 207 | return do_count (mach, count + mcount, 0); |
208 | } | 208 | } |
209 | 209 | ||
210 | int | 210 | int |
... | @@ -235,39 +235,39 @@ retrieve_envelope (void *item, void *data, int idx, char **pval) | ... | @@ -235,39 +235,39 @@ retrieve_envelope (void *item, void *data, int idx, char **pval) |
235 | } | 235 | } |
236 | 236 | ||
237 | int | 237 | int |
238 | sieve_test_envelope (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 238 | sieve_test_envelope (mu_sieve_machine_t mach) |
239 | { | 239 | { |
240 | mu_sieve_value_t *h, *v; | 240 | mu_sieve_value_t *h, *v; |
241 | mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach, tags); | 241 | mu_sieve_comparator_t comp = mu_sieve_get_comparator (mach); |
242 | mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach, tags); | 242 | mu_sieve_relcmp_t test = mu_sieve_get_relcmp (mach); |
243 | struct address_closure clos; | 243 | struct address_closure clos; |
244 | int rc; | 244 | int rc; |
245 | size_t count; | 245 | size_t count; |
246 | 246 | ||
247 | h = mu_sieve_value_get_untyped (mach, args, 0); | 247 | h = mu_sieve_get_arg_untyped (mach, 0); |
248 | v = mu_sieve_value_get_untyped (mach, args, 1); | 248 | v = mu_sieve_get_arg_untyped (mach, 1); |
249 | 249 | ||
250 | mu_message_get_envelope (mu_sieve_get_message (mach), | 250 | mu_message_get_envelope (mu_sieve_get_message (mach), |
251 | (mu_envelope_t*)&clos.data); | 251 | (mu_envelope_t*)&clos.data); |
252 | clos.aget = sieve_get_address_part (tags); | 252 | clos.aget = sieve_get_address_part (mach->tag_list); |
253 | clos.addr = NULL; | 253 | clos.addr = NULL; |
254 | rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_envelope, &clos, | 254 | rc = mu_sieve_vlist_compare (h, v, comp, test, retrieve_envelope, &clos, |
255 | &count); | 255 | &count); |
256 | mu_address_destroy (&clos.addr); | 256 | mu_address_destroy (&clos.addr); |
257 | return do_count (mach, args, tags, count, rc); | 257 | return do_count (mach, count, rc); |
258 | } | 258 | } |
259 | 259 | ||
260 | int | 260 | int |
261 | sieve_test_size (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 261 | sieve_test_size (mu_sieve_machine_t mach) |
262 | { | 262 | { |
263 | int rc = 1; | 263 | int rc = 1; |
264 | mu_sieve_runtime_tag_t *tag = NULL; | 264 | mu_sieve_runtime_tag_t *tag = NULL; |
265 | size_t size; | 265 | size_t size; |
266 | size_t arg; | 266 | size_t arg; |
267 | 267 | ||
268 | mu_sieve_value_get (mach, args, 0, SVT_NUMBER, &arg); | 268 | mu_sieve_get_arg (mach, 0, SVT_NUMBER, &arg); |
269 | mu_message_size (mu_sieve_get_message (mach), &size); | 269 | mu_message_size (mu_sieve_get_message (mach), &size); |
270 | mu_list_get (tags, 0, (void **)&tag); | 270 | mu_list_get (mach->tag_list, 0, (void **)&tag); |
271 | if (!tag) | 271 | if (!tag) |
272 | rc = size == arg; | 272 | rc = size == arg; |
273 | else if (strcmp (tag->tag, "over") == 0) | 273 | else if (strcmp (tag->tag, "over") == 0) |
... | @@ -288,13 +288,13 @@ _test_exists (void *item, void *data) | ... | @@ -288,13 +288,13 @@ _test_exists (void *item, void *data) |
288 | } | 288 | } |
289 | 289 | ||
290 | int | 290 | int |
291 | sieve_test_exists (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags) | 291 | sieve_test_exists (mu_sieve_machine_t mach) |
292 | { | 292 | { |
293 | mu_header_t header = NULL; | 293 | mu_header_t header = NULL; |
294 | mu_sieve_value_t *val; | 294 | mu_sieve_value_t *val; |
295 | 295 | ||
296 | mu_message_get_header (mu_sieve_get_message (mach), &header); | 296 | mu_message_get_header (mu_sieve_get_message (mach), &header); |
297 | val = mu_sieve_value_get_untyped (mach, args, 0); | 297 | val = mu_sieve_get_arg_untyped (mach, 0); |
298 | return mu_sieve_vlist_do (val, _test_exists, header) == 0; | 298 | return mu_sieve_vlist_do (val, _test_exists, header) == 0; |
299 | } | 299 | } |
300 | 300 | ... | ... |
... | @@ -177,11 +177,10 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data) | ... | @@ -177,11 +177,10 @@ mu_sieve_value_create (mu_sieve_data_type type, void *data) |
177 | } | 177 | } |
178 | 178 | ||
179 | mu_sieve_value_t * | 179 | mu_sieve_value_t * |
180 | mu_sieve_value_get_untyped (mu_sieve_machine_t mach, mu_list_t vlist, | 180 | mu_sieve_get_arg_untyped (mu_sieve_machine_t mach, size_t index) |
181 | size_t index) | ||
182 | { | 181 | { |
183 | mu_sieve_value_t *val = NULL; | 182 | mu_sieve_value_t *val = NULL; |
184 | int rc = mu_list_get (vlist, index, (void **)&val); | 183 | int rc = mu_list_get (mach->arg_list, index, (void **)&val); |
185 | if (rc) | 184 | if (rc) |
186 | { | 185 | { |
187 | mu_sieve_error (mach, _("can't get argument %zu: %s"), | 186 | mu_sieve_error (mach, _("can't get argument %zu: %s"), |
... | @@ -192,11 +191,10 @@ mu_sieve_value_get_untyped (mu_sieve_machine_t mach, mu_list_t vlist, | ... | @@ -192,11 +191,10 @@ mu_sieve_value_get_untyped (mu_sieve_machine_t mach, mu_list_t vlist, |
192 | } | 191 | } |
193 | 192 | ||
194 | mu_sieve_value_t * | 193 | mu_sieve_value_t * |
195 | mu_sieve_value_get_optional (mu_sieve_machine_t mach, mu_list_t vlist, | 194 | mu_sieve_get_arg_optional (mu_sieve_machine_t mach, size_t index) |
196 | size_t index) | ||
197 | { | 195 | { |
198 | mu_sieve_value_t *val = NULL; | 196 | mu_sieve_value_t *val = NULL; |
199 | int rc = mu_list_get (vlist, index, (void **)&val); | 197 | int rc = mu_list_get (mach->arg_list, index, (void **)&val); |
200 | if (rc == MU_ERR_NOENT) | 198 | if (rc == MU_ERR_NOENT) |
201 | return NULL; | 199 | return NULL; |
202 | else if (rc) | 200 | else if (rc) |
... | @@ -209,11 +207,10 @@ mu_sieve_value_get_optional (mu_sieve_machine_t mach, mu_list_t vlist, | ... | @@ -209,11 +207,10 @@ mu_sieve_value_get_optional (mu_sieve_machine_t mach, mu_list_t vlist, |
209 | } | 207 | } |
210 | 208 | ||
211 | int | 209 | int |
212 | mu_sieve_value_get (mu_sieve_machine_t mach, mu_list_t vlist, | 210 | mu_sieve_get_arg (mu_sieve_machine_t mach, size_t index, |
213 | size_t index, | 211 | mu_sieve_data_type type, void *ret) |
214 | mu_sieve_data_type type, void *ret) | ||
215 | { | 212 | { |
216 | mu_sieve_value_t *val = mu_sieve_value_get_untyped (mach, vlist, index); | 213 | mu_sieve_value_t *val = mu_sieve_get_arg_untyped (mach, index); |
217 | if (val->type != type) | 214 | if (val->type != type) |
218 | { | 215 | { |
219 | mu_sieve_error (mach, | 216 | mu_sieve_error (mach, |
... | @@ -325,8 +322,7 @@ mu_i_sv_debug (mu_sieve_machine_t mach, size_t pc, const char *fmt, ...) | ... | @@ -325,8 +322,7 @@ mu_i_sv_debug (mu_sieve_machine_t mach, size_t pc, const char *fmt, ...) |
325 | void | 322 | void |
326 | mu_i_sv_debug_command (mu_sieve_machine_t mach, | 323 | mu_i_sv_debug_command (mu_sieve_machine_t mach, |
327 | size_t pc, | 324 | size_t pc, |
328 | char const *what, | 325 | char const *what) |
329 | mu_list_t taglist, mu_list_t arglist) | ||
330 | { | 326 | { |
331 | if (mach->state_flags & MU_SV_SAVED_DBG_STATE) | 327 | if (mach->state_flags & MU_SV_SAVED_DBG_STATE) |
332 | { | 328 | { |
... | @@ -344,14 +340,13 @@ mu_i_sv_debug_command (mu_sieve_machine_t mach, | ... | @@ -344,14 +340,13 @@ mu_i_sv_debug_command (mu_sieve_machine_t mach, |
344 | } | 340 | } |
345 | mu_stream_printf (mach->dbgstream, "%4zu: %s: %s", | 341 | mu_stream_printf (mach->dbgstream, "%4zu: %s: %s", |
346 | pc, what, mach->identifier); | 342 | pc, what, mach->identifier); |
347 | mu_i_sv_tagf (mach->dbgstream, taglist); | 343 | mu_i_sv_tagf (mach->dbgstream, mach->tag_list); |
348 | mu_i_sv_argf (mach->dbgstream, arglist); | 344 | mu_i_sv_argf (mach->dbgstream, mach->arg_list); |
349 | mu_stream_write (mach->dbgstream, "\n", 1, NULL); | 345 | mu_stream_write (mach->dbgstream, "\n", 1, NULL); |
350 | } | 346 | } |
351 | 347 | ||
352 | void | 348 | void |
353 | mu_i_sv_trace (mu_sieve_machine_t mach, const char *what, | 349 | mu_i_sv_trace (mu_sieve_machine_t mach, const char *what) |
354 | mu_list_t taglist, mu_list_t arglist) | ||
355 | { | 350 | { |
356 | if (!mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE4)) | 351 | if (!mu_debug_level_p (mu_sieve_debug_handle, MU_DEBUG_TRACE4)) |
357 | return; | 352 | return; |
... | @@ -365,8 +360,8 @@ mu_i_sv_trace (mu_sieve_machine_t mach, const char *what, | ... | @@ -365,8 +360,8 @@ mu_i_sv_trace (mu_sieve_machine_t mach, const char *what, |
365 | mach->locus.mu_line); | 360 | mach->locus.mu_line); |
366 | mu_stream_printf (mach->errstream, "%zu: %s %s", mach->msgno, what, | 361 | mu_stream_printf (mach->errstream, "%zu: %s %s", mach->msgno, what, |
367 | mach->identifier); | 362 | mach->identifier); |
368 | mu_i_sv_tagf (mach->errstream, taglist); | 363 | mu_i_sv_tagf (mach->errstream, mach->tag_list); |
369 | mu_i_sv_argf (mach->errstream, arglist); | 364 | mu_i_sv_argf (mach->errstream, mach->arg_list); |
370 | mu_stream_printf (mach->errstream, "\n"); | 365 | mu_stream_printf (mach->errstream, "\n"); |
371 | } | 366 | } |
372 | 367 | ||
... | @@ -401,13 +396,13 @@ tag_finder (void *item, void *data) | ... | @@ -401,13 +396,13 @@ tag_finder (void *item, void *data) |
401 | } | 396 | } |
402 | 397 | ||
403 | int | 398 | int |
404 | mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist, | 399 | mu_sieve_get_tag_untyped (mu_sieve_machine_t mach, |
405 | char *name, mu_sieve_value_t **ret) | 400 | char *name, mu_sieve_value_t **ret) |
406 | { | 401 | { |
407 | mu_sieve_runtime_tag_t t; | 402 | mu_sieve_runtime_tag_t t; |
408 | 403 | ||
409 | t.tag = name; | 404 | t.tag = name; |
410 | if (taglist && mu_list_foreach (taglist, tag_finder, &t)) | 405 | if (mach->tag_list && mu_list_foreach (mach->tag_list, tag_finder, &t)) |
411 | { | 406 | { |
412 | if (ret) | 407 | if (ret) |
413 | *ret = t.arg; | 408 | *ret = t.arg; |
... | @@ -417,12 +412,12 @@ mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist, | ... | @@ -417,12 +412,12 @@ mu_sieve_tag_lookup_untyped (mu_sieve_machine_t mach, mu_list_t taglist, |
417 | } | 412 | } |
418 | 413 | ||
419 | int | 414 | int |
420 | mu_sieve_tag_lookup (mu_sieve_machine_t mach, mu_list_t taglist, | 415 | mu_sieve_get_tag (mu_sieve_machine_t mach, |
421 | char *name, mu_sieve_data_type type, | 416 | char *name, mu_sieve_data_type type, |
422 | void *ret) | 417 | void *ret) |
423 | { | 418 | { |
424 | mu_sieve_value_t *val; | 419 | mu_sieve_value_t *val; |
425 | int found = mu_sieve_tag_lookup_untyped (mach, taglist, name, &val); | 420 | int found = mu_sieve_get_tag_untyped (mach, name, &val); |
426 | 421 | ||
427 | if (found) | 422 | if (found) |
428 | { | 423 | { | ... | ... |
-
Please register or sign in to post a comment