1 #ifndef SIEVE_EXTPROGRAMS_COMMON_H 2 #define SIEVE_EXTPROGRAMS_COMMON_H 3 4 #include "sieve-common.h" 5 6 /* 7 * Extension configuration 8 */ 9 10 enum sieve_extprograms_eol { 11 SIEVE_EXTPROGRAMS_EOL_CRLF = 0, 12 SIEVE_EXTPROGRAMS_EOL_LF 13 }; 14 15 struct sieve_extprograms_config { 16 const struct sieve_extension *copy_ext; 17 const struct sieve_extension *var_ext; 18 19 char *socket_dir; 20 char *bin_dir; 21 22 enum sieve_extprograms_eol default_input_eol; 23 24 unsigned int execute_timeout; 25 }; 26 27 struct sieve_extprograms_config *sieve_extprograms_config_init 28 (const struct sieve_extension *ext); 29 void sieve_extprograms_config_deinit 30 (struct sieve_extprograms_config **ext_config); 31 32 /* 33 * Extensions 34 */ 35 36 extern const struct sieve_extension_def sieve_ext_vnd_pipe; 37 extern const struct sieve_extension_def sieve_ext_vnd_filter; 38 extern const struct sieve_extension_def sieve_ext_vnd_execute; 39 40 /* 41 * Commands 42 */ 43 44 extern const struct sieve_command_def sieve_cmd_pipe; 45 extern const struct sieve_command_def sieve_cmd_filter; 46 extern const struct sieve_command_def sieve_cmd_execute; 47 48 /* 49 * Operations 50 */ 51 52 extern const struct sieve_operation_def sieve_opr_pipe; 53 extern const struct sieve_operation_def sieve_opr_filter; 54 extern const struct sieve_operation_def sieve_opr_execute; 55 56 /* 57 * Program name and arguments 58 */ 59 60 bool sieve_extprogram_arg_is_valid(string_t *arg); 61 bool sieve_extprogram_name_is_valid(string_t *name); 62 63 /* 64 * Command validation 65 */ 66 67 bool sieve_extprogram_command_validate 68 (struct sieve_validator *valdtr, struct sieve_command *cmd); 69 70 /* 71 * Common command operands 72 */ 73 74 int sieve_extprogram_command_read_operands 75 (const struct sieve_runtime_env *renv, sieve_size_t *address, 76 string_t **pname_r, struct sieve_stringlist **args_list_r); 77 78 /* 79 * Running external programs 80 */ 81 82 void sieve_extprogram_exec_error 83 (struct sieve_error_handler *ehandler, const char *location, 84 const char *fmt, ...) ATTR_FORMAT(3, 4); 85 86 struct sieve_extprogram *sieve_extprogram_create 87 (const struct sieve_extension *ext, const struct sieve_script_env *senv, 88 const struct sieve_message_data *msgdata, const char *action, 89 const char *program_name, const char * const *args, 90 enum sieve_error *error_r); 91 void sieve_extprogram_destroy(struct sieve_extprogram **_sprog); 92 93 void sieve_extprogram_set_output 94 (struct sieve_extprogram *sprog, struct ostream *output); 95 void sieve_extprogram_set_output_seekable 96 (struct sieve_extprogram *sprog); 97 struct istream *sieve_extprogram_get_output_seekable 98 (struct sieve_extprogram *sprog); 99 100 void sieve_extprogram_set_input 101 (struct sieve_extprogram *sprog, struct istream *input); 102 int sieve_extprogram_set_input_mail 103 (struct sieve_extprogram *sprog, struct mail *mail); 104 105 int sieve_extprogram_run(struct sieve_extprogram *sprog); 106 107 #endif 108