From 81083e3e0ad4012c49f7ed3b56a986c6c7fae02a Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan.bosch@open-xchange.com> Date: Wed, 17 Jun 2020 23:53:56 +0200 Subject: [PATCH] lib-sieve: plugins: relational: Reformat ext-relational-common.c. --- .../relational/ext-relational-common.c | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/src/lib-sieve/plugins/relational/ext-relational-common.c b/src/lib-sieve/plugins/relational/ext-relational-common.c index 9f70e900d..14b4e0581 100644 --- a/src/lib-sieve/plugins/relational/ext-relational-common.c +++ b/src/lib-sieve/plugins/relational/ext-relational-common.c @@ -2,11 +2,12 @@ */ /* Syntax: - * MATCH-TYPE =/ COUNT / VALUE - * COUNT = ":count" relational-match - * VALUE = ":value" relational-match - * relational-match = DQUOTE ( "gt" / "ge" / "lt" - * / "le" / "eq" / "ne" ) DQUOTE + + MATCH-TYPE =/ COUNT / VALUE + COUNT = ":count" relational-match + VALUE = ":value" relational-match + relational-match = DQUOTE ( "gt" / "ge" / "lt" + / "le" / "eq" / "ne" ) DQUOTE */ #include "lib.h" @@ -36,41 +37,44 @@ const struct sieve_match_type_def *rel_match_types[]; * Validation */ -bool mcht_relational_validate -(struct sieve_validator *valdtr, struct sieve_ast_argument **arg, - struct sieve_match_type_context *ctx) +bool mcht_relational_validate(struct sieve_validator *valdtr, + struct sieve_ast_argument **arg, + struct sieve_match_type_context *ctx) { struct sieve_match_type *mcht; enum relational_match rel_match = REL_MATCH_INVALID; string_t *rel_match_ident; /* Check syntax: - * relational-match = DQUOTE ( "gt" / "ge" / "lt" - * / "le" / "eq" / "ne" ) DQUOTE - * - * So, actually this must be a constant string and it is implemented as such + relational-match = DQUOTE ( "gt" / "ge" / "lt" + / "le" / "eq" / "ne" ) DQUOTE + + So, actually this must be a constant string and it is implemented as + such. */ - /* Did we get a string in the first place ? */ - if ( (*arg)->type != SAAT_STRING ) { - sieve_argument_validate_error(valdtr, *arg, + /* Did we get a string in the first place? */ + if ((*arg)->type != SAAT_STRING) { + sieve_argument_validate_error( + valdtr, *arg, "the :%s match-type requires a constant string argument being " "one of \"gt\", \"ge\", \"lt\", \"le\", \"eq\" or \"ne\", " "but %s was found", - sieve_match_type_name(ctx->match_type), sieve_ast_argument_name(*arg)); + sieve_match_type_name(ctx->match_type), + sieve_ast_argument_name(*arg)); return FALSE; } /* Check the relational match id */ rel_match_ident = sieve_ast_argument_str(*arg); - if ( str_len(rel_match_ident) == 2 ) { + if (str_len(rel_match_ident) == 2) { const char *rel_match_id = str_c(rel_match_ident); - switch ( rel_match_id[0] ) { + switch (rel_match_id[0]) { /* "gt" or "ge" */ case 'g': - switch ( rel_match_id[1] ) { + switch (rel_match_id[1]) { case 't': rel_match = REL_MATCH_GREATER; break; @@ -83,7 +87,7 @@ bool mcht_relational_validate break; /* "lt" or "le" */ case 'l': - switch ( rel_match_id[1] ) { + switch (rel_match_id[1]) { case 't': rel_match = REL_MATCH_LESS; break; @@ -96,14 +100,14 @@ bool mcht_relational_validate break; /* "eq" */ case 'e': - if ( rel_match_id[1] == 'q' ) + if (rel_match_id[1] == 'q') rel_match = REL_MATCH_EQUAL; else rel_match = REL_MATCH_INVALID; break; /* "ne" */ case 'n': - if ( rel_match_id[1] == 'e' ) + if (rel_match_id[1] == 'e') rel_match = REL_MATCH_NOT_EQUAL; else rel_match = REL_MATCH_INVALID; @@ -114,8 +118,9 @@ bool mcht_relational_validate } } - if ( rel_match >= REL_MATCH_INVALID ) { - sieve_argument_validate_error(valdtr, *arg, + if (rel_match >= REL_MATCH_INVALID) { + sieve_argument_validate_error( + valdtr, *arg, "the :%s match-type requires a constant string argument being " "one of \"gt\", \"ge\", \"lt\", \"le\", \"eq\" or \"ne\", " "but \"%s\" was found", @@ -135,8 +140,8 @@ bool mcht_relational_validate */ mcht = p_new(sieve_ast_argument_pool(*arg), struct sieve_match_type, 1); mcht->object.ext = ctx->match_type->object.ext; - SIEVE_OBJECT_SET_DEF(mcht, rel_match_types - [REL_MATCH_INDEX(ctx->match_type->object.def->code, rel_match)]); + SIEVE_OBJECT_SET_DEF(mcht, rel_match_types[ + REL_MATCH_INDEX(ctx->match_type->object.def->code, rel_match)]); ctx->match_type = mcht; return TRUE; @@ -150,7 +155,7 @@ const struct sieve_match_type_def *rel_match_types[] = { &rel_match_value_gt, &rel_match_value_ge, &rel_match_value_lt, &rel_match_value_le, &rel_match_value_eq, &rel_match_value_ne, &rel_match_count_gt, &rel_match_count_ge, &rel_match_count_lt, - &rel_match_count_le, &rel_match_count_eq, &rel_match_count_ne + &rel_match_count_le, &rel_match_count_eq, &rel_match_count_ne, }; static const struct sieve_extension_objects ext_match_types = @@ -160,6 +165,5 @@ const struct sieve_operand_def rel_match_type_operand = { .name = "relational match", .ext_def = &relational_extension, .class = &sieve_match_type_operand_class, - .interface = &ext_match_types + .interface = &ext_match_types, }; - -- GitLab