static int cmd_test_config_reload_operation_execute (const struct sieve_runtime_env *renv, sieve_size_t *address) { const struct sieve_extension *ext; int opt_code = 0; string_t *extension = NULL; int ret; /* * Read operands */ /* Optional operands */ for (;;) { int opt; if ( (opt=sieve_opr_optional_read(renv, address, &opt_code)) < 0 ) return SIEVE_EXEC_BIN_CORRUPT; if ( opt == 0 ) break; switch ( opt_code ) { case OPT_EXTENSION: ret = sieve_opr_string_read(renv, address, "extension", &extension); break; default: sieve_runtime_trace_error(renv, "unknown optional operand"); ret = SIEVE_EXEC_BIN_CORRUPT; } if ( ret <= 0 ) return ret; } /* * Perform operation */ if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_COMMANDS) ) { sieve_runtime_trace(renv, 0, "testsuite: test_config_reload command"); sieve_runtime_trace_descend(renv); } if ( extension == NULL ) { if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_COMMANDS) ) { sieve_runtime_trace(renv, 0, "reload configuration for sieve engine"); } sieve_settings_load(renv->svinst); } else { if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_COMMANDS) ) { sieve_runtime_trace(renv, 0, "reload configuration for extension `%s'", str_c(extension)); } ext = sieve_extension_get_by_name(renv->svinst, str_c(extension)); if ( ext == NULL ) { testsuite_test_failf("test_config_reload: " "unknown extension '%s'", str_c(extension)); return SIEVE_EXEC_OK; } sieve_extension_reload(ext); } return SIEVE_EXEC_OK; }
static int cmd_test_imap_metadata_operation_execute (const struct sieve_runtime_env *renv, sieve_size_t *address) { const struct sieve_operation *oprtn = renv->oprtn; int opt_code = 0; string_t *mailbox = NULL, *annotation = NULL, *value = NULL; int ret; /* * Read operands */ /* Optional operands */ for (;;) { int opt; if ( (opt=sieve_opr_optional_read(renv, address, &opt_code)) < 0 ) return SIEVE_EXEC_BIN_CORRUPT; if ( opt == 0 ) break; switch ( opt_code ) { case OPT_MAILBOX: ret = sieve_opr_string_read(renv, address, "mailbox", &mailbox); break; default: sieve_runtime_trace_error(renv, "unknown optional operand"); ret = SIEVE_EXEC_BIN_CORRUPT; } if ( ret <= 0 ) return ret; } /* Fixed operands */ if ( (ret=sieve_opr_string_read (renv, address, "annotation", &annotation)) <= 0 ) return ret; if ( (ret=sieve_opr_string_read (renv, address, "value", &value)) <= 0 ) return ret; /* * Perform operation */ if ( sieve_operation_is(oprtn, test_imap_metadata_set_operation) ) { if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_COMMANDS) ) { sieve_runtime_trace(renv, 0, "testsuite/test_imap_metadata_set command"); sieve_runtime_trace_descend(renv); if (mailbox == NULL) { sieve_runtime_trace(renv, 0, "set server annotation `%s'", str_c(annotation)); } else { sieve_runtime_trace(renv, 0, "set annotation `%s' for mailbox `%s'", str_c(annotation), str_c(mailbox)); } } if (testsuite_mailstore_set_imap_metadata (( mailbox == NULL ? NULL : str_c(mailbox) ), str_c(annotation), str_c(value)) < 0) return SIEVE_EXEC_FAILURE; } return SIEVE_EXEC_OK; }
static int cmd_report_operation_execute (const struct sieve_runtime_env *renv, sieve_size_t *address) { struct act_report_data *act; string_t *fbtype, *message, *to_address; const char *norm_address, *feedback_type, *error; int opt_code = 0, ret = 0; bool headers_only = FALSE; pool_t pool; /* * Read operands */ /* Optional operands */ for (;;) { int opt; if ( (opt=sieve_opr_optional_read(renv, address, &opt_code)) < 0 ) return SIEVE_EXEC_BIN_CORRUPT; if ( opt == 0 ) break; switch ( opt_code ) { case OPT_HEADERS_ONLY: headers_only = TRUE; break; default: sieve_runtime_trace_error(renv, "unknown optional operand"); return SIEVE_EXEC_BIN_CORRUPT; } } /* Fixed operands */ if ( (ret=sieve_opr_string_read (renv, address, "feedback-type", &fbtype)) <= 0 ) return ret; if ( (ret=sieve_opr_string_read (renv, address, "message", &message)) <= 0 ) return ret; if ( (ret=sieve_opr_string_read (renv, address, "address", &to_address)) <= 0 ) return ret; /* * Perform operation */ /* Verify and trim feedback type */ feedback_type = ext_vnd_report_parse_feedback_type(str_c(fbtype)); if ( feedback_type == NULL ) { sieve_runtime_error(renv, NULL, "specified report feedback type `%s' is invalid", str_sanitize(str_c(fbtype), 256)); return SIEVE_EXEC_FAILURE; } /* Verify and normalize the address to 'local_part@domain' */ norm_address = sieve_address_normalize(to_address, &error); if ( norm_address == NULL ) { sieve_runtime_error(renv, NULL, "specified report address `%s' is invalid: %s", str_sanitize(str_c(to_address), 256), error); return SIEVE_EXEC_FAILURE; } /* Trace */ if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_ACTIONS) ) { sieve_runtime_trace(renv, 0, "report action"); sieve_runtime_trace_descend(renv); sieve_runtime_trace(renv, 0, "report incoming message as `%s' to address `%s'", str_sanitize(str_c(fbtype), 32), str_sanitize(norm_address, 80)); } /* Add report action to the result */ pool = sieve_result_pool(renv->result); act = p_new(pool, struct act_report_data, 1); act->headers_only = headers_only; act->feedback_type = p_strdup(pool, feedback_type); act->message = p_strdup(pool, str_c(message)); act->to_address = p_strdup(pool, norm_address); if ( sieve_result_add_action(renv, NULL, &act_report, NULL, (void *) act, 0, TRUE) < 0 ) return SIEVE_EXEC_FAILURE; return SIEVE_EXEC_OK; }