diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2002-11-14 14:50:48 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2002-11-14 14:50:48 +0000 |
commit | 6743217693a0d837a62b364209c1a6a1edbc2de0 (patch) | |
tree | 466c7bf0fc7bfc725619b2c45ea0cd1999c28bba | |
parent | a5be4691fe917aa6dba90d6dc95934950c4a43a0 (diff) | |
download | mailutils-6743217693a0d837a62b364209c1a6a1edbc2de0.tar.gz mailutils-6743217693a0d837a62b364209c1a6a1edbc2de0.tar.bz2 |
(sieve_vlist_do, sieve_vlist_compare): New functions.
-rw-r--r-- | libsieve/util.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/libsieve/util.c b/libsieve/util.c index 917208ab0..4b083c9e9 100644 --- a/libsieve/util.c +++ b/libsieve/util.c @@ -338,6 +338,7 @@ tag_printer (sieve_runtime_tag_t *val, struct debug_data *dbg) sieve_debug_internal (dbg->printer, dbg->data, ")"); } sieve_debug_internal (dbg->printer, dbg->data, " "); + return 0; } void @@ -370,4 +371,64 @@ sieve_mark_deleted (message_t msg, int deleted) return rc; } +int +sieve_vlist_do (sieve_value_t *val, list_action_t *ac, void *data) +{ + switch (val->type) + { + case SVT_VALUE_LIST: + case SVT_STRING_LIST: + return list_do (val->v.list, ac, data); + + default: + return -1; + } +} + +struct comp_data { + sieve_value_t *val; + sieve_comparator_t comp; + sieve_retrieve_t retr; + void *data; +}; + +struct comp_data2 { + char *sample; + sieve_comparator_t comp; +}; +int +_comp_action2 (void *item, void *data) +{ + struct comp_data2 *cp = data; + return cp->comp (item, cp->sample); +} + +int +_comp_action (void *item, void *data) +{ + struct comp_data *cp = data; + struct comp_data2 d; + int rc; + + if (cp->retr (item, cp->data, &d.sample)) + return 0; + d.comp = cp->comp; + rc = sieve_vlist_do (cp->val, _comp_action2, &d); + free (d.sample); + return rc; +} + +int +sieve_vlist_compare (sieve_value_t *a, sieve_value_t *b, + sieve_comparator_t comp, sieve_retrieve_t retr, + void *data) +{ + struct comp_data d; + + d.comp = comp; + d.retr = retr; + d.data = data; + d.val = b; + return sieve_vlist_do (a, _comp_action, &d); +} |