dovecot-2.2-pigeonhole: lib-sieve: Added support for having mult...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Fri Jan 8 19:51:28 UTC 2016
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/1f8ce0c29ef4
changeset: 2213:1f8ce0c29ef4
user: Stephan Bosch <stephan at rename-it.nl>
date: Fri Jan 08 20:49:39 2016 +0100
description:
lib-sieve: Added support for having multiple instances of a single tag (type) within a single command.
diffstat:
src/lib-sieve/sieve-commands.h | 6 ++++++
src/lib-sieve/sieve-validator.c | 40 +++++++++++++++++++++-------------------
2 files changed, 27 insertions(+), 19 deletions(-)
diffs (71 lines):
diff -r 9748a6055d2c -r 1f8ce0c29ef4 src/lib-sieve/sieve-commands.h
--- a/src/lib-sieve/sieve-commands.h Fri Jan 08 20:49:39 2016 +0100
+++ b/src/lib-sieve/sieve-commands.h Fri Jan 08 20:49:39 2016 +0100
@@ -13,8 +13,14 @@
* Argument definition
*/
+enum sieve_argument_flag {
+ /* More than one of this (type of) tagged argument is allowed */
+ SIEVE_ARGUMENT_FLAG_MULTIPLE = (1 << 0)
+};
+
struct sieve_argument_def {
const char *identifier;
+ enum sieve_argument_flag flags;
bool (*is_instance_of)
(struct sieve_validator *valdtr, struct sieve_command *cmd,
diff -r 9748a6055d2c -r 1f8ce0c29ef4 src/lib-sieve/sieve-validator.c
--- a/src/lib-sieve/sieve-validator.c Fri Jan 08 20:49:39 2016 +0100
+++ b/src/lib-sieve/sieve-validator.c Fri Jan 08 20:49:39 2016 +0100
@@ -939,28 +939,30 @@
struct sieve_ast_argument *parg;
/* Scan backwards for any duplicates */
- parg = sieve_ast_argument_prev(arg);
- while ( parg != NULL ) {
- if ( (sieve_ast_argument_type(parg) == SAAT_TAG &&
- parg->argument->def == tag_def)
- || (arg->argument->id_code > 0 && parg->argument != NULL &&
- parg->argument->id_code == arg->argument->id_code) )
- {
- const char *tag_id = sieve_ast_argument_tag(arg);
- const char *tag_desc =
- strcmp(tag_def->identifier, tag_id) != 0 ?
- t_strdup_printf("%s argument (:%s)", tag_def->identifier, tag_id) :
- t_strdup_printf(":%s argument", tag_def->identifier);
+ if ( (tag_def->flags & SIEVE_ARGUMENT_FLAG_MULTIPLE) == 0 ) {
+ parg = sieve_ast_argument_prev(arg);
+ while ( parg != NULL ) {
+ if ( (sieve_ast_argument_type(parg) == SAAT_TAG &&
+ parg->argument->def == tag_def)
+ || (arg->argument->id_code > 0 && parg->argument != NULL &&
+ parg->argument->id_code == arg->argument->id_code) )
+ {
+ const char *tag_id = sieve_ast_argument_tag(arg);
+ const char *tag_desc =
+ strcmp(tag_def->identifier, tag_id) != 0 ?
+ t_strdup_printf("%s argument (:%s)", tag_def->identifier, tag_id) :
+ t_strdup_printf(":%s argument", tag_def->identifier);
- sieve_argument_validate_error(valdtr, arg,
- "encountered duplicate %s for the %s %s",
- tag_desc, sieve_command_identifier(cmd),
- sieve_command_type_name(cmd));
+ sieve_argument_validate_error(valdtr, arg,
+ "encountered duplicate %s for the %s %s",
+ tag_desc, sieve_command_identifier(cmd),
+ sieve_command_type_name(cmd));
- return FALSE;
+ return FALSE;
+ }
+
+ parg = sieve_ast_argument_prev(parg);
}
-
- parg = sieve_ast_argument_prev(parg);
}
/* Call the validation function for the tag (if present)
More information about the dovecot-cvs
mailing list