(sieve_require_action, sieve_require_test): New functions.
Showing
2 changed files
with
38 additions
and
4 deletions
... | @@ -26,6 +26,9 @@ | ... | @@ -26,6 +26,9 @@ |
26 | extern "C" { | 26 | extern "C" { |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | #define __s_cat3__(a,b,c) a ## b ## c | ||
30 | #define SIEVE_EXPORT(module,name) __s_cat3__(module,_LTX_,name) | ||
31 | |||
29 | typedef struct sieve_machine *sieve_machine_t; | 32 | typedef struct sieve_machine *sieve_machine_t; |
30 | 33 | ||
31 | typedef int (*sieve_handler_t) __PMT((sieve_machine_t mach, | 34 | typedef int (*sieve_handler_t) __PMT((sieve_machine_t mach, |
... | @@ -137,6 +140,8 @@ int sieve_register_comparator __P((sieve_machine_t mach, | ... | @@ -137,6 +140,8 @@ int sieve_register_comparator __P((sieve_machine_t mach, |
137 | sieve_comparator_t contains, | 140 | sieve_comparator_t contains, |
138 | sieve_comparator_t matches, | 141 | sieve_comparator_t matches, |
139 | sieve_comparator_t regex)); | 142 | sieve_comparator_t regex)); |
143 | int sieve_require_action __P((sieve_machine_t mach, const char *name)); | ||
144 | int sieve_require_test __P((sieve_machine_t mach, const char *name)); | ||
140 | int sieve_require_comparator __P((sieve_machine_t mach, const char *name)); | 145 | int sieve_require_comparator __P((sieve_machine_t mach, const char *name)); |
141 | 146 | ||
142 | sieve_comparator_t sieve_comparator_lookup __P((sieve_machine_t mach, | 147 | sieve_comparator_t sieve_comparator_lookup __P((sieve_machine_t mach, |
... | @@ -148,6 +153,7 @@ sieve_comparator_t sieve_get_comparator __P((sieve_machine_t mach, | ... | @@ -148,6 +153,7 @@ sieve_comparator_t sieve_get_comparator __P((sieve_machine_t mach, |
148 | 153 | ||
149 | void sieve_require __P((list_t slist)); | 154 | void sieve_require __P((list_t slist)); |
150 | int sieve_tag_lookup __P((list_t taglist, char *name, sieve_value_t **arg)); | 155 | int sieve_tag_lookup __P((list_t taglist, char *name, sieve_value_t **arg)); |
156 | int sieve_load_ext __P((sieve_machine_t mach, const char *name)); | ||
151 | 157 | ||
152 | /* Operations in value lists */ | 158 | /* Operations in value lists */ |
153 | sieve_value_t *sieve_value_get __P((list_t vlist, size_t index)); | 159 | sieve_value_t *sieve_value_get __P((list_t vlist, size_t index)); |
... | @@ -201,6 +207,7 @@ int sieve_mailbox __P((sieve_machine_t mach, mailbox_t mbox)); | ... | @@ -201,6 +207,7 @@ int sieve_mailbox __P((sieve_machine_t mach, mailbox_t mbox)); |
201 | int sieve_message __P((sieve_machine_t mach, message_t message)); | 207 | int sieve_message __P((sieve_machine_t mach, message_t message)); |
202 | int sieve_disass __P((sieve_machine_t mach)); | 208 | int sieve_disass __P((sieve_machine_t mach)); |
203 | 209 | ||
210 | |||
204 | #ifdef __cplusplus | 211 | #ifdef __cplusplus |
205 | } | 212 | } |
206 | #endif | 213 | #endif | ... | ... |
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | #include <sieve.h> | 26 | #include <sieve.h> |
27 | 27 | ||
28 | static sieve_register_t * | 28 | static sieve_register_t * |
29 | sieve_lookup (list_t list, const char *name) | 29 | reg_lookup (list_t list, const char *name) |
30 | { | 30 | { |
31 | iterator_t itr; | 31 | iterator_t itr; |
32 | sieve_register_t *reg; | 32 | sieve_register_t *reg; |
... | @@ -49,15 +49,42 @@ sieve_lookup (list_t list, const char *name) | ... | @@ -49,15 +49,42 @@ sieve_lookup (list_t list, const char *name) |
49 | sieve_register_t * | 49 | sieve_register_t * |
50 | sieve_test_lookup (sieve_machine_t mach, const char *name) | 50 | sieve_test_lookup (sieve_machine_t mach, const char *name) |
51 | { | 51 | { |
52 | return sieve_lookup (mach->test_list, name); | 52 | return reg_lookup (mach->test_list, name); |
53 | } | 53 | } |
54 | 54 | ||
55 | sieve_register_t * | 55 | sieve_register_t * |
56 | sieve_action_lookup (sieve_machine_t mach, const char *name) | 56 | sieve_action_lookup (sieve_machine_t mach, const char *name) |
57 | { | 57 | { |
58 | return sieve_lookup (mach->action_list, name); | 58 | return reg_lookup (mach->action_list, name); |
59 | } | 59 | } |
60 | 60 | ||
61 | static int | ||
62 | reg_require (sieve_machine_t mach, list_t list, const char *name) | ||
63 | { | ||
64 | sieve_register_t *reg = reg_lookup (list, name); | ||
65 | if (!reg) | ||
66 | { | ||
67 | if (!(sieve_load_ext (mach, name) == 0 | ||
68 | && (reg = reg_lookup (list, name)) != NULL)) | ||
69 | return 1; | ||
70 | } | ||
71 | reg->required = 1; | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | int | ||
76 | sieve_require_action (sieve_machine_t mach, const char *name) | ||
77 | { | ||
78 | return reg_require (mach, mach->action_list, name); | ||
79 | } | ||
80 | |||
81 | int | ||
82 | sieve_require_test (sieve_machine_t mach, const char *name) | ||
83 | { | ||
84 | return reg_require (mach, mach->test_list, name); | ||
85 | } | ||
86 | |||
87 | |||
61 | static int | 88 | static int |
62 | sieve_register (list_t *pool, | 89 | sieve_register (list_t *pool, |
63 | list_t *list, | 90 | list_t *list, | ... | ... |
-
Please register or sign in to post a comment