struct ext_ihave_binary_context *ext_ihave_binary_init (const struct sieve_extension *this_ext, struct sieve_binary *sbin, struct sieve_ast *ast) { struct ext_ihave_ast_context *ast_ctx = ext_ihave_get_ast_context(this_ext, ast); struct ext_ihave_binary_context *binctx; const char *const *exts; unsigned int i, count; binctx = ext_ihave_binary_get_context(this_ext, sbin); exts = array_get(&ast_ctx->missing_extensions, &count); if ( count > 0 ) { pool_t pool = sieve_binary_pool(sbin); if ( binctx->block == NULL ) binctx->block = sieve_binary_extension_create_block(sbin, this_ext); for ( i = 0; i < count; i++ ) { const char *ext_name = p_strdup(pool, exts[i]); array_append(&binctx->missing_extensions, &ext_name, 1); } } return binctx; }
static bool ext_ihave_binary_save (const struct sieve_extension *ext, struct sieve_binary *sbin, void *context) { struct ext_ihave_binary_context *binctx = (struct ext_ihave_binary_context *) context; const char *const *exts; unsigned int count, i; exts = array_get(&binctx->missing_extensions, &count); if ( binctx->block != NULL ) sieve_binary_block_clear(binctx->block); if ( count > 0 ) { if ( binctx->block == NULL ) binctx->block = sieve_binary_extension_create_block(sbin, ext); sieve_binary_emit_unsigned(binctx->block, count); for ( i = 0; i < count; i++ ) { sieve_binary_emit_cstring(binctx->block, exts[i]); } } return TRUE; }
struct ext_include_binary_context *ext_include_binary_init (const struct sieve_extension *this_ext, struct sieve_binary *sbin, struct sieve_ast *ast) { struct ext_include_ast_context *ast_ctx = ext_include_get_ast_context(this_ext, ast); struct ext_include_binary_context *ctx; /* Get/create our context from the binary we are working on */ ctx = ext_include_binary_get_context(this_ext, sbin); /* Create dependency block */ if ( ctx->dependency_block == 0 ) ctx->dependency_block = sieve_binary_extension_create_block(sbin, this_ext); if ( ctx->global_vars == NULL ) { ctx->global_vars = sieve_variable_scope_binary_create(ast_ctx->global_vars); sieve_variable_scope_binary_ref(ctx->global_vars); } return ctx; }