aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile13
-rw-r--r--antispam-plugin.c13
-rw-r--r--defconfig5
3 files changed, 22 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 5f1e362..9b015ae 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
# include config file
--include .config
+CONFIG ?= .config
+-include $(CONFIG)
# includes/flags we need for building a dovecot plugin
CFLAGS += -DHAVE_CONFIG_H
@@ -13,7 +14,7 @@ CFLAGS += -I$(DOVECOT)/src/lib-dict/
CFLAGS += -I$(DOVECOT)/src/imap/
# output name
-PLUGIN_NAME ?= lib90_antispam_plugin.so
+LIBRARY_NAME ?= lib90_$(PLUGINNAME)_plugin.so
# debug rules
ifeq ("$(DEBUG)", "stderr")
@@ -52,7 +53,7 @@ objs += signature.o
endif
# main make rules
-CFLAGS += -fPIC -shared -Wall
+CFLAGS += -fPIC -shared -Wall -DPLUGINNAME=$(PLUGINNAME)
CC ?= "gcc"
objs += antispam-plugin.o $(BACKEND).o
@@ -64,13 +65,13 @@ all: verify_config $(ALL)
$(CC) -c $(CFLAGS) -o $@ $<
plugin: $(objs)
- $(CC) $(CFLAGS) $(objs) -o $(PLUGIN_NAME) $(LDFLAGS)
+ $(CC) $(CFLAGS) $(objs) -o $(LIBRARY_NAME) $(LDFLAGS)
clean:
- rm -f $(PLUGIN_NAME) *.o *~
+ rm -f $(LIBRARY_NAME) *.o *~
install: all
- install -o root -g root -m 0660 $(PLUGIN_NAME) $(INSTALLDIR)/
+ install -o root -g root -m 0660 $(LIBRARY_NAME) $(INSTALLDIR)/
verify_config:
@if [ ! -r .config ]; then \
diff --git a/antispam-plugin.c b/antispam-plugin.c
index 1a8ee52..d737758 100644
--- a/antispam-plugin.c
+++ b/antispam-plugin.c
@@ -78,7 +78,14 @@ bool mailbox_is_unsure(struct mailbox *box)
return mailbox_in_list(box, unsure_folders);
}
-void antispam_plugin_init(void)
+#define __PLUGIN_FUNCTION(name, ioe) \
+ name ## _plugin_ ## ioe
+#define _PLUGIN_FUNCTION(name, ioe) \
+ __PLUGIN_FUNCTION(name, ioe)
+#define PLUGIN_FUNCTION(ioe) \
+ _PLUGIN_FUNCTION(PLUGINNAME, ioe)
+
+void PLUGIN_FUNCTION(init)(void)
{
char *tmp, **iter;
@@ -131,7 +138,7 @@ void antispam_plugin_init(void)
hook_mail_storage_created = antispam_mail_storage_created;
}
-void antispam_plugin_deinit(void)
+void PLUGIN_FUNCTION(deinit)(void)
{
hook_mail_storage_created = antispam_next_hook_mail_storage_created;
backend_exit();
@@ -139,4 +146,4 @@ void antispam_plugin_deinit(void)
}
/* put dovecot version we built against into plugin for checking */
-const char *antispam_plugin_version = PACKAGE_VERSION;
+const char *PLUGIN_FUNCTION(version) = PACKAGE_VERSION;
diff --git a/defconfig b/defconfig
index 31348dd..18e6f9a 100644
--- a/defconfig
+++ b/defconfig
@@ -40,3 +40,8 @@ INSTALLDIR=/usr/lib/dovecot/modules/imap/
# enable debugging to syslog or stderr
#DEBUG=stderr
#DEBUG=syslog
+
+# plugin name, change only if you need to rename the plugin
+# (because, for example, you need two instances for different
+# spam filters installed)
+PLUGINNAME=antispam