From c5ae806830cd16194b3fbc355d6a0085d6aef7a0 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Mon, 26 Nov 2007 19:19:16 +0100 Subject: [PATCH] Exported discard command to its own separate file. --- src/lib-sieve/Makefile.am | 3 +- src/lib-sieve/cmd-discard.c | 72 ++++++++++++++++++++++++++++++++++ src/lib-sieve/cmd-keep.c | 3 +- src/lib-sieve/sieve-commands.c | 43 -------------------- 4 files changed, 75 insertions(+), 46 deletions(-) create mode 100644 src/lib-sieve/cmd-discard.c diff --git a/src/lib-sieve/Makefile.am b/src/lib-sieve/Makefile.am index 3af5a36a7..81fd9917b 100644 --- a/src/lib-sieve/Makefile.am +++ b/src/lib-sieve/Makefile.am @@ -21,7 +21,8 @@ cmds = \ cmd-if.c \ cmd-require.c \ cmd-redirect.c \ - cmd-keep.c + cmd-keep.c \ + cmd-discard.c exts = \ ext-fileinto.c \ diff --git a/src/lib-sieve/cmd-discard.c b/src/lib-sieve/cmd-discard.c new file mode 100644 index 000000000..eb3cd1834 --- /dev/null +++ b/src/lib-sieve/cmd-discard.c @@ -0,0 +1,72 @@ +#include "lib.h" + +#include "sieve-commands.h" +#include "sieve-commands-private.h" +#include "sieve-validator.h" +#include "sieve-generator.h" +#include "sieve-interpreter.h" +#include "sieve-result.h" + +/* Forward declarations */ + +static bool cmd_discard_generate + (struct sieve_generator *generator, + struct sieve_command_context *ctx ATTR_UNUSED); + +static bool opc_discard_execute + (const struct sieve_opcode *opcode, + const struct sieve_runtime_env *renv, sieve_size_t *address); + +/* Discard command + * + * Syntax + * discard + */ +const struct sieve_command cmd_discard = { + "discard", + SCT_COMMAND, + 0, 0, FALSE, FALSE, + NULL, NULL, NULL, + cmd_discard_generate, + NULL +}; + +/* Discard opcode */ + +const struct sieve_opcode cmd_discard_opcode = { + "DISCARD", + SIEVE_OPCODE_DISCARD, + NULL, + 0, + NULL, + opc_discard_execute +}; + +/* + * Generation + */ + +static bool cmd_discard_generate + (struct sieve_generator *generator, + struct sieve_command_context *ctx ATTR_UNUSED) +{ + sieve_operation_emit_code( + sieve_generator_get_binary(generator), &cmd_discard_opcode); + return TRUE; +} + +/* + * Interpretation + */ + +static bool opc_discard_execute +(const struct sieve_opcode *opcode ATTR_UNUSED, + const struct sieve_runtime_env *renv ATTR_UNUSED, + sieve_size_t *address ATTR_UNUSED) +{ + printf(">> DISCARD\n"); + + return TRUE; +} + + diff --git a/src/lib-sieve/cmd-keep.c b/src/lib-sieve/cmd-keep.c index c9a90d80d..68b7599f3 100644 --- a/src/lib-sieve/cmd-keep.c +++ b/src/lib-sieve/cmd-keep.c @@ -1,5 +1,4 @@ #include "lib.h" -#include "str-sanitize.h" #include "sieve-commands.h" #include "sieve-commands-private.h" @@ -70,7 +69,7 @@ static bool cmd_keep_generate } /* - * Intepretation + * Interpretation */ static bool opc_keep_execute diff --git a/src/lib-sieve/sieve-commands.c b/src/lib-sieve/sieve-commands.c index 299182e0e..37d508711 100644 --- a/src/lib-sieve/sieve-commands.c +++ b/src/lib-sieve/sieve-commands.c @@ -141,10 +141,6 @@ static bool cmd_stop_generate static bool cmd_stop_validate (struct sieve_validator *validator, struct sieve_command_context *ctx); -static bool cmd_discard_generate - (struct sieve_generator *generator, - struct sieve_command_context *ctx ATTR_UNUSED); - const struct sieve_command cmd_stop = { "stop", SCT_COMMAND, @@ -155,15 +151,6 @@ const struct sieve_command cmd_stop = { NULL }; -const struct sieve_command cmd_discard = { - "discard", - SCT_COMMAND, - 0, 0, FALSE, FALSE, - NULL, NULL, NULL, - cmd_discard_generate, - NULL -}; - /* Lists of core tests and commands */ const struct sieve_command *sieve_core_tests[] = { @@ -261,9 +248,6 @@ inline bool sieve_command_block_exits_unconditionally static bool opc_stop_execute (const struct sieve_opcode *opcode, const struct sieve_runtime_env *renv, sieve_size_t *address); -static bool opc_discard_execute - (const struct sieve_opcode *opcode, - const struct sieve_runtime_env *renv, sieve_size_t *address); const struct sieve_opcode cmd_stop_opcode = { "STOP", @@ -274,15 +258,6 @@ const struct sieve_opcode cmd_stop_opcode = { opc_stop_execute }; -const struct sieve_opcode cmd_discard_opcode = { - "DISCARD", - SIEVE_OPCODE_DISCARD, - NULL, - 0, - NULL, - opc_discard_execute -}; - static bool opc_stop_execute (const struct sieve_opcode *opcode ATTR_UNUSED, const struct sieve_runtime_env *renv, @@ -295,15 +270,6 @@ static bool opc_stop_execute return TRUE; } -static bool opc_discard_execute -(const struct sieve_opcode *opcode ATTR_UNUSED, - const struct sieve_runtime_env *renv ATTR_UNUSED, - sieve_size_t *address ATTR_UNUSED) -{ - printf(">> DISCARD\n"); - - return TRUE; -} /* Code generation for trivial commands and tests */ @@ -325,15 +291,6 @@ static bool cmd_stop_generate return TRUE; } -static bool cmd_discard_generate - (struct sieve_generator *generator, - struct sieve_command_context *ctx ATTR_UNUSED) -{ - sieve_operation_emit_code( - sieve_generator_get_binary(generator), &cmd_discard_opcode); - return TRUE; -} - static bool tst_false_generate (struct sieve_generator *generator, struct sieve_command_context *context ATTR_UNUSED, -- GitLab