* Forward declarations */ static int cmp_i_ascii_casemap_compare (const struct sieve_comparator *cmp, const char *val1, size_t val1_size, const char *val2, size_t val2_size); static bool cmp_i_ascii_casemap_char_match (const struct sieve_comparator *cmp, const char **val1, const char *val1_end, const char **val2, const char *val2_end); /* * Comparator object */ const struct sieve_comparator_def i_ascii_casemap_comparator = { SIEVE_OBJECT ("i;ascii-casemap", &comparator_operand, SIEVE_COMPARATOR_I_ASCII_CASEMAP), SIEVE_COMPARATOR_FLAG_ORDERING | SIEVE_COMPARATOR_FLAG_EQUALITY | SIEVE_COMPARATOR_FLAG_SUBSTRING_MATCH | SIEVE_COMPARATOR_FLAG_PREFIX_MATCH, cmp_i_ascii_casemap_compare, cmp_i_ascii_casemap_char_match, sieve_comparator_octet_skip }; /* * Comparator implementation */ static int cmp_i_ascii_casemap_compare( const struct sieve_comparator *cmp ATTR_UNUSED, const char *val1, size_t val1_size, const char *val2, size_t val2_size) {
#include <stdio.h> /* * Forward declarations */ static int mcht_contains_match_key (struct sieve_match_context *mctx, const char *val, size_t val_size, const char *key, size_t key_size); /* * Match-type object */ const struct sieve_match_type_def contains_match_type = { SIEVE_OBJECT("contains", &match_type_operand, SIEVE_MATCH_TYPE_CONTAINS), NULL, sieve_match_substring_validate_context, NULL, NULL, NULL, mcht_contains_match_key, NULL }; /* * Match-type implementation */ /* FIXME: Naive substring match implementation. Should switch to more * efficient algorithm if large values need to be searched (e.g. message body). */ static int mcht_contains_match_key
#include <stdio.h> /* * Forward declarations */ static int mcht_is_match_key (struct sieve_match_context *mctx, const char *val, size_t val_size, const char *key, size_t key_size); /* * Match-type object */ const struct sieve_match_type_def is_match_type = { SIEVE_OBJECT("is", &match_type_operand, SIEVE_MATCH_TYPE_IS), NULL, NULL, NULL, NULL, NULL, mcht_is_match_key, NULL }; /* * Match-type implementation */ static int mcht_is_match_key (struct sieve_match_context *mctx ATTR_UNUSED, const char *val, size_t val_size, const char *key, size_t key_size) { if ( val_size == 0 )
/* * Global variables namespace */ bool vnspc_global_variables_validate (struct sieve_validator *valdtr, const struct sieve_variables_namespace *nspc, struct sieve_ast_argument *arg, struct sieve_command *cmd, ARRAY_TYPE(sieve_variable_name) *var_name, void **var_data, bool assignment); bool vnspc_global_variables_generate (const struct sieve_codegen_env *cgenv, const struct sieve_variables_namespace *nspc, struct sieve_ast_argument *arg, struct sieve_command *cmd, void *var_data); static const struct sieve_variables_namespace_def global_variables_namespace = { SIEVE_OBJECT("global", NULL, 0), vnspc_global_variables_validate, vnspc_global_variables_generate, NULL, NULL }; bool vnspc_global_variables_validate (struct sieve_validator *valdtr, const struct sieve_variables_namespace *nspc, struct sieve_ast_argument *arg, struct sieve_command *cmd ATTR_UNUSED, ARRAY_TYPE(sieve_variable_name) *var_name, void **var_data, bool assignment ATTR_UNUSED) { const struct sieve_extension *this_ext = SIEVE_OBJECT_EXTENSION(nspc); struct sieve_ast *ast = arg->ast;
#include "ext-relational-common.h" /* * Forward declarations */ static int mcht_count_match (struct sieve_match_context *mctx, struct sieve_stringlist *value_list, struct sieve_stringlist *key_list); /* * Match-type objects */ const struct sieve_match_type_def count_match_type = { SIEVE_OBJECT("count", &rel_match_type_operand, RELATIONAL_COUNT), .validate = mcht_relational_validate }; #define COUNT_MATCH_TYPE(name, rel_match) \ const struct sieve_match_type_def rel_match_count_ ## name = { \ SIEVE_OBJECT("count-" #name, \ &rel_match_type_operand, \ REL_MATCH_INDEX(RELATIONAL_COUNT, rel_match)), \ .match = mcht_count_match, \ } COUNT_MATCH_TYPE(gt, REL_MATCH_GREATER); COUNT_MATCH_TYPE(ge, REL_MATCH_GREATER_EQUAL); COUNT_MATCH_TYPE(lt, REL_MATCH_LESS); COUNT_MATCH_TYPE(le, REL_MATCH_LESS_EQUAL);
bool assignment); bool testsuite_varnamespace_generate (const struct sieve_codegen_env *cgenv, const struct sieve_variables_namespace *nspc, struct sieve_ast_argument *arg, struct sieve_command *cmd, void *var_data); bool testsuite_varnamespace_dump_variable (const struct sieve_dumptime_env *denv, const struct sieve_variables_namespace *nspc, const struct sieve_operand *oprnd, sieve_size_t *address); int testsuite_varnamespace_read_variable (const struct sieve_runtime_env *renv, const struct sieve_variables_namespace *nspc, const struct sieve_operand *oprnd, sieve_size_t *address, string_t **str_r); static const struct sieve_variables_namespace_def testsuite_namespace = { SIEVE_OBJECT("tst", &testsuite_namespace_operand, 0), testsuite_varnamespace_validate, testsuite_varnamespace_generate, testsuite_varnamespace_dump_variable, testsuite_varnamespace_read_variable }; bool testsuite_varnamespace_validate (struct sieve_validator *valdtr, const struct sieve_variables_namespace *nspc ATTR_UNUSED, struct sieve_ast_argument *arg, struct sieve_command *cmd ATTR_UNUSED, ARRAY_TYPE(sieve_variable_name) *var_name, void **var_data, bool assignment) { struct sieve_ast *ast = arg->ast; const struct sieve_variable_name *name_element;
const struct sieve_variables_namespace *nspc, struct sieve_ast_argument *arg, struct sieve_command *cmd, void *var_data); static bool vnspc_vnd_environment_dump_variable (const struct sieve_dumptime_env *denv, const struct sieve_variables_namespace *nspc, const struct sieve_operand *oprnd, sieve_size_t *address); static int vnspc_vnd_environment_read_variable (const struct sieve_runtime_env *renv, const struct sieve_variables_namespace *nspc, const struct sieve_operand *oprnd, sieve_size_t *address, string_t **str_r); static const struct sieve_variables_namespace_def environment_namespace = { SIEVE_OBJECT("env", &environment_namespace_operand, 0), vnspc_vnd_environment_validate, vnspc_vnd_environment_generate, vnspc_vnd_environment_dump_variable, vnspc_vnd_environment_read_variable }; static bool vnspc_vnd_environment_validate (struct sieve_validator *valdtr, const struct sieve_variables_namespace *nspc ATTR_UNUSED, struct sieve_ast_argument *arg, struct sieve_command *cmd ATTR_UNUSED, ARRAY_TYPE(sieve_variable_name) *var_name, void **var_data, bool assignment) { struct sieve_ast *ast = arg->ast; const struct sieve_variable_name *name_elements;
}; /* * Side effect */ static void seff_mailbox_create_print (const struct sieve_side_effect *seffect, const struct sieve_action *action, const struct sieve_result_print_env *rpenv, bool *keep); static bool seff_mailbox_create_pre_execute (const struct sieve_side_effect *seffect, const struct sieve_action *action, const struct sieve_action_exec_env *aenv, void **se_context, void *tr_context); const struct sieve_side_effect_def mailbox_create_side_effect = { SIEVE_OBJECT("create", &mailbox_create_operand, 0), &act_store, NULL, NULL, NULL, seff_mailbox_create_print, seff_mailbox_create_pre_execute, NULL, NULL, NULL }; /* * Operand */ static const struct sieve_extension_objects ext_side_effects = SIEVE_EXT_DEFINE_SIDE_EFFECT(mailbox_create_side_effect); const struct sieve_operand_def mailbox_create_operand = {
*/ static bool svmo_mime_dump_context (const struct sieve_message_override *svmo, const struct sieve_dumptime_env *denv, sieve_size_t *address); static int svmo_mime_read_context (const struct sieve_message_override *svmo, const struct sieve_runtime_env *renv, sieve_size_t *address, void **ho_context); static int svmo_mime_header_override (const struct sieve_message_override *svmo, const struct sieve_runtime_env *renv, bool mime_decode, struct sieve_stringlist **headers); const struct sieve_message_override_def mime_header_override = { SIEVE_OBJECT("mime", &mime_operand, 0), .sequence = 0, /* Completely replace header source */ .dump_context = svmo_mime_dump_context, .read_context = svmo_mime_read_context, .header_override = svmo_mime_header_override }; /* * Operand */ static const struct sieve_extension_objects ext_header_overrides = SIEVE_EXT_DEFINE_MESSAGE_OVERRIDE(mime_header_override); const struct sieve_operand_def mime_operand = { .name = "mime operand",
#include "sieve-commands.h" #include "sieve-comparators.h" #include "sieve-match-types.h" #include "sieve-validator.h" #include "sieve-generator.h" #include "sieve-interpreter.h" #include "sieve-match.h" #include "ext-relational-common.h" /* * Match-type objects */ const struct sieve_match_type_def value_match_type = { SIEVE_OBJECT("value", &rel_match_type_operand, RELATIONAL_VALUE), .validate = mcht_relational_validate }; #define VALUE_MATCH_TYPE(name, rel_match) \ const struct sieve_match_type_def rel_match_value_ ## name = { \ SIEVE_OBJECT("value-" #name, \ &rel_match_type_operand, \ REL_MATCH_INDEX(RELATIONAL_VALUE, rel_match)), \ .match_key = mcht_value_match_key, \ } VALUE_MATCH_TYPE(gt, REL_MATCH_GREATER); VALUE_MATCH_TYPE(ge, REL_MATCH_GREATER_EQUAL); VALUE_MATCH_TYPE(lt, REL_MATCH_LESS); VALUE_MATCH_TYPE(le, REL_MATCH_LESS_EQUAL);
*/ static bool svmo_index_dump_context (const struct sieve_message_override *svmo, const struct sieve_dumptime_env *denv, sieve_size_t *address); static int svmo_index_read_context (const struct sieve_message_override *svmo, const struct sieve_runtime_env *renv, sieve_size_t *address, void **ho_context); static int svmo_index_header_override (const struct sieve_message_override *svmo, const struct sieve_runtime_env *renv, bool mime_decode, struct sieve_stringlist **headers); const struct sieve_message_override_def index_header_override = { SIEVE_OBJECT("index", &index_operand, 0), .sequence = SIEVE_EXT_INDEX_HDR_OVERRIDE_SEQUENCE, .dump_context = svmo_index_dump_context, .read_context = svmo_index_read_context, .header_override = svmo_index_header_override }; /* * Operand */ static const struct sieve_extension_objects ext_header_overrides = SIEVE_EXT_DEFINE_MESSAGE_OVERRIDE(index_header_override); const struct sieve_operand_def index_operand = { .name = "index operand",
#include <stdio.h> /* * Forward declarations */ static int mcht_matches_match_key (struct sieve_match_context *mctx, const char *val, size_t val_size, const char *key, size_t key_size); /* * Match-type object */ const struct sieve_match_type_def matches_match_type = { SIEVE_OBJECT("matches", &match_type_operand, SIEVE_MATCH_TYPE_MATCHES), .validate_context = sieve_match_substring_validate_context, .match_key = mcht_matches_match_key }; /* * Match-type implementation */ /* Quick 'n dirty debug */ //#define MATCH_DEBUG #ifdef MATCH_DEBUG #define debug_printf(...) printf ("match debug: " __VA_ARGS__) #else #define debug_printf(...) #endif
* Forward declarations */ static int cmp_i_octet_compare (const struct sieve_comparator *cmp, const char *val1, size_t val1_size, const char *val2, size_t val2_size); static bool cmp_i_octet_char_match (const struct sieve_comparator *cmp, const char **val1, const char *val1_end, const char **val2, const char *val2_end); /* * Comparator object */ const struct sieve_comparator_def i_octet_comparator = { SIEVE_OBJECT("i;octet", &comparator_operand, SIEVE_COMPARATOR_I_OCTET), SIEVE_COMPARATOR_FLAG_ORDERING | SIEVE_COMPARATOR_FLAG_EQUALITY | SIEVE_COMPARATOR_FLAG_SUBSTRING_MATCH | SIEVE_COMPARATOR_FLAG_PREFIX_MATCH, cmp_i_octet_compare, cmp_i_octet_char_match, sieve_comparator_octet_skip }; /* * Comparator implementation */ static int cmp_i_octet_compare( const struct sieve_comparator *cmp ATTR_UNUSED, const char *val1, size_t val1_size, const char *val2, size_t val2_size) {
#include "sieve-common.h" #include "sieve-code.h" #include "sieve-ext-variables.h" #include "ext-enotify-common.h" /* * Encodeurl modifier */ bool mod_encodeurl_modify(string_t *in, string_t **result); const struct sieve_variables_modifier_def encodeurl_modifier = { SIEVE_OBJECT("encodeurl", &encodeurl_operand, 0), 15, mod_encodeurl_modify }; /* * Modifier operand */ static const struct sieve_extension_objects ext_enotify_modifiers = SIEVE_VARIABLES_DEFINE_MODIFIER(encodeurl_modifier); const struct sieve_operand_def encodeurl_operand = { "modifier", &enotify_extension, 0,
* Core modifiers */ /* Forward declarations */ bool mod_lower_modify(string_t *in, string_t **result); bool mod_upper_modify(string_t *in, string_t **result); bool mod_lowerfirst_modify(string_t *in, string_t **result); bool mod_upperfirst_modify(string_t *in, string_t **result); bool mod_length_modify(string_t *in, string_t **result); bool mod_quotewildcard_modify(string_t *in, string_t **result); /* Modifier objects */ const struct sieve_variables_modifier_def lower_modifier = { SIEVE_OBJECT("lower", &modifier_operand, EXT_VARIABLES_MODIFIER_LOWER), 40, mod_lower_modify }; const struct sieve_variables_modifier_def upper_modifier = { SIEVE_OBJECT("upper", &modifier_operand, EXT_VARIABLES_MODIFIER_UPPER), 40, mod_upper_modify }; const struct sieve_variables_modifier_def lowerfirst_modifier = { SIEVE_OBJECT ("lowerfirst", &modifier_operand, EXT_VARIABLES_MODIFIER_LOWERFIRST), 30, mod_lowerfirst_modify