Implemented header test.
Showing
1 changed file
with
30 additions
and
13 deletions
... | @@ -25,17 +25,6 @@ | ... | @@ -25,17 +25,6 @@ |
25 | #include <string.h> | 25 | #include <string.h> |
26 | #include <sieve.h> | 26 | #include <sieve.h> |
27 | 27 | ||
28 | #define TAG_LOCALPART 0 | ||
29 | #define TAG_DOMAIN 1 | ||
30 | #define TAG_ALL 2 | ||
31 | #define TAG_COMPARATOR 3 | ||
32 | #define TAG_IS 4 | ||
33 | #define TAG_CONTAINS 5 | ||
34 | #define TAG_MATCHES 6 | ||
35 | #define TAG_REGEX 7 | ||
36 | #define TAG_UNDER 8 | ||
37 | #define TAG_OVER 9 | ||
38 | |||
39 | int | 28 | int |
40 | sieve_test_address (sieve_machine_t mach, list_t args, list_t tags) | 29 | sieve_test_address (sieve_machine_t mach, list_t args, list_t tags) |
41 | { | 30 | { |
... | @@ -43,9 +32,37 @@ sieve_test_address (sieve_machine_t mach, list_t args, list_t tags) | ... | @@ -43,9 +32,37 @@ sieve_test_address (sieve_machine_t mach, list_t args, list_t tags) |
43 | } | 32 | } |
44 | 33 | ||
45 | int | 34 | int |
35 | retrieve_header (void *item, void *data, char **pval) | ||
36 | { | ||
37 | return header_aget_value ((header_t) data, (char*)item, pval); | ||
38 | } | ||
39 | |||
40 | int | ||
46 | sieve_test_header (sieve_machine_t mach, list_t args, list_t tags) | 41 | sieve_test_header (sieve_machine_t mach, list_t args, list_t tags) |
47 | { | 42 | { |
48 | return 0; | 43 | sieve_value_t *h, *v; |
44 | header_t header = NULL; | ||
45 | sieve_comparator_t comp = sieve_get_comparator (tags); | ||
46 | |||
47 | if (mach->debug_level & MU_SIEVE_DEBUG_TRACE) | ||
48 | sieve_debug (mach, "HEADER\n"); | ||
49 | |||
50 | h = sieve_value_get (args, 0); | ||
51 | if (!h) | ||
52 | { | ||
53 | sieve_error (mach, "header: can't get argument 1"); | ||
54 | sieve_abort (mach); | ||
55 | } | ||
56 | v = sieve_value_get (args, 1); | ||
57 | if (!v) | ||
58 | { | ||
59 | sieve_error (mach, "header: can't get argument 2"); | ||
60 | sieve_abort (mach); | ||
61 | } | ||
62 | |||
63 | message_get_header (sieve_get_message (mach), &header); | ||
64 | |||
65 | return sieve_vlist_compare (h, v, comp, retrieve_header, header); | ||
49 | } | 66 | } |
50 | 67 | ||
51 | int | 68 | int |
... | @@ -122,7 +139,7 @@ sieve_test_exists (sieve_machine_t mach, list_t args, list_t tags) | ... | @@ -122,7 +139,7 @@ sieve_test_exists (sieve_machine_t mach, list_t args, list_t tags) |
122 | sieve_abort (mach); | 139 | sieve_abort (mach); |
123 | } | 140 | } |
124 | 141 | ||
125 | return list_do (val->v.list, _test_exists, header) == 0; | 142 | return sieve_vlist_do (val, _test_exists, header) == 0; |
126 | } | 143 | } |
127 | 144 | ||
128 | #define ADDRESS_PART \ | 145 | #define ADDRESS_PART \ | ... | ... |
-
Please register or sign in to post a comment