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

Variables/Include: added support for dumping variables declared in extension scopes.

parent 631fb839
No related branches found
No related tags found
No related merge requests found
Next (in order of descending priority/precedence):
* Finish the test suite for the base functionality
* Improve debugging and error handling:
- Variables: dump variable identifiers in stead of storage indexes
* Make sure cmusieve can be replaced seamlessly with the new plugin.
* Final issues:
- FIXME hunting
- Fix amd64 logging segfault
- Fix/Report issues listed in 'doc/rfc/RFC Controversy.txt'
......
......@@ -411,3 +411,16 @@ bool ext_include_binary_dump(struct sieve_dumptime_env *denv)
return TRUE;
}
bool ext_include_code_dump
(const struct sieve_dumptime_env *denv, sieve_size_t *address ATTR_UNUSED)
{
struct sieve_binary *sbin = denv->sbin;
struct ext_include_binary_context *binctx =
ext_include_binary_get_context(sbin);
sieve_ext_variables_dump_set_scope(denv, &include_extension, binctx->global_vars);
return TRUE;
}
......@@ -56,6 +56,8 @@ unsigned int ext_include_binary_script_get_count
*/
bool ext_include_binary_dump(struct sieve_dumptime_env *denv);
bool ext_include_code_dump
(const struct sieve_dumptime_env *denv, sieve_size_t *address ATTR_UNUSED);
#endif /* __EXT_INCLUDE_BINARY_H */
......@@ -67,7 +67,7 @@ const struct sieve_extension include_extension = {
ext_include_interpreter_load,
ext_include_binary_load,
ext_include_binary_dump,
NULL,
ext_include_code_dump,
SIEVE_EXT_DEFINE_OPERATIONS(ext_include_operations),
SIEVE_EXT_DEFINE_NO_OPERANDS
};
......
......@@ -18,7 +18,28 @@
struct ext_variables_dump_context {
struct sieve_variable_scope *main_scope;
};
ARRAY_DEFINE(ext_scopes, struct sieve_variable_scope *);
};
static struct ext_variables_dump_context *ext_variables_dump_get_context
(const struct sieve_dumptime_env *denv)
{
struct sieve_code_dumper *dumper = denv->cdumper;
struct ext_variables_dump_context *dctx = sieve_dump_extension_get_context
(dumper, &variables_extension);
pool_t pool;
if ( dctx == NULL ) {
/* Create dumper context */
pool = sieve_code_dumper_pool(dumper);
dctx = p_new(pool, struct ext_variables_dump_context, 1);
p_array_init(&dctx->ext_scopes, pool, sieve_extensions_get_count());
sieve_dump_extension_set_context(dumper, &variables_extension, dctx);
}
return dctx;
}
bool ext_variables_code_dump
(const struct sieve_dumptime_env *denv, sieve_size_t *address)
......@@ -59,16 +80,25 @@ bool ext_variables_code_dump
(void) sieve_variable_scope_declare(main_scope, str_c(identifier));
}
/* Create dumper context */
dctx = p_new(sieve_code_dumper_pool(dumper),
struct ext_variables_dump_context, 1);
dctx = ext_variables_dump_get_context(denv);
dctx->main_scope = main_scope;
sieve_dump_extension_set_context(dumper, &variables_extension, dctx);
return TRUE;
}
/*
* Scope registry
*/
void sieve_ext_variables_dump_set_scope
(const struct sieve_dumptime_env *denv, const struct sieve_extension *ext,
struct sieve_variable_scope *scope)
{
struct ext_variables_dump_context *dctx = ext_variables_dump_get_context(denv);
array_idx_set(&dctx->ext_scopes, (unsigned int) *ext->id, &scope);
}
/*
* Variable identifier dump
*/
......@@ -77,15 +107,27 @@ const char *ext_variables_dump_get_identifier
(const struct sieve_dumptime_env *denv, const struct sieve_extension *ext,
unsigned int index)
{
struct sieve_code_dumper *dumper = denv->cdumper;
struct ext_variables_dump_context *dctx = sieve_dump_extension_get_context
(dumper, &variables_extension);
struct ext_variables_dump_context *dctx = ext_variables_dump_get_context(denv);
struct sieve_variable_scope *scope;
struct sieve_variable *var;
if ( ext != NULL )
if ( ext == NULL )
scope = dctx->main_scope;
else {
struct sieve_variable_scope *const *ext_scope;
int ext_id = *ext->id;
if ( ext_id < 0 || ext_id >= (int) array_count(&dctx->ext_scopes) )
return NULL;
ext_scope = array_idx(&dctx->ext_scopes, (unsigned int) ext_id);
scope = *ext_scope;
}
if ( scope == NULL )
return NULL;
var = sieve_variable_scope_get_indexed(dctx->main_scope, index);
var = sieve_variable_scope_get_indexed(scope, index);
return var->identifier;
}
......
......@@ -151,4 +151,12 @@ struct sieve_variables_modifier {
void sieve_variables_modifier_register
(struct sieve_validator *valdtr, const struct sieve_variables_modifier *smodf);
/*
* Code dumping
*/
void sieve_ext_variables_dump_set_scope
(const struct sieve_dumptime_env *denv, const struct sieve_extension *ext,
struct sieve_variable_scope *scope);
#endif /* __SIEVE_EXT_VARIABLES_H */
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.