From acf7285a2642550b806ce73c86a96bb1d030ff1c Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sun, 23 Jan 2011 13:39:50 +0100
Subject: [PATCH] Copy extension: added public interface for adding the :copy
 tag to new commands.

---
 src/lib-sieve/plugins/copy/Makefile.am      | 10 ++++++++++
 src/lib-sieve/plugins/copy/ext-copy.c       | 14 ++++++++++++++
 src/lib-sieve/plugins/copy/sieve-ext-copy.h | 21 +++++++++++++++++++++
 3 files changed, 45 insertions(+)
 create mode 100644 src/lib-sieve/plugins/copy/sieve-ext-copy.h

diff --git a/src/lib-sieve/plugins/copy/Makefile.am b/src/lib-sieve/plugins/copy/Makefile.am
index d2220d70a..5e6479640 100644
--- a/src/lib-sieve/plugins/copy/Makefile.am
+++ b/src/lib-sieve/plugins/copy/Makefile.am
@@ -6,3 +6,13 @@ AM_CPPFLAGS = \
 
 libsieve_ext_copy_la_SOURCES = \
 	ext-copy.c
+
+public_headers = \
+	sieve-ext-copy.h 
+
+headers =
+
+pkginc_libdir=$(dovecot_pkgincludedir)/sieve
+pkginc_lib_HEADERS = $(public_headers)
+noinst_HEADERS = $(headers)
+
diff --git a/src/lib-sieve/plugins/copy/ext-copy.c b/src/lib-sieve/plugins/copy/ext-copy.c
index 212e7748e..f45dd84f5 100644
--- a/src/lib-sieve/plugins/copy/ext-copy.c
+++ b/src/lib-sieve/plugins/copy/ext-copy.c
@@ -115,6 +115,20 @@ static const struct sieve_operand_def copy_side_effect_operand = {
 	&ext_side_effects
 };
 
+/*
+ * Tag registration
+ */
+
+void sieve_ext_copy_register_tag
+(struct sieve_validator *valdtr, const struct sieve_extension *copy_ext,
+	const char *command)
+{
+	if ( sieve_validator_extension_loaded(valdr, copy_ext) ) {
+		sieve_validator_register_external_tag
+			(valdtr, command, copy_ext, &copy_tag, SIEVE_OPT_SIDE_EFFECT);
+	}
+}
+
 /* 
  * Tag validation 
  */
diff --git a/src/lib-sieve/plugins/copy/sieve-ext-copy.h b/src/lib-sieve/plugins/copy/sieve-ext-copy.h
new file mode 100644
index 000000000..7b239572d
--- /dev/null
+++ b/src/lib-sieve/plugins/copy/sieve-ext-copy.h
@@ -0,0 +1,21 @@
+#ifndef __SIEVE_EXT_COPY_H
+#define __SIEVE_EXT_COPY_H
+
+/* sieve_ext_copy_get_extension():
+ *   Get the extension struct for the copy extension.
+ */
+static inline const struct sieve_extension *sieve_ext_copy_get_extension
+(struct sieve_instance *svinst)
+{
+	return sieve_extension_get_by_name(svinst, "copy");
+}
+
+/* sieve_ext_copy_register_tag():
+ *   Register the :copy tagged argument for a command other than fileinto and
+ *   redirect.
+ */
+void sieve_ext_copy_register_tag
+	(struct sieve_validator *valdtr, const struct sieve_extension *copy_ext,
+		const char *command);
+
+#endif /* __SIEVE_EXT_COPY_H */
-- 
GitLab