From 60278d7991693f5a650e5c13032addc4bf27d94e Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sun, 17 Aug 2008 23:03:21 +0200
Subject: [PATCH] Cleaned up relational extension.

---
 .../relational/ext-relational-common.c        |  3 ++
 .../relational/ext-relational-common.h        | 40 +++++++++++++++----
 .../plugins/relational/ext-relational.c       | 11 ++---
 src/lib-sieve/plugins/relational/mcht-count.c |  6 ++-
 src/lib-sieve/plugins/relational/mcht-value.c |  3 ++
 5 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/src/lib-sieve/plugins/relational/ext-relational-common.c b/src/lib-sieve/plugins/relational/ext-relational-common.c
index a718a23b3..88c80a0db 100644
--- a/src/lib-sieve/plugins/relational/ext-relational-common.c
+++ b/src/lib-sieve/plugins/relational/ext-relational-common.c
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+
 /* Syntax:
  *   MATCH-TYPE =/ COUNT / VALUE
  *   COUNT = ":count" relational-match
diff --git a/src/lib-sieve/plugins/relational/ext-relational-common.h b/src/lib-sieve/plugins/relational/ext-relational-common.h
index 14c997ff7..195cf2fda 100644
--- a/src/lib-sieve/plugins/relational/ext-relational-common.h
+++ b/src/lib-sieve/plugins/relational/ext-relational-common.h
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+ 
 #ifndef __EXT_RELATIONAL_COMMON_H
 #define __EXT_RELATIONAL_COMMON_H
 
@@ -41,16 +44,17 @@ int ext_relational_my_id;
 extern const struct sieve_extension relational_extension;
 extern const struct sieve_match_type_extension relational_match_extension;
 
-bool mcht_relational_validate
-	(struct sieve_validator *validator, struct sieve_ast_argument **arg, 
-		struct sieve_match_type_context *ctx);
-int mcht_value_match
-    (struct sieve_match_context *mctx, const char *val, size_t val_size,
-        const char *key, size_t key_size, int key_index);
+/*
+ * Match types
+ */
+ 
+/* Registered for validation */ 
 
 extern const struct sieve_match_type value_match_type;
 extern const struct sieve_match_type count_match_type;
 
+/* Used in byte code */
+
 extern const struct sieve_match_type rel_match_count_gt;
 extern const struct sieve_match_type rel_match_count_ge;
 extern const struct sieve_match_type rel_match_count_lt;
@@ -65,6 +69,28 @@ extern const struct sieve_match_type rel_match_value_le;
 extern const struct sieve_match_type rel_match_value_eq;
 extern const struct sieve_match_type rel_match_value_ne;
 
+/*
+ * Operand
+ */
+ 
 extern const struct sieve_operand rel_match_type_operand;
 
-#endif
+
+/*
+ * Match type validation
+ */
+
+bool mcht_relational_validate
+	(struct sieve_validator *validator, struct sieve_ast_argument **arg, 
+		struct sieve_match_type_context *ctx);
+		
+/*
+ * Value match function (also used by :count)
+ */
+ 
+int mcht_value_match
+    (struct sieve_match_context *mctx, const char *val, size_t val_size,
+        const char *key, size_t key_size, int key_index);
+
+
+#endif /* __EXT_RELATIONAL_COMMON_H */
diff --git a/src/lib-sieve/plugins/relational/ext-relational.c b/src/lib-sieve/plugins/relational/ext-relational.c
index 26a4c9206..8570982de 100644
--- a/src/lib-sieve/plugins/relational/ext-relational.c
+++ b/src/lib-sieve/plugins/relational/ext-relational.c
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+
 /* Extension relational 
  * --------------------
  *
@@ -26,14 +29,12 @@
 #include "ext-relational-common.h"
 
 /* 
- * Forward declarations 
+ * Extension
  */
 
 static bool ext_relational_load(int ext_id);
 static bool ext_relational_validator_load(struct sieve_validator *validator);
 
-/* Extension definitions */
-
 int ext_relational_my_id;
 
 const struct sieve_extension relational_extension = { 
@@ -53,10 +54,6 @@ static bool ext_relational_load(int ext_id)
 	return TRUE;
 }
 
-/* 
- * Load extension into validator 
- */
-
 static bool ext_relational_validator_load(struct sieve_validator *validator)
 {
 	sieve_match_type_register(validator, &value_match_type); 
diff --git a/src/lib-sieve/plugins/relational/mcht-count.c b/src/lib-sieve/plugins/relational/mcht-count.c
index fe7bcc775..061648827 100644
--- a/src/lib-sieve/plugins/relational/mcht-count.c
+++ b/src/lib-sieve/plugins/relational/mcht-count.c
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+ 
 /* Match-type ':count' 
  */
 
@@ -5,7 +8,6 @@
 #include "str.h"
 
 #include "sieve-common.h"
-
 #include "sieve-ast.h"
 #include "sieve-code.h"
 #include "sieve-extensions.h"
@@ -32,7 +34,7 @@ static int mcht_count_match_deinit(struct sieve_match_context *mctx);
 /* 
  * Match-type objects
  */
-
+ 
 const struct sieve_match_type count_match_type = {
 	SIEVE_OBJECT("count", &rel_match_type_operand, RELATIONAL_COUNT),
 	FALSE, FALSE,
diff --git a/src/lib-sieve/plugins/relational/mcht-value.c b/src/lib-sieve/plugins/relational/mcht-value.c
index d9c121233..c259583db 100644
--- a/src/lib-sieve/plugins/relational/mcht-value.c
+++ b/src/lib-sieve/plugins/relational/mcht-value.c
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+
 #include "lib.h"
 #include "str.h"
 
-- 
GitLab