diff --git a/src/lib-sieve/plugins/index/tag-index.c b/src/lib-sieve/plugins/index/tag-index.c index d2bd65b1fc48edfa306d87e9cbebcb755ba9d9fc..ba29e79c1fed499900926ec19042fe227cb06667 100644 --- a/src/lib-sieve/plugins/index/tag-index.c +++ b/src/lib-sieve/plugins/index/tag-index.c @@ -22,12 +22,13 @@ * Tagged argument */ -static bool tag_index_validate - (struct sieve_validator *valdtr, struct sieve_ast_argument **arg, - struct sieve_command *cmd); -static bool tag_index_generate - (const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg, - struct sieve_command *context); +static bool +tag_index_validate(struct sieve_validator *valdtr, + struct sieve_ast_argument **arg, struct sieve_command *cmd); +static bool +tag_index_generate(const struct sieve_codegen_env *cgenv, + struct sieve_ast_argument *arg, + struct sieve_command *context); const struct sieve_argument_def index_tag = { .identifier = "index", @@ -35,9 +36,9 @@ const struct sieve_argument_def index_tag = { .generate = tag_index_generate }; -static bool tag_last_validate - (struct sieve_validator *valdtr, struct sieve_ast_argument **arg, - struct sieve_command *cmd); +static bool +tag_last_validate(struct sieve_validator *valdtr, + struct sieve_ast_argument **arg, struct sieve_command *cmd); const struct sieve_argument_def last_tag = { .identifier = "last", @@ -48,17 +49,18 @@ const struct sieve_argument_def last_tag = { * Header override */ -static bool svmo_index_dump_context - (const struct sieve_message_override *svmo, - const struct sieve_dumptime_env *denv, sieve_size_t *address); -static int svmo_index_read_context - (const struct sieve_message_override *svmo, - const struct sieve_runtime_env *renv, sieve_size_t *address, - void **ho_context); -static int svmo_index_header_override - (const struct sieve_message_override *svmo, - const struct sieve_runtime_env *renv, - bool mime_decode, struct sieve_stringlist **headers); +static bool +svmo_index_dump_context(const struct sieve_message_override *svmo, + const struct sieve_dumptime_env *denv, + sieve_size_t *address); +static int +svmo_index_read_context(const struct sieve_message_override *svmo, + const struct sieve_runtime_env *renv, + sieve_size_t *address, void **ho_context); +static int +svmo_index_header_override(const struct sieve_message_override *svmo, + const struct sieve_runtime_env *renv, + bool mime_decode, struct sieve_stringlist **headers); const struct sieve_message_override_def index_header_override = { SIEVE_OBJECT("index", &index_operand, 0), @@ -95,9 +97,9 @@ struct tag_index_data { * Tag validation */ -static bool tag_index_validate -(struct sieve_validator *valdtr ATTR_UNUSED, - struct sieve_ast_argument **arg, struct sieve_command *cmd) +static bool +tag_index_validate(struct sieve_validator *valdtr ATTR_UNUSED, + struct sieve_ast_argument **arg, struct sieve_command *cmd) { struct sieve_ast_argument *tag = *arg; struct tag_index_data *data; @@ -108,10 +110,9 @@ static bool tag_index_validate /* Check syntax: * ":index" <fieldno: number> */ - if ( !sieve_validate_tag_parameter - (valdtr, cmd, tag, *arg, NULL, 0, SAAT_NUMBER, FALSE) ) { + if (!sieve_validate_tag_parameter(valdtr, cmd, tag, *arg, NULL, 0, + SAAT_NUMBER, FALSE)) return FALSE; - } if (tag->argument->data == NULL) { data = p_new(sieve_command_pool(cmd), struct tag_index_data, 1); @@ -127,19 +128,21 @@ static bool tag_index_validate return TRUE; } -static bool tag_last_validate -(struct sieve_validator *valdtr ATTR_UNUSED, - struct sieve_ast_argument **arg, struct sieve_command *cmd) +static bool +tag_last_validate(struct sieve_validator *valdtr ATTR_UNUSED, + struct sieve_ast_argument **arg, struct sieve_command *cmd) { struct sieve_ast_argument *index_arg; struct tag_index_data *data; index_arg = sieve_command_find_argument(cmd, &index_tag); if (index_arg == NULL) { - sieve_argument_validate_error(valdtr, *arg, + sieve_argument_validate_error( + valdtr, *arg, "the :last tag for the %s %s cannot be specified " "without the :index tag", - sieve_command_identifier(cmd), sieve_command_type_name(cmd)); + sieve_command_identifier(cmd), + sieve_command_type_name(cmd)); return FALSE; } @@ -153,7 +156,7 @@ static bool tag_last_validate data->last = TRUE; /* Detach */ - *arg = sieve_ast_arguments_detach(*arg,1); + *arg = sieve_ast_arguments_detach(*arg, 1); return TRUE; } @@ -161,24 +164,22 @@ static bool tag_last_validate * Code generation */ -static bool tag_index_generate -(const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg, - struct sieve_command *cmd ATTR_UNUSED) +static bool +tag_index_generate(const struct sieve_codegen_env *cgenv, + struct sieve_ast_argument *arg, + struct sieve_command *cmd ATTR_UNUSED) { struct tag_index_data *data = (struct tag_index_data *)arg->argument->data; - if ( sieve_ast_argument_type(arg) != SAAT_TAG ) + if (sieve_ast_argument_type(arg) != SAAT_TAG) return FALSE; - sieve_opr_message_override_emit - (cgenv->sblock, arg->argument->ext, &index_header_override); - - (void)sieve_binary_emit_integer - (cgenv->sblock, data->fieldno); - (void)sieve_binary_emit_byte - (cgenv->sblock, ( data->last ? 1 : 0 )); + sieve_opr_message_override_emit(cgenv->sblock, arg->argument->ext, + &index_header_override); + (void)sieve_binary_emit_integer (cgenv->sblock, data->fieldno); + (void)sieve_binary_emit_byte(cgenv->sblock, (data->last ? 1 : 0)); return TRUE; } @@ -195,20 +196,20 @@ struct svmo_index_context { /* Context coding */ -static bool svmo_index_dump_context -(const struct sieve_message_override *svmo ATTR_UNUSED, - const struct sieve_dumptime_env *denv, sieve_size_t *address) +static bool +svmo_index_dump_context(const struct sieve_message_override *svmo ATTR_UNUSED, + const struct sieve_dumptime_env *denv, + sieve_size_t *address) { sieve_number_t fieldno = 0; unsigned int last; - if ( !sieve_binary_read_integer(denv->sblock, address, &fieldno) ) + if (!sieve_binary_read_integer(denv->sblock, address, &fieldno)) return FALSE; - sieve_code_dumpf(denv, "fieldno: %llu", - (unsigned long long) fieldno); + sieve_code_dumpf(denv, "fieldno: %llu", (unsigned long long) fieldno); - if ( !sieve_binary_read_byte(denv->sblock, address, &last) ) + if (!sieve_binary_read_byte(denv->sblock, address, &last)) return FALSE; if (last > 0) @@ -216,22 +217,21 @@ static bool svmo_index_dump_context return TRUE; } -static int svmo_index_read_context -(const struct sieve_message_override *svmo ATTR_UNUSED, - const struct sieve_runtime_env *renv, sieve_size_t *address, - void **ho_context) +static int +svmo_index_read_context(const struct sieve_message_override *svmo ATTR_UNUSED, + const struct sieve_runtime_env *renv, + sieve_size_t *address, void **ho_context) { pool_t pool = sieve_result_pool(renv->result); struct svmo_index_context *ctx; sieve_number_t fieldno; unsigned int last = 0; - if ( !sieve_binary_read_integer(renv->sblock, address, &fieldno) ) { + if (!sieve_binary_read_integer(renv->sblock, address, &fieldno)) { sieve_runtime_trace_error(renv, "fieldno: invalid number"); return SIEVE_EXEC_BIN_CORRUPT; } - - if ( !sieve_binary_read_byte(renv->sblock, address, &last) ) { + if (!sieve_binary_read_byte(renv->sblock, address, &last)) { sieve_runtime_trace_error(renv, "last: invalid byte"); return SIEVE_EXEC_BIN_CORRUPT; } @@ -241,27 +241,26 @@ static int svmo_index_read_context ctx->last = (last == 0 ? FALSE : TRUE); *ho_context = (void *) ctx; - return SIEVE_EXEC_OK; } /* Override */ -static int svmo_index_header_override -(const struct sieve_message_override *svmo, - const struct sieve_runtime_env *renv, - bool mime_decode ATTR_UNUSED, - struct sieve_stringlist **headers) +static int +svmo_index_header_override(const struct sieve_message_override *svmo, + const struct sieve_runtime_env *renv, + bool mime_decode ATTR_UNUSED, + struct sieve_stringlist **headers) { struct svmo_index_context *ctx = (struct svmo_index_context *)svmo->context; - sieve_runtime_trace(renv, SIEVE_TRLVL_MATCHING, + sieve_runtime_trace( + renv, SIEVE_TRLVL_MATCHING, "header index override: only returning index %d%s", - ctx->fieldno, ( ctx->last ? " (from last)" : "" )); + ctx->fieldno, (ctx->last ? " (from last)" : "")); - *headers = sieve_index_stringlist_create(renv, *headers, - (int)ctx->fieldno * ( ctx->last ? -1 : 1 )); + *headers = sieve_index_stringlist_create( + renv, *headers, (int)ctx->fieldno * (ctx->last ? -1 : 1)); return SIEVE_EXEC_OK; } -