dovecot-1.2-sieve: Added preliminary support for plugins and added support for installing development headers.
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Thu Dec 31 05:49:00 EET 2009
details: http://hg.rename-it.nl/dovecot-1.2-sieve/rev/66404c1a046f
changeset: 1171:66404c1a046f
user: Stephan Bosch <stephan at rename-it.nl>
date: Thu Dec 31 04:41:30 2009 +0100
description:
Added preliminary support for plugins and added support for installing development headers.
diffstat:
configure.in | 13 ++++
src/lib-sieve/Makefile.am | 12 +++-
src/lib-sieve/plugins/enotify/Makefile.am | 14 ++++-
src/lib-sieve/plugins/environment/Makefile.am | 15 ++++-
src/lib-sieve/plugins/variables/Makefile.am | 17 ++++-
src/lib-sieve/sieve.c | 79 ++++++++++++++++++++++++++
6 files changed, 141 insertions(+), 9 deletions(-)
diffs (249 lines):
diff -r 204eaac26e45 -r 66404c1a046f configure.in
--- a/configure.in Thu Dec 31 04:40:09 2009 +0100
+++ b/configure.in Thu Dec 31 04:41:30 2009 +0100
@@ -73,6 +73,16 @@
#
#
+AC_ARG_ENABLE(header-install,
+[ --enable-header-install Install development headers],
+ if test x$enableval = xno; then
+ want_headers=no
+ else
+ want_headers=yes
+ fi,
+ want_headers=no)
+AM_CONDITIONAL(INSTALL_HEADERS, test "$want_headers" = "yes")
+
AC_ARG_ENABLE(valgrind,
[AC_HELP_STRING([--enable-valgrind], [Enable Valgrind memory leak checks in testsuite [default=no]])],
if test x$enableval = xno || test x$enableval = xauto; then
@@ -97,6 +107,9 @@
AC_SUBST(dovecot_incdir)
AC_SUBST(moduledir)
+dovecot_pkgincludedir='$(includedir)/dovecot'
+AC_SUBST(dovecot_pkgincludedir)
+
AC_CONFIG_FILES([
Makefile
src/Makefile
diff -r 204eaac26e45 -r 66404c1a046f src/lib-sieve/Makefile.am
--- a/src/lib-sieve/Makefile.am Thu Dec 31 04:40:09 2009 +0100
+++ b/src/lib-sieve/Makefile.am Thu Dec 31 04:41:30 2009 +0100
@@ -7,7 +7,8 @@
-I$(dovecot_incdir)/src/lib \
-I$(dovecot_incdir)/src/lib-mail \
-I$(dovecot_incdir)/src/lib-storage \
- -I$(dovecot_incdir)/src/lib-imap
+ -I$(dovecot_incdir)/src/lib-imap \
+ -DMODULEDIR=\""$(moduledir)"\"
tests = \
tst-truefalse.c \
@@ -102,7 +103,7 @@
$(extensions) \
sieve.c
-noinst_HEADERS = \
+headers = \
rfc2822.h \
sieve-config.h \
sieve-types.h \
@@ -136,3 +137,10 @@
sieve-actions.h \
sieve-extensions.h \
sieve.h
+
+if INSTALL_HEADERS
+ pkginc_libdir=$(dovecot_pkgincludedir)/sieve
+ pkginc_lib_HEADERS = $(headers)
+else
+ noinst_HEADERS = $(headers)
+endif
diff -r 204eaac26e45 -r 66404c1a046f src/lib-sieve/plugins/enotify/Makefile.am
--- a/src/lib-sieve/plugins/enotify/Makefile.am Thu Dec 31 04:40:09 2009 +0100
+++ b/src/lib-sieve/plugins/enotify/Makefile.am Thu Dec 31 04:41:30 2009 +0100
@@ -29,8 +29,18 @@
$(var_modifiers) \
$(notify_methods)
-noinst_HEADERS = \
- sieve-ext-enotify.h \
+public_headers = \
+ sieve-ext-enotify.h
+
+headers = \
ext-enotify-limits.h \
ext-enotify-common.h
+if INSTALL_HEADERS
+ pkginc_libdir=$(dovecot_pkgincludedir)/sieve
+ pkginc_lib_HEADERS = $(public_headers)
+ noinst_HEADERS = $(headers)
+else
+ noinst_HEADERS = $(headers) $(public_headers)
+endif
+
diff -r 204eaac26e45 -r 66404c1a046f src/lib-sieve/plugins/environment/Makefile.am
--- a/src/lib-sieve/plugins/environment/Makefile.am Thu Dec 31 04:40:09 2009 +0100
+++ b/src/lib-sieve/plugins/environment/Makefile.am Thu Dec 31 04:41:30 2009 +0100
@@ -15,6 +15,17 @@
ext-environment-common.c \
ext-environment.c
-noinst_HEADERS = \
- ext-environment-common.h \
+public_headers = \
sieve-ext-environment.h
+
+headers = \
+ ext-environment-common.h
+
+if INSTALL_HEADERS
+ pkginc_libdir=$(dovecot_pkgincludedir)/sieve
+ pkginc_lib_HEADERS = $(public_headers)
+ noinst_HEADERS = $(headers)
+else
+ noinst_HEADERS = $(headers) $(public_headers)
+endif
+
diff -r 204eaac26e45 -r 66404c1a046f src/lib-sieve/plugins/variables/Makefile.am
--- a/src/lib-sieve/plugins/variables/Makefile.am Thu Dec 31 04:40:09 2009 +0100
+++ b/src/lib-sieve/plugins/variables/Makefile.am Thu Dec 31 04:41:30 2009 +0100
@@ -25,7 +25,10 @@
$(tsts) \
ext-variables.c
-noinst_HEADERS = \
+public_headers = \
+ sieve-ext-variables.h
+
+headers = \
ext-variables-common.h \
ext-variables-limits.h \
ext-variables-name.h \
@@ -33,5 +36,13 @@
ext-variables-arguments.h \
ext-variables-operands.h \
ext-variables-modifiers.h \
- ext-variables-dump.h \
- sieve-ext-variables.h
+ ext-variables-dump.h
+
+if INSTALL_HEADERS
+ pkginc_libdir=$(dovecot_pkgincludedir)/sieve
+ pkginc_lib_HEADERS = $(public_headers)
+ noinst_HEADERS = $(headers)
+else
+ noinst_HEADERS = $(headers) $(public_headers)
+endif
+
diff -r 204eaac26e45 -r 66404c1a046f src/lib-sieve/sieve.c
--- a/src/lib-sieve/sieve.c Thu Dec 31 04:40:09 2009 +0100
+++ b/src/lib-sieve/sieve.c Thu Dec 31 04:41:30 2009 +0100
@@ -6,6 +6,7 @@
#include "istream.h"
#include "buffer.h"
#include "eacces-error.h"
+#include "module-dir.h"
#include "sieve-limits.h"
#include "sieve-settings.h"
@@ -34,6 +35,81 @@
#include <stdio.h>
#include <dirent.h>
+/*
+ * Plugin support
+ */
+
+static struct module *sieve_modules = NULL;
+static int sieve_modules_refcount = 0;
+
+static void sieve_plugins_load(struct sieve_instance *svinst)
+{
+ struct module *module;
+
+ /* Physically load modules */
+
+ /* FIXME: sieve plugins may/cannot differ between Sieve instances */
+
+ if ( sieve_modules == NULL ) {
+ const char *plugins = sieve_setting_get(svinst, "sieve_plugins");
+
+ if ( plugins != NULL && *plugins != '\0' ) {
+ const char *plugin_dir = sieve_setting_get(svinst, "sieve_plugin_dir");
+
+ if ( plugin_dir == NULL || *plugin_dir == '\0' )
+ plugin_dir = MODULEDIR"/sieve";
+
+ sieve_modules = module_dir_load(plugin_dir, plugins, TRUE, SIEVE_VERSION);
+ }
+ }
+
+ sieve_modules_refcount++;
+
+ /* Call plugin load functions for this instance */
+
+ module = sieve_modules;
+ while ( module != NULL ) {
+ void (*load_func)(struct sieve_instance *svinst);
+
+ load_func = module_get_symbol
+ (module, t_strdup_printf("%s_load", module->name));
+ if ( load_func != NULL ) {
+ load_func(svinst);
+ }
+
+ module = module->next;
+ }
+}
+
+static void sieve_plugins_unload(struct sieve_instance *svinst)
+{
+ struct module *module;
+
+ /* Call plugin unload functions for this instance */
+
+ module = sieve_modules;
+ while ( module != NULL ) {
+ void (*unload_func)(struct sieve_instance *svinst);
+
+ unload_func = module_get_symbol
+ (module, t_strdup_printf("%s_unload", module->name));
+ if ( unload_func != NULL ) {
+ unload_func(svinst);
+ }
+
+ module = module->next;
+ }
+
+ /* Physically unload modules */
+
+ i_assert(sieve_modules_refcount > 0);
+
+ if ( --sieve_modules_refcount != 0 )
+ return;
+
+ module_dir_unload(&sieve_modules);
+}
+
/*
* Main Sieve library interface
*/
@@ -80,11 +156,14 @@
return NULL;
}
+ sieve_plugins_load(svinst);
+
return svinst;
}
void sieve_deinit(struct sieve_instance **svinst)
{
+ sieve_plugins_unload(*svinst);
sieve_extensions_deinit(*svinst);
pool_unref(&(*svinst)->pool);
More information about the dovecot-cvs
mailing list