aboutsummaryrefslogtreecommitdiffstats
path: root/antispam-plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'antispam-plugin.c')
-rw-r--r--antispam-plugin.c59
1 files changed, 54 insertions, 5 deletions
diff --git a/antispam-plugin.c b/antispam-plugin.c
index 455668d..bbcc0e6 100644
--- a/antispam-plugin.c
+++ b/antispam-plugin.c
@@ -73,14 +73,17 @@ static char **trash_folders[] = { NULL, NULL, NULL };
static char **spam_folders[] = { default_spam_folders,NULL, NULL };
static char **unsure_folders[] = { NULL, NULL, NULL };
+void (*antispam_next_hook_mail_storage_created)(struct mail_storage *storage);
bool antispam_can_append_to_spam = FALSE;
static char **spam_keywords = NULL;
bool need_keyword_hook;
bool need_folder_hook;
+struct backend *backend = NULL;
+
/* lower-case string, but keep modified UTF7 unchanged */
-void lowercase_string(const char *in, char *out)
+static void lowercase_string(const char *in, char *out)
{
char ch;
@@ -248,8 +251,8 @@ const char *get_setting(const char *name)
return env;
}
-int parse_folder_setting(const char *setting, char ***strings,
- const char *display_name)
+static int parse_folder_setting(const char *setting, char ***strings,
+ const char *display_name)
{
const char *tmp;
int cnt = 0;
@@ -297,8 +300,33 @@ void PLUGIN_FUNCTION(init)(void)
char * const *iter;
int spam_folder_count;
+ debug_target = ADT_NONE;
+ verbose_debug = 0;
+
+ tmp = get_setting("DEBUG_TARGET");
+ if (tmp) {
+ if (strcmp(tmp, "syslog") == 0)
+ debug_target = ADT_SYSLOG;
+ else if (strcmp(tmp, "stderr") == 0)
+ debug_target = ADT_STDERR;
+ else
+ exit(4);
+ }
+
debug("plugin initialising (%s)\n", ANTISPAM_VERSION);
+ tmp = get_setting("VERBOSE_DEBUG");
+ if (tmp) {
+ char *endp;
+ unsigned long val = strtoul(tmp, &endp, 10);
+ if (*endp || val >= 2) {
+ debug("Invalid verbose_debug setting");
+ exit(5);
+ }
+ verbose_debug = val;
+ debug_verbose("verbose debug enabled");
+ }
+
global_pool = pool_alloconly_create("antispam-pool", 1024);
parse_folder_setting("TRASH", trash_folders, "trash");
@@ -323,11 +351,32 @@ void PLUGIN_FUNCTION(init)(void)
}
}
+ tmp = get_setting("BACKEND");
+ if (tmp) {
+ if (strcmp(tmp, "crm114") == 0)
+ backend = &crm114_backend;
+ else if (strcmp(tmp, "dspam") == 0)
+ backend = &dspam_backend;
+ else if (strcmp(tmp, "pipe") == 0)
+ backend = &pipe_backend;
+ else if (strcmp(tmp, "signature") == 0)
+ backend = &signature_backend;
+ else if (strcmp(tmp, "spool2dir") == 0)
+ backend = &spool2dir_backend;
+ else {
+ debug("selected invalid backend!\n");
+ exit(3);
+ }
+ } else {
+ debug("no backend selected!\n");
+ exit(2);
+ }
+
/* set spam_folders to empty to only allow keywords */
need_folder_hook = spam_folder_count > 0;
need_keyword_hook = !!spam_keywords;
- backend_init(global_pool);
+ backend->init(global_pool);
antispam_next_hook_mail_storage_created = hook_mail_storage_created;
hook_mail_storage_created = antispam_mail_storage_created;
@@ -336,7 +385,7 @@ void PLUGIN_FUNCTION(init)(void)
void PLUGIN_FUNCTION(deinit)(void)
{
hook_mail_storage_created = antispam_next_hook_mail_storage_created;
- backend_exit();
+ backend->exit();
mempool_unref(&global_pool);
}