From ea24147502dfa8babab2e44f0aae9285b92f2d26 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Mon, 7 Oct 2024 21:30:49 +0200
Subject: [PATCH] lib-sieve: sieve-storage - Add sieve_storage_hash()

---
 src/lib-sieve/sieve-storage-private.h |  1 +
 src/lib-sieve/sieve-storage.c         | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/lib-sieve/sieve-storage-private.h b/src/lib-sieve/sieve-storage-private.h
index 64bb8f138..6b1a45796 100644
--- a/src/lib-sieve/sieve-storage-private.h
+++ b/src/lib-sieve/sieve-storage-private.h
@@ -132,6 +132,7 @@ int sieve_storage_setup_bin_path(struct sieve_storage *storage, mode_t mode);
 
 int sieve_storage_cmp(const struct sieve_storage *storage1,
 		      const struct sieve_storage *storage2);
+unsigned int sieve_storage_hash(const struct sieve_storage *storage);
 
 /*
  * Active script
diff --git a/src/lib-sieve/sieve-storage.c b/src/lib-sieve/sieve-storage.c
index 5a8155a69..ea921ccf9 100644
--- a/src/lib-sieve/sieve-storage.c
+++ b/src/lib-sieve/sieve-storage.c
@@ -4,6 +4,7 @@
 #include "lib.h"
 #include "array.h"
 #include "str-sanitize.h"
+#include "hash.h"
 #include "home-expand.h"
 #include "eacces-error.h"
 #include "mkdir-parents.h"
@@ -854,6 +855,16 @@ int sieve_storage_cmp(const struct sieve_storage *storage1,
 	return null_strcmp(storage1->location, storage2->location);
 }
 
+unsigned int sieve_storage_hash(const struct sieve_storage *storage)
+{
+	unsigned int hash = 0;
+
+	hash ^= POINTER_CAST_TO(storage->storage_class, unsigned int);
+	hash ^= str_hash(storage->location);
+
+	return hash;
+}
+
 /*
  * Script access
  */
-- 
GitLab