dovecot-2.0-sieve: Adjusted tag parameter validation API.
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sun Jan 3 14:33:57 EET 2010
details: http://hg.rename-it.nl/dovecot-2.0-sieve/rev/07e60dfc49e4
changeset: 1174:07e60dfc49e4
user: Stephan Bosch <stephan at rename-it.nl>
date: Sat Jan 02 19:06:03 2010 +0100
description:
Adjusted tag parameter validation API.
diffstat:
src/lib-sieve/plugins/body/tst-body.c | 5 +----
src/lib-sieve/plugins/date/tst-date.c | 2 +-
src/lib-sieve/plugins/enotify/cmd-notify.c | 6 ++++--
src/lib-sieve/plugins/imap4flags/tag-flags.c | 2 +-
src/lib-sieve/plugins/notify/cmd-notify.c | 6 ++++--
src/lib-sieve/plugins/vacation/cmd-vacation.c | 6 +++---
src/lib-sieve/sieve-validator.c | 22 +++++++++++++++-------
src/lib-sieve/sieve-validator.h | 3 ++-
src/testsuite/cmd-test-message.c | 2 +-
src/testsuite/tst-test-error.c | 2 +-
src/testsuite/tst-test-result.c | 2 +-
11 files changed, 34 insertions(+), 24 deletions(-)
diffs (216 lines):
diff -r 968a695f1a6a -r 07e60dfc49e4 src/lib-sieve/plugins/body/tst-body.c
--- a/src/lib-sieve/plugins/body/tst-body.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/lib-sieve/plugins/body/tst-body.c Sat Jan 02 19:06:03 2010 +0100
@@ -154,13 +154,10 @@
* :content <content-types: string-list>
*/
if ( !sieve_validate_tag_parameter
- (valdtr, cmd, tag, *arg, SAAT_STRING_LIST) ) {
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) ) {
return FALSE;
}
- if ( !sieve_validator_argument_activate(valdtr, cmd, *arg, FALSE) )
- return FALSE;
-
/* Assign tag parameters */
tag->parameters = *arg;
*arg = sieve_ast_arguments_detach(*arg,1);
diff -r 968a695f1a6a -r 07e60dfc49e4 src/lib-sieve/plugins/date/tst-date.c
--- a/src/lib-sieve/plugins/date/tst-date.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/lib-sieve/plugins/date/tst-date.c Sat Jan 02 19:06:03 2010 +0100
@@ -173,7 +173,7 @@
* :zone <time-zone: string>
*/
if ( !sieve_validate_tag_parameter
- (valdtr, cmd, tag, *arg, SAAT_STRING) ) {
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) {
return FALSE;
}
diff -r 968a695f1a6a -r 07e60dfc49e4 src/lib-sieve/plugins/enotify/cmd-notify.c
--- a/src/lib-sieve/plugins/enotify/cmd-notify.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/lib-sieve/plugins/enotify/cmd-notify.c Sat Jan 02 19:06:03 2010 +0100
@@ -180,7 +180,8 @@
* :from <string>
* :message <string>
*/
- if ( !sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, SAAT_STRING) )
+ if ( !sieve_validate_tag_parameter
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) )
return FALSE;
if ( sieve_argument_is(tag, notify_from_tag) ) {
@@ -213,7 +214,8 @@
/* Check syntax:
* :options string-list
*/
- if ( !sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, SAAT_STRING_LIST) )
+ if ( !sieve_validate_tag_parameter
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) )
return FALSE;
/* Assign context */
diff -r 968a695f1a6a -r 07e60dfc49e4 src/lib-sieve/plugins/imap4flags/tag-flags.c
--- a/src/lib-sieve/plugins/imap4flags/tag-flags.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/lib-sieve/plugins/imap4flags/tag-flags.c Sat Jan 02 19:06:03 2010 +0100
@@ -128,7 +128,7 @@
* :flags <list-of-flags: string-list>
*/
if ( !sieve_validate_tag_parameter
- (valdtr, cmd, tag, *arg, SAAT_STRING_LIST) ) {
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) ) {
return FALSE;
}
diff -r 968a695f1a6a -r 07e60dfc49e4 src/lib-sieve/plugins/notify/cmd-notify.c
--- a/src/lib-sieve/plugins/notify/cmd-notify.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/lib-sieve/plugins/notify/cmd-notify.c Sat Jan 02 19:06:03 2010 +0100
@@ -192,7 +192,8 @@
* :method <string>
* :message <string>
*/
- if ( !sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, SAAT_STRING) )
+ if ( !sieve_validate_tag_parameter
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) )
return FALSE;
if ( sieve_argument_is(tag, notify_method_tag) ) {
@@ -231,7 +232,8 @@
/* Check syntax:
* :options string-list
*/
- if ( !sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, SAAT_STRING_LIST) )
+ if ( !sieve_validate_tag_parameter
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) )
return FALSE;
/* Assign context */
diff -r 968a695f1a6a -r 07e60dfc49e4 src/lib-sieve/plugins/vacation/cmd-vacation.c
--- a/src/lib-sieve/plugins/vacation/cmd-vacation.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c Sat Jan 02 19:06:03 2010 +0100
@@ -242,7 +242,7 @@
* :days number
*/
if ( !sieve_validate_tag_parameter
- (valdtr, cmd, tag, *arg, SAAT_NUMBER) ) {
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_NUMBER, FALSE) ) {
return FALSE;
}
@@ -274,7 +274,7 @@
* :handle string
*/
if ( !sieve_validate_tag_parameter
- (valdtr, cmd, tag, *arg, SAAT_STRING) ) {
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) {
return FALSE;
}
@@ -332,7 +332,7 @@
* :addresses string-list
*/
if ( !sieve_validate_tag_parameter
- (valdtr, cmd, tag, *arg, SAAT_STRING_LIST) ) {
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING_LIST, FALSE) ) {
return FALSE;
}
diff -r 968a695f1a6a -r 07e60dfc49e4 src/lib-sieve/sieve-validator.c
--- a/src/lib-sieve/sieve-validator.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/lib-sieve/sieve-validator.c Sat Jan 02 19:06:03 2010 +0100
@@ -803,14 +803,18 @@
bool sieve_validate_tag_parameter
(struct sieve_validator *valdtr, struct sieve_command *cmd,
struct sieve_ast_argument *tag, struct sieve_ast_argument *param,
- enum sieve_ast_argument_type req_type)
+ const char *arg_name, unsigned int arg_pos,
+ enum sieve_ast_argument_type req_type, bool constant)
{
if ( param == NULL ) {
+ const char *position = ( arg_pos == 0 ? "" :
+ t_strdup_printf(" %d (%s)", arg_pos, arg_name) );
+
sieve_argument_validate_error(valdtr, tag,
- "the :%s tag for the %s %s requires %s as parameter, "
- "but no more arguments were found", sieve_ast_argument_tag(tag),
+ "the :%s tag for the %s %s requires %s as parameter %s, "
+ "but no parameters were found", sieve_ast_argument_tag(tag),
sieve_command_identifier(cmd), sieve_command_type_name(cmd),
- sieve_ast_argument_type_name(req_type));
+ sieve_ast_argument_type_name(req_type), position);
return FALSE;
}
@@ -818,15 +822,19 @@
(sieve_ast_argument_type(param) != SAAT_STRING ||
req_type != SAAT_STRING_LIST) )
{
+ const char *position = ( arg_pos == 0 ? "" :
+ t_strdup_printf(" %d (%s)", arg_pos, arg_name) );
+
sieve_argument_validate_error(valdtr, param,
- "the :%s tag for the %s %s requires %s as parameter, "
+ "the :%s tag for the %s %s requires %s as parameter%s, "
"but %s was found", sieve_ast_argument_tag(tag),
sieve_command_identifier(cmd), sieve_command_type_name(cmd),
- sieve_ast_argument_type_name(req_type), sieve_ast_argument_name(param));
+ sieve_ast_argument_type_name(req_type), position,
+ sieve_ast_argument_name(param));
return FALSE;
}
- if ( !sieve_validator_argument_activate(valdtr, cmd, param, FALSE) )
+ if ( !sieve_validator_argument_activate(valdtr, cmd, param, constant) )
return FALSE;
param->argument->id_code = tag->argument->id_code;
diff -r 968a695f1a6a -r 07e60dfc49e4 src/lib-sieve/sieve-validator.h
--- a/src/lib-sieve/sieve-validator.h Sat Jan 02 16:16:24 2010 +0100
+++ b/src/lib-sieve/sieve-validator.h Sat Jan 02 19:06:03 2010 +0100
@@ -114,7 +114,8 @@
bool sieve_validate_tag_parameter
(struct sieve_validator *valdtr, struct sieve_command *cmd,
struct sieve_ast_argument *tag, struct sieve_ast_argument *param,
- enum sieve_ast_argument_type req_type);
+ const char *arg_name, unsigned int arg_pos,
+ enum sieve_ast_argument_type req_type, bool constant);
/*
* Extension support
diff -r 968a695f1a6a -r 07e60dfc49e4 src/testsuite/cmd-test-message.c
--- a/src/testsuite/cmd-test-message.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/testsuite/cmd-test-message.c Sat Jan 02 19:06:03 2010 +0100
@@ -193,7 +193,7 @@
* :folder string
*/
if ( !sieve_validate_tag_parameter
- (valdtr, cmd, tag, *arg, SAAT_STRING) ) {
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_STRING, FALSE) ) {
return FALSE;
}
diff -r 968a695f1a6a -r 07e60dfc49e4 src/testsuite/tst-test-error.c
--- a/src/testsuite/tst-test-error.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/testsuite/tst-test-error.c Sat Jan 02 19:06:03 2010 +0100
@@ -102,7 +102,7 @@
* :index number
*/
if ( !sieve_validate_tag_parameter
- (valdtr, cmd, tag, *arg, SAAT_NUMBER) ) {
+ (valdtr, cmd, tag, *arg, NULL, 0, SAAT_NUMBER, FALSE) ) {
return FALSE;
}
diff -r 968a695f1a6a -r 07e60dfc49e4 src/testsuite/tst-test-result.c
--- a/src/testsuite/tst-test-result.c Sat Jan 02 16:16:24 2010 +0100
+++ b/src/testsuite/tst-test-result.c Sat Jan 02 19:06:03 2010 +0100
@@ -107,7 +107,7 @@
* :index number
*/
if ( !sieve_validate_tag_parameter
- (validator, cmd, tag, *arg, SAAT_NUMBER) ) {
+ (validator, cmd, tag, *arg, NULL, 0, SAAT_NUMBER, FALSE) ) {
return FALSE;
}
More information about the dovecot-cvs
mailing list