diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2011-05-03 19:26:38 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2011-05-03 19:26:38 +0200 |
commit | a1527ce7177df11a8ee1b46a0e7b64f0f0df234b (patch) | |
tree | 41f724c2a04b3582878d40dc451930e71a7b86aa /antispam-plugin.h | |
parent | c8a9a6550b84412f919b772a9cb8db1e3ef79d19 (diff) | |
parent | 808eaa49efe2dc2438ef98ddf4bac4cfd2898a3d (diff) | |
download | dovecot-antispam-master.tar.gz dovecot-antispam-master.tar.xz dovecot-antispam-master.zip |
Diffstat (limited to '')
-rw-r--r-- | antispam-plugin.h | 85 |
1 files changed, 46 insertions, 39 deletions
diff --git a/antispam-plugin.h b/antispam-plugin.h index 38a3be6..a06a1e9 100644 --- a/antispam-plugin.h +++ b/antispam-plugin.h @@ -29,53 +29,56 @@ enum classification { CLASS_SPAM, }; -void backend_init(pool_t pool); -void backend_exit(void); -/* - * Handle mail; parameters are - * - t: transaction context - * - ast: transaction context from backend_start() - * - mail: the message - * - wanted: the wanted classification determined by the user - */ -int backend_handle_mail(struct mailbox_transaction_context *t, - struct antispam_transaction_context *ast, - struct mail *mail, enum classification wanted); -struct antispam_transaction_context *backend_start(struct mailbox *box); -void backend_rollback(struct antispam_transaction_context *ast); -int backend_commit(struct mailbox_transaction_context *ctx, - struct antispam_transaction_context *ast); - -#ifdef CONFIG_DEBUG +struct backend { + void (*init)(pool_t pool); + void (*exit)(void); + /* + * Handle mail; parameters are + * - t: transaction context + * - ast: transaction context from backend_start() + * - mail: the message + * - wanted: the wanted classification determined by the user + */ + int (*handle_mail)(struct mailbox_transaction_context *t, + struct antispam_transaction_context *ast, + struct mail *mail, enum classification wanted); + struct antispam_transaction_context *(*start)(struct mailbox *box); + void (*rollback)(struct antispam_transaction_context *ast); + int (*commit)(struct mailbox_transaction_context *ctx, + struct antispam_transaction_context *ast); +}; + +/* the selected backend */ +extern struct backend *backend; + +/* possible backends */ +extern struct backend crm114_backend; +extern struct backend dspam_backend; +extern struct backend pipe_backend; +extern struct backend signature_backend; +extern struct backend spool2dir_backend; + +enum antispam_debug_target { + ADT_NONE, + ADT_STDERR, + ADT_SYSLOG, +}; + +extern enum antispam_debug_target debug_target; +extern int verbose_debug; + void debug(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); void debugv(char **args); -#else -static void debug(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); -static inline void debug(const char *fmt __attribute__((unused)), ...) -{ -} -static inline void debugv(char **args __attribute__((unused))) -{ -} -#endif - -#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE) -/* bit of an ugly short-cut */ -#define debug_verbose debug -#else -static void debug_verbose(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); -static inline void debug_verbose(const char *fmt __attribute__((unused)), ...) -{ -} -#endif +void debugv_not_stderr(char **args); +void debug_verbose(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); void antispam_mail_storage_created(struct mail_storage *storage); -void (*antispam_next_hook_mail_storage_created)(struct mail_storage *storage); +extern void (*antispam_next_hook_mail_storage_created)(struct mail_storage *storage); bool mailbox_is_spam(struct mailbox *box); bool mailbox_is_trash(struct mailbox *box); bool mailbox_is_unsure(struct mailbox *box); const char *get_setting(const char *name); -bool antispam_can_append_to_spam; +extern bool antispam_can_append_to_spam; bool keyword_is_spam(const char *keyword); extern bool need_keyword_hook; @@ -84,6 +87,10 @@ extern bool need_folder_hook; /* * Dovecot version compat code */ +#if DOVECOT_VERSION <= DOVECOT_VERSION_CODE(1, 1, 0) +#define mailbox_get_storage(s) mailbox_get_storage((struct mailbox *)s) +#define mailbox_get_name(s) mailbox_get_name((struct mailbox *)s) +#endif #if DOVECOT_VERSION_CODE(1, 1, 0) == DOVECOT_VERSION || DOVECOT_VERSION_CODE(1, 2, 0) == DOVECOT_VERSION #define __attr_unused__ ATTR_UNUSED |