diff --git a/src/lib-sieve/Makefile.am b/src/lib-sieve/Makefile.am index 3af5a36a7e0436cc25196f99a31ab46e3a61635d..81fd9917bf6eb87252ae82462cdd3558530988af 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 0000000000000000000000000000000000000000..eb3cd183419dd9c317a5a4e624a611e3477c5261 --- /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 c9a90d80db3f257b09f22d183c69c180bb218964..68b7599f3cdf59688b08ff6577d3c949a428a191 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 299182e0e5f93fbaf803a6a948cb29a9d2f24323..37d5087116d7daf799768a33de08d5adea25a8fa 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,