From 78bbdc897129194245b32bc34e731070d15bc16e Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Sun, 17 Aug 2008 22:41:33 +0200 Subject: [PATCH] Cleaned up include extension. --- src/lib-sieve/plugins/include/cmd-import.c | 3 ++ src/lib-sieve/plugins/include/cmd-include.c | 12 ++++-- src/lib-sieve/plugins/include/cmd-return.c | 3 ++ .../plugins/include/ext-include-binary.c | 36 ++++++++--------- .../plugins/include/ext-include-binary.h | 7 ++++ .../plugins/include/ext-include-common.c | 5 ++- .../plugins/include/ext-include-common.h | 3 ++ .../plugins/include/ext-include-limits.h | 3 ++ .../plugins/include/ext-include-variables.c | 9 ++++- .../plugins/include/ext-include-variables.h | 3 ++ src/lib-sieve/plugins/include/ext-include.c | 39 ++++++++++--------- 11 files changed, 80 insertions(+), 43 deletions(-) diff --git a/src/lib-sieve/plugins/include/cmd-import.c b/src/lib-sieve/plugins/include/cmd-import.c index 00ff3a8a4..cacab7da6 100644 --- a/src/lib-sieve/plugins/include/cmd-import.c +++ b/src/lib-sieve/plugins/include/cmd-import.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "sieve-common.h" diff --git a/src/lib-sieve/plugins/include/cmd-include.c b/src/lib-sieve/plugins/include/cmd-include.c index 85ad0a5da..e150a4422 100644 --- a/src/lib-sieve/plugins/include/cmd-include.c +++ b/src/lib-sieve/plugins/include/cmd-include.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "str-sanitize.h" @@ -77,7 +80,7 @@ struct cmd_include_context_data { }; /* - * Tags + * Tagged arguments */ static bool cmd_include_validate_location_tag @@ -111,7 +114,8 @@ static bool cmd_include_validate_location_tag if ( ctx_data->location_assigned) { sieve_command_validate_error(validator, cmd, - "include: cannot use location tags ':personal' and ':global' multiple times"); + "include: cannot use location tags ':personal' and ':global' " + "multiple times"); return FALSE; } @@ -186,13 +190,13 @@ static bool cmd_include_validate(struct sieve_validator *validator, "include: '/' not allowed in script name (%s)", str_sanitize(script_name, 80)); return FALSE; - } + } script_dir = ext_include_get_script_directory (ctx_data->location, script_name); if ( script_dir == NULL ) { sieve_command_validate_error(validator, cmd, - "include: specified location for included script '%s' is unavailable " + "include: specified location for included script '%s' is unavailable " "(system logs should provide more information)", str_sanitize(script_name, 80)); return FALSE; diff --git a/src/lib-sieve/plugins/include/cmd-return.c b/src/lib-sieve/plugins/include/cmd-return.c index 37ebc4396..335d6d0a9 100644 --- a/src/lib-sieve/plugins/include/cmd-return.c +++ b/src/lib-sieve/plugins/include/cmd-return.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "sieve-code.h" diff --git a/src/lib-sieve/plugins/include/ext-include-binary.c b/src/lib-sieve/plugins/include/ext-include-binary.c index 8815f977a..530243ac6 100644 --- a/src/lib-sieve/plugins/include/ext-include-binary.c +++ b/src/lib-sieve/plugins/include/ext-include-binary.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "str.h" @@ -16,20 +19,6 @@ #include "ext-include-variables.h" #include "ext-include-binary.h" -/* - * Types - */ - -struct ext_include_binary_context { - struct sieve_binary *binary; - unsigned int dependency_block; - - struct hash_table *included_scripts; - ARRAY_DEFINE(include_index, struct ext_include_script_info *); - - struct sieve_variable_scope *global_vars; -}; - /* * Forward declarations */ @@ -55,6 +44,17 @@ const struct sieve_binary_extension include_binary_ext = { * Binary context management */ +struct ext_include_binary_context { + struct sieve_binary *binary; + unsigned int dependency_block; + + struct hash_table *included_scripts; + ARRAY_DEFINE(include_index, struct ext_include_script_info *); + + struct sieve_variable_scope *global_vars; +}; + + static struct ext_include_binary_context *ext_include_binary_create_context (struct sieve_binary *sbin) { @@ -85,10 +85,6 @@ struct ext_include_binary_context *ext_include_binary_get_context return ctx; } - -/* - * Binary include implementation - */ struct ext_include_binary_context *ext_include_binary_init (struct sieve_binary *sbin, struct sieve_ast *ast) @@ -351,6 +347,10 @@ static void ext_include_binary_free(struct sieve_binary *sbin) } +/* + * Dumping the binary + */ + inline static const char *_script_location (enum ext_include_script_location loc) { diff --git a/src/lib-sieve/plugins/include/ext-include-binary.h b/src/lib-sieve/plugins/include/ext-include-binary.h index f50cbd032..7f5988ff0 100644 --- a/src/lib-sieve/plugins/include/ext-include-binary.h +++ b/src/lib-sieve/plugins/include/ext-include-binary.h @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __EXT_INCLUDE_BINARY_H #define __EXT_INCLUDE_BINARY_H @@ -48,6 +51,10 @@ const struct ext_include_script_info *ext_include_binary_script_get unsigned int ext_include_binary_script_get_count (struct ext_include_binary_context *binctx); +/* + * Dumping the binary + */ + bool ext_include_binary_dump(struct sieve_dumptime_env *denv); #endif /* __EXT_INCLUDE_BINARY_H */ diff --git a/src/lib-sieve/plugins/include/ext-include-common.c b/src/lib-sieve/plugins/include/ext-include-common.c index 4f685a2ab..19538aad7 100644 --- a/src/lib-sieve/plugins/include/ext-include-common.c +++ b/src/lib-sieve/plugins/include/ext-include-common.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "str-sanitize.h" @@ -327,7 +330,7 @@ struct sieve_variable_storage *ext_include_interpreter_get_global_variables } /* - * Including a script during generation + * Including a script during code generation */ bool ext_include_generate_include diff --git a/src/lib-sieve/plugins/include/ext-include-common.h b/src/lib-sieve/plugins/include/ext-include-common.h index 018129b0a..fa3426df4 100644 --- a/src/lib-sieve/plugins/include/ext-include-common.h +++ b/src/lib-sieve/plugins/include/ext-include-common.h @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __EXT_INCLUDE_COMMON_H #define __EXT_INCLUDE_COMMON_H diff --git a/src/lib-sieve/plugins/include/ext-include-limits.h b/src/lib-sieve/plugins/include/ext-include-limits.h index eaa9c26a8..b89ae2745 100644 --- a/src/lib-sieve/plugins/include/ext-include-limits.h +++ b/src/lib-sieve/plugins/include/ext-include-limits.h @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __EXT_INCLUDE_LIMITS_H #define __EXT_INCLUDE_LIMITS_H diff --git a/src/lib-sieve/plugins/include/ext-include-variables.c b/src/lib-sieve/plugins/include/ext-include-variables.c index ae1ff5295..6726fc813 100644 --- a/src/lib-sieve/plugins/include/ext-include-variables.c +++ b/src/lib-sieve/plugins/include/ext-include-variables.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "sieve-common.h" #include "sieve-error.h" #include "sieve-script.h" @@ -106,14 +109,16 @@ struct sieve_variable *ext_include_variable_import_global varctx = p_new(pool, struct ext_include_variable, 1); varctx->type = EXT_INCLUDE_VAR_IMPORTED; - varctx->source_line = cmd->ast_node->source_line; impvar->context = varctx; } return var; } - +/* + * Binary symbol table + */ + bool ext_include_variables_save (struct sieve_binary *sbin, struct sieve_variable_scope *global_vars) { diff --git a/src/lib-sieve/plugins/include/ext-include-variables.h b/src/lib-sieve/plugins/include/ext-include-variables.h index 6458b8381..3a0e4185c 100644 --- a/src/lib-sieve/plugins/include/ext-include-variables.h +++ b/src/lib-sieve/plugins/include/ext-include-variables.h @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __EXT_INCLUDE_VARIABLES_H #define __EXT_INCLUDE_VARIABLES_H diff --git a/src/lib-sieve/plugins/include/ext-include.c b/src/lib-sieve/plugins/include/ext-include.c index b1b7b0951..dabcf913c 100644 --- a/src/lib-sieve/plugins/include/ext-include.c +++ b/src/lib-sieve/plugins/include/ext-include.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + /* Extension include * ----------------- * @@ -27,15 +30,9 @@ #include "ext-include-common.h" #include "ext-include-binary.h" -/* Forward declarations */ - -static bool ext_include_load(int ext_id); -static bool ext_include_validator_load(struct sieve_validator *validator); -static bool ext_include_generator_load(const struct sieve_codegen_env *cgenv); -static bool ext_include_binary_load(struct sieve_binary *sbin); -static bool ext_include_interpreter_load(struct sieve_interpreter *interp); - -/* Operations */ +/* + * Operations + */ static const struct sieve_operation *ext_include_operations[] = { &include_operation, @@ -44,7 +41,19 @@ static const struct sieve_operation *ext_include_operations[] = { &export_operation }; -/* Extension definitions */ +/* + * Extension + */ + +/* Forward declaration */ + +static bool ext_include_load(int ext_id); +static bool ext_include_validator_load(struct sieve_validator *validator); +static bool ext_include_generator_load(const struct sieve_codegen_env *cgenv); +static bool ext_include_binary_load(struct sieve_binary *sbin); +static bool ext_include_interpreter_load(struct sieve_interpreter *interp); + +/* Extension objects */ static int ext_my_id; @@ -61,6 +70,8 @@ const struct sieve_extension include_extension = { SIEVE_EXT_DEFINE_NO_OPERANDS }; +/* Extension hooks */ + static bool ext_include_load(int ext_id) { ext_my_id = ext_id; @@ -68,8 +79,6 @@ static bool ext_include_load(int ext_id) return TRUE; } -/* Load extension into validator */ - static bool ext_include_validator_load(struct sieve_validator *validator) { /* Register new commands */ @@ -81,8 +90,6 @@ static bool ext_include_validator_load(struct sieve_validator *validator) return TRUE; } -/* Load extension into generator */ - static bool ext_include_generator_load(const struct sieve_codegen_env *cgenv) { ext_include_register_generator_context(cgenv); @@ -90,8 +97,6 @@ static bool ext_include_generator_load(const struct sieve_codegen_env *cgenv) return TRUE; } -/* Load extension into interpreter */ - static bool ext_include_interpreter_load (struct sieve_interpreter *interp) { @@ -100,8 +105,6 @@ static bool ext_include_interpreter_load return TRUE; } -/* Load extension into binary */ - static bool ext_include_binary_load(struct sieve_binary *sbin) { /* Register extension to the binary object to get notified of events like -- GitLab