(sieve_register_comparator)
(sieve_require_comparator,sieve_comparator_lookup) (sieve_get_comparator) (sieve_register_standard_comparators): Accept the pointer to sieve machine as first argument.
Showing
1 changed file
with
23 additions
and
21 deletions
... | @@ -33,11 +33,9 @@ typedef struct { | ... | @@ -33,11 +33,9 @@ typedef struct { |
33 | sieve_comparator_t comp[MU_SIEVE_MATCH_LAST]; | 33 | sieve_comparator_t comp[MU_SIEVE_MATCH_LAST]; |
34 | } sieve_comparator_record_t; | 34 | } sieve_comparator_record_t; |
35 | 35 | ||
36 | |||
37 | static list_t comparator_list; | ||
38 | |||
39 | int | 36 | int |
40 | sieve_register_comparator (const char *name, | 37 | sieve_register_comparator (sieve_machine_t mach, |
38 | const char *name, | ||
41 | int required, | 39 | int required, |
42 | sieve_comparator_t is, sieve_comparator_t contains, | 40 | sieve_comparator_t is, sieve_comparator_t contains, |
43 | sieve_comparator_t matches, | 41 | sieve_comparator_t matches, |
... | @@ -45,14 +43,14 @@ sieve_register_comparator (const char *name, | ... | @@ -45,14 +43,14 @@ sieve_register_comparator (const char *name, |
45 | { | 43 | { |
46 | sieve_comparator_record_t *rp; | 44 | sieve_comparator_record_t *rp; |
47 | 45 | ||
48 | if (!comparator_list) | 46 | if (!mach->comp_list) |
49 | { | 47 | { |
50 | int rc = list_create (&comparator_list); | 48 | int rc = list_create (&mach->comp_list); |
51 | if (rc) | 49 | if (rc) |
52 | return rc; | 50 | return rc; |
53 | } | 51 | } |
54 | 52 | ||
55 | rp = sieve_palloc (&sieve_machine->memory_pool, sizeof (*rp)); | 53 | rp = sieve_palloc (&mach->memory_pool, sizeof (*rp)); |
56 | rp->required = required; | 54 | rp->required = required; |
57 | rp->name = name; | 55 | rp->name = name; |
58 | rp->comp[MU_SIEVE_MATCH_IS] = is; | 56 | rp->comp[MU_SIEVE_MATCH_IS] = is; |
... | @@ -60,16 +58,16 @@ sieve_register_comparator (const char *name, | ... | @@ -60,16 +58,16 @@ sieve_register_comparator (const char *name, |
60 | rp->comp[MU_SIEVE_MATCH_MATCHES] = matches; | 58 | rp->comp[MU_SIEVE_MATCH_MATCHES] = matches; |
61 | rp->comp[MU_SIEVE_MATCH_REGEX] = regex; | 59 | rp->comp[MU_SIEVE_MATCH_REGEX] = regex; |
62 | 60 | ||
63 | return list_append (comparator_list, rp); | 61 | return list_append (mach->comp_list, rp); |
64 | } | 62 | } |
65 | 63 | ||
66 | sieve_comparator_record_t * | 64 | sieve_comparator_record_t * |
67 | _lookup (const char *name) | 65 | _lookup (list_t list, const char *name) |
68 | { | 66 | { |
69 | iterator_t itr; | 67 | iterator_t itr; |
70 | sieve_comparator_record_t *reg; | 68 | sieve_comparator_record_t *reg; |
71 | 69 | ||
72 | if (!comparator_list || iterator_create (&itr, comparator_list)) | 70 | if (!list || iterator_create (&itr, list)) |
73 | return NULL; | 71 | return NULL; |
74 | 72 | ||
75 | for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr)) | 73 | for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr)) |
... | @@ -85,9 +83,9 @@ _lookup (const char *name) | ... | @@ -85,9 +83,9 @@ _lookup (const char *name) |
85 | } | 83 | } |
86 | 84 | ||
87 | int | 85 | int |
88 | sieve_require_comparator (const char *name) | 86 | sieve_require_comparator (sieve_machine_t mach, const char *name) |
89 | { | 87 | { |
90 | sieve_comparator_record_t *reg = _lookup (name); | 88 | sieve_comparator_record_t *reg = _lookup (mach->comp_list, name); |
91 | if (!reg) | 89 | if (!reg) |
92 | return 1; | 90 | return 1; |
93 | reg->required = 1; | 91 | reg->required = 1; |
... | @@ -95,9 +93,9 @@ sieve_require_comparator (const char *name) | ... | @@ -95,9 +93,9 @@ sieve_require_comparator (const char *name) |
95 | } | 93 | } |
96 | 94 | ||
97 | sieve_comparator_t | 95 | sieve_comparator_t |
98 | sieve_comparator_lookup (const char *name, int matchtype) | 96 | sieve_comparator_lookup (sieve_machine_t mach, const char *name, int matchtype) |
99 | { | 97 | { |
100 | sieve_comparator_record_t *reg = _lookup (name); | 98 | sieve_comparator_record_t *reg = _lookup (mach->comp_list, name); |
101 | if (reg && reg->comp[matchtype]) | 99 | if (reg && reg->comp[matchtype]) |
102 | return reg->comp[matchtype]; | 100 | return reg->comp[matchtype]; |
103 | return NULL; | 101 | return NULL; |
... | @@ -117,12 +115,13 @@ _find_comparator (void *item, void *data) | ... | @@ -117,12 +115,13 @@ _find_comparator (void *item, void *data) |
117 | } | 115 | } |
118 | 116 | ||
119 | sieve_comparator_t | 117 | sieve_comparator_t |
120 | sieve_get_comparator (list_t tags) | 118 | sieve_get_comparator (sieve_machine_t mach, list_t tags) |
121 | { | 119 | { |
122 | sieve_comparator_t comp = NULL; | 120 | sieve_comparator_t comp = NULL; |
123 | 121 | ||
124 | list_do (tags, _find_comparator, &comp); | 122 | list_do (tags, _find_comparator, &comp); |
125 | return comp ? comp : sieve_comparator_lookup ("i;ascii-casemap", | 123 | return comp ? comp : sieve_comparator_lookup (mach, |
124 | "i;ascii-casemap", | ||
126 | MU_SIEVE_MATCH_IS); | 125 | MU_SIEVE_MATCH_IS); |
127 | } | 126 | } |
128 | 127 | ||
... | @@ -248,7 +247,7 @@ sieve_match_part_checker (const char *name, list_t tags, list_t args) | ... | @@ -248,7 +247,7 @@ sieve_match_part_checker (const char *name, list_t tags, list_t args) |
248 | list_remove (tags, match); | 247 | list_remove (tags, match); |
249 | 248 | ||
250 | compname = comp ? comp->arg->v.string : "i;ascii-casemap"; | 249 | compname = comp ? comp->arg->v.string : "i;ascii-casemap"; |
251 | compfun = sieve_comparator_lookup (compname, matchtype); | 250 | compfun = sieve_comparator_lookup (sieve_machine, compname, matchtype); |
252 | if (!compfun) | 251 | if (!compfun) |
253 | { | 252 | { |
254 | sieve_compile_error (sieve_filename, sieve_line_num, | 253 | sieve_compile_error (sieve_filename, sieve_line_num, |
... | @@ -468,21 +467,24 @@ i_ascii_numeric_is (const char *pattern, const char *text) | ... | @@ -468,21 +467,24 @@ i_ascii_numeric_is (const char *pattern, const char *text) |
468 | } | 467 | } |
469 | 468 | ||
470 | void | 469 | void |
471 | sieve_register_standard_comparators () | 470 | sieve_register_standard_comparators (sieve_machine_t mach) |
472 | { | 471 | { |
473 | sieve_register_comparator ("i;octet", | 472 | sieve_register_comparator (mach, |
473 | "i;octet", | ||
474 | 1, | 474 | 1, |
475 | i_octet_is, | 475 | i_octet_is, |
476 | i_octet_contains, | 476 | i_octet_contains, |
477 | i_octet_matches, | 477 | i_octet_matches, |
478 | i_octet_regex); | 478 | i_octet_regex); |
479 | sieve_register_comparator ("i;ascii-casemap", | 479 | sieve_register_comparator (mach, |
480 | "i;ascii-casemap", | ||
480 | 1, | 481 | 1, |
481 | i_ascii_casemap_is, | 482 | i_ascii_casemap_is, |
482 | i_ascii_casemap_contains, | 483 | i_ascii_casemap_contains, |
483 | i_ascii_casemap_matches, | 484 | i_ascii_casemap_matches, |
484 | i_ascii_casemap_regex); | 485 | i_ascii_casemap_regex); |
485 | sieve_register_comparator ("i;ascii-numeric", | 486 | sieve_register_comparator (mach, |
487 | "i;ascii-numeric", | ||
486 | 0, | 488 | 0, |
487 | i_ascii_numeric_is, | 489 | i_ascii_numeric_is, |
488 | NULL, | 490 | NULL, | ... | ... |
-
Please register or sign in to post a comment