aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/bloom.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-04-21 16:25:51 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-04-21 16:25:51 +0100
commit61555065f3d1c8badcc9573691232f1b6e42988c (patch)
tree563d5b7cb8c468530f7e79c4da0a75267b1184e1 /src/libutil/bloom.h
parentad5bf825b7f33bc10311673991f0cc888e69c0b1 (diff)
downloadrspamd-61555065f3d1c8badcc9573691232f1b6e42988c.tar.gz
rspamd-61555065f3d1c8badcc9573691232f1b6e42988c.zip
Rework project structure, remove trash files.
Diffstat (limited to 'src/libutil/bloom.h')
-rw-r--r--src/libutil/bloom.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/libutil/bloom.h b/src/libutil/bloom.h
new file mode 100644
index 000000000..380143c80
--- /dev/null
+++ b/src/libutil/bloom.h
@@ -0,0 +1,48 @@
+#ifndef __RSPAMD_BLOOM_H__
+#define __RSPAMD_BLOOM_H__
+
+#include "config.h"
+
+typedef struct rspamd_bloom_filter_s {
+ size_t asize;
+ gchar *a;
+ size_t nfuncs;
+ guint32 *seeds;
+} rspamd_bloom_filter_t;
+
+
+/*
+ * Some random uint32 seeds for hashing
+ */
+#define RSPAMD_DEFAULT_BLOOM_HASHES 8, 0x61782caaU, 0x79ab8141U, 0xe45ee2d1U, \
+ 0xf97542d1U, 0x1e2623edU, 0xf5a23cfeU, 0xa41b2508U, 0x85abdce8U
+
+/*
+ * Create new bloom filter
+ * @param size length of bloom buffer
+ * @param nfuncs number of hash functions
+ * @param ... hash functions list
+ */
+rspamd_bloom_filter_t* rspamd_bloom_create (size_t size, size_t nfuncs, ...);
+
+/*
+ * Destroy bloom filter
+ */
+void rspamd_bloom_destroy (rspamd_bloom_filter_t * bloom);
+
+/*
+ * Add a string to bloom filter
+ */
+gboolean rspamd_bloom_add (rspamd_bloom_filter_t * bloom, const gchar *s);
+
+/*
+ * Delete a string from bloom filter
+ */
+gboolean rspamd_bloom_del (rspamd_bloom_filter_t * bloom, const gchar *s);
+
+/*
+ * Check whether this string is in bloom filter (algorithm produces FALSE-POSITIVES, so result must be checked if it is positive)
+ */
+gboolean rspamd_bloom_check (rspamd_bloom_filter_t * bloom, const gchar *s);
+
+#endif