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

Added operand emission support for action side effects.

parent 0a7f6dcd
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
#include "mail-storage.h"
#include "mail-namespace.h"
#include "sieve-code.h"
#include "sieve-extensions.h"
#include "sieve-binary.h"
#include "sieve-interpreter.h"
......@@ -24,7 +25,7 @@ const struct sieve_extension side_effects_extension = {
NULL, NULL,
seffect_binary_load,
NULL,
SIEVE_EXT_DEFINE_NO_OPCODES,
SIEVE_EXT_DEFINE_NO_OPCODES, /* Opcode is hardcoded */
NULL
};
......@@ -60,6 +61,23 @@ static bool seffect_binary_load(struct sieve_binary *sbin)
return TRUE;
}
/*
* Side-effect operand
*/
static struct sieve_operand_class side_effect_class =
{ "side-effect", NULL };
struct sieve_operand side_effect_operand =
{ "side-effect", &side_effect_class, FALSE };
void sieve_opr_side_effect_emit
(struct sieve_binary *sbin, struct sieve_side_effect *seffect, int ext_id)
{
sieve_binary_emit_extension
(sbin, seffect, ext_id, 0, SIEVE_OPERAND_SIDE_EFFECT,
seffect->extension->side_effects_count > 1)
}
/*
* Actions common to multiple core commands
*/
......
......@@ -45,10 +45,15 @@ struct sieve_action {
/* Action side effects */
struct sieve_side_effect_extension;
struct sieve_side_effect {
const char *name;
const struct sieve_action *to_action;
const struct sieve_side_effect_extension *extension;
unsigned int ext_code;
bool (*pre_execute)
(const struct sieve_side_effect *seffect, const struct sieve_action *action,
const struct sieve_action_exec_env *aenv, void **se_context,
......@@ -85,6 +90,9 @@ void sieve_side_effect_extension_set
(struct sieve_binary *sbin, int ext_id,
const struct sieve_side_effect_extension *ext);
void sieve_opr_side_effect_emit
(struct sieve_binary *sbin, struct sieve_side_effect *seffect, int ext_id);
/* Actions common to multiple commands */
const struct sieve_action act_store;
......
......@@ -88,4 +88,15 @@ void sieve_binary_registry_set_object
(struct sieve_binary *sbin, int ext_id, int id, const void *object);
void sieve_binary_registry_init(struct sieve_binary *sbin, int ext_id);
/* */
#define sieve_binary_emit_extension(sbin, obj, ext_id, base, operand, mult) \
unsigned char code = base + sieve_binary_extension_get_index(sbin, ext_id); \
\
(void) sieve_operand_emit_code(sbin, operand); \
(void) sieve_binary_emit_byte(sbin, code); \
if ( mult ) \
(void) sieve_binary_emit_byte(sbin, obj->ext_code);
#endif
......@@ -221,6 +221,7 @@ const struct sieve_operand stringlist_operand =
extern struct sieve_operand comparator_operand;
extern struct sieve_operand match_type_operand;
extern struct sieve_operand address_part_operand;
extern struct sieve_operand side_effect_operand;
const struct sieve_operand *sieve_operands[] = {
NULL, /* SIEVE_OPERAND_OPTIONAL */
......@@ -229,7 +230,8 @@ const struct sieve_operand *sieve_operands[] = {
&stringlist_operand,
&comparator_operand,
&match_type_operand,
&address_part_operand
&address_part_operand,
&side_effect_operand
};
const unsigned int sieve_operand_count =
......
......@@ -63,6 +63,7 @@ enum sieve_core_operand {
SIEVE_OPERAND_COMPARATOR,
SIEVE_OPERAND_MATCH_TYPE,
SIEVE_OPERAND_ADDRESS_PART,
SIEVE_OPERAND_SIDE_EFFECT,
SIEVE_OPERAND_CUSTOM
};
......
......@@ -58,7 +58,7 @@ extern const struct sieve_extension imapflags_extension;
extern const struct sieve_extension copy_extension;
const struct sieve_extension *sieve_core_extensions[] = {
/* Preloaded extensions */
/* Preloaded 'extensions' */
&comparator_extension, &match_type_extension, &address_part_extension,
&side_effects_extension,
......
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.