Skip to content
Snippets Groups Projects
Commit c5ae8068 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Exported discard command to its own separate file.

parent 0bde3903
No related branches found
No related tags found
No related merge requests found
......@@ -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 \
......
#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;
}
#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
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.