Commit a5910b7b a5910b7b29ef70feaba37935b7b5c509b2b91d49 by Sergey Poznyakoff

(sieve_retrieve_t): Extra argument.

(sieve_destructor_t,sieve_tag_checker_t): New types.
(sieve_value_t): New member v.ptr.
(sieve_tag_def_t): Removed num member.
(sieve_tag_group_t): New data type.
(sieve_runtime_tag): Changed type of tag member to char *.
(sieve_register_t): Removed unused members. Changed type of
tags member.
(sieve_register_test,sieve_register_action): Changed type of
fourth argument (tags).
(sieve_machine_destroy,sieve_machine_add_destructor): New
functions.
1 parent f61d2513
...@@ -34,8 +34,10 @@ typedef void (*sieve_action_log_t) __PMT((void *data, ...@@ -34,8 +34,10 @@ typedef void (*sieve_action_log_t) __PMT((void *data,
34 const char *fmt, va_list ap)); 34 const char *fmt, va_list ap));
35 35
36 typedef int (*sieve_comparator_t) __PMT((const char *, const char *)); 36 typedef int (*sieve_comparator_t) __PMT((const char *, const char *));
37 typedef int (*sieve_retrieve_t) __PMT((void *item, void *data, char **pval)); 37 typedef int (*sieve_retrieve_t) __PMT((void *item, void *data, int idx, char **pval));
38 38 typedef void (*sieve_destructor_t) __PMT((void *data));
39 typedef int (*sieve_tag_checker_t) __PMT((const char *name,
40 list_t tags, list_t args));
39 41
40 typedef enum { 42 typedef enum {
41 SVT_VOID, 43 SVT_VOID,
...@@ -44,7 +46,8 @@ typedef enum { ...@@ -44,7 +46,8 @@ typedef enum {
44 SVT_STRING_LIST, 46 SVT_STRING_LIST,
45 SVT_TAG, 47 SVT_TAG,
46 SVT_IDENT, 48 SVT_IDENT,
47 SVT_VALUE_LIST 49 SVT_VALUE_LIST,
50 SVT_POINTER
48 } sieve_data_type; 51 } sieve_data_type;
49 52
50 typedef struct sieve_runtime_tag sieve_runtime_tag_t; 53 typedef struct sieve_runtime_tag sieve_runtime_tag_t;
...@@ -56,17 +59,22 @@ typedef struct { ...@@ -56,17 +59,22 @@ typedef struct {
56 long number; 59 long number;
57 list_t list; 60 list_t list;
58 sieve_runtime_tag_t *tag; 61 sieve_runtime_tag_t *tag;
62 void *ptr;
59 } v; 63 } v;
60 } sieve_value_t; 64 } sieve_value_t;
61 65
62 typedef struct { 66 typedef struct {
63 char *name; 67 char *name;
64 int num;
65 sieve_data_type argtype; 68 sieve_data_type argtype;
66 } sieve_tag_def_t; 69 } sieve_tag_def_t;
67 70
71 typedef struct {
72 sieve_tag_def_t *tags;
73 sieve_tag_checker_t checker;
74 } sieve_tag_group_t;
75
68 struct sieve_runtime_tag { 76 struct sieve_runtime_tag {
69 int tag; 77 char *tag;
70 sieve_value_t *arg; 78 sieve_value_t *arg;
71 }; 79 };
72 80
...@@ -74,10 +82,8 @@ typedef struct { ...@@ -74,10 +82,8 @@ typedef struct {
74 char *name; 82 char *name;
75 int required; 83 int required;
76 sieve_handler_t handler; 84 sieve_handler_t handler;
77 int num_req_args;
78 sieve_data_type *req_args; 85 sieve_data_type *req_args;
79 int num_tags; 86 sieve_tag_group_t *tags;
80 sieve_tag_def_t *tags;
81 } sieve_register_t; 87 } sieve_register_t;
82 88
83 #define MU_SIEVE_MATCH_IS 1 89 #define MU_SIEVE_MATCH_IS 1
...@@ -108,10 +114,10 @@ sieve_register_t *sieve_test_lookup __P((const char *name)); ...@@ -108,10 +114,10 @@ sieve_register_t *sieve_test_lookup __P((const char *name));
108 sieve_register_t *sieve_action_lookup __P((const char *name)); 114 sieve_register_t *sieve_action_lookup __P((const char *name));
109 int sieve_register_test __P((const char *name, sieve_handler_t handler, 115 int sieve_register_test __P((const char *name, sieve_handler_t handler,
110 sieve_data_type *arg_types, 116 sieve_data_type *arg_types,
111 sieve_tag_def_t *tags, int required)); 117 sieve_tag_group_t *tags, int required));
112 int sieve_register_action __P((const char *name, sieve_handler_t handler, 118 int sieve_register_action __P((const char *name, sieve_handler_t handler,
113 sieve_data_type *arg_types, 119 sieve_data_type *arg_types,
114 sieve_tag_def_t *tags, int required)); 120 sieve_tag_group_t *tags, int required));
115 121
116 void sieve_slist_destroy __P((list_t *plist)); 122 void sieve_slist_destroy __P((list_t *plist));
117 void sieve_require __P((list_t slist)); 123 void sieve_require __P((list_t slist));
...@@ -133,6 +139,11 @@ int sieve_mailbox __P((sieve_machine_t mach, mailbox_t mbox)); ...@@ -133,6 +139,11 @@ int sieve_mailbox __P((sieve_machine_t mach, mailbox_t mbox));
133 int sieve_disass __P((sieve_machine_t mach)); 139 int sieve_disass __P((sieve_machine_t mach));
134 140
135 int sieve_machine_init __P((sieve_machine_t *mach, void *data)); 141 int sieve_machine_init __P((sieve_machine_t *mach, void *data));
142 void sieve_machine_destroy __P((sieve_machine_t *pmach));
143 int sieve_machine_add_destructor __P((sieve_machine_t mach,
144 sieve_destructor_t destr,
145 void *ptr));
146
136 void sieve_machine_set_error __P((sieve_machine_t mach, 147 void sieve_machine_set_error __P((sieve_machine_t mach,
137 sieve_printf_t error_printer)); 148 sieve_printf_t error_printer));
138 void sieve_machine_set_parse_error __P((sieve_machine_t mach, 149 void sieve_machine_set_parse_error __P((sieve_machine_t mach,
...@@ -166,3 +177,5 @@ sieve_comparator_t sieve_comparator_lookup __P((const char *name, ...@@ -166,3 +177,5 @@ sieve_comparator_t sieve_comparator_lookup __P((const char *name,
166 int matchtype)); 177 int matchtype));
167 178
168 sieve_comparator_t sieve_get_comparator __P((list_t tags)); 179 sieve_comparator_t sieve_get_comparator __P((list_t tags));
180
181 const char *sieve_type_str __P((sieve_data_type type));
......