aboutsummaryrefslogtreecommitdiffstats
path: root/src/bloom.h
blob: e97b0aaee01ffc021d02cf105b9e717b256dc730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef __RSPAMD_BLOOM_H__
#define __RSPAMD_BLOOM_H__

#include "config.h"

typedef unsigned int (*hashfunc_t) (const char *);

typedef struct bloom_filter_s {
	size_t          asize;
	unsigned char  *a;
	size_t          nfuncs;
	hashfunc_t     *funcs;
} bloom_filter_t;

/* Hash functions */
unsigned int bloom_sax_hash (const char *key);
unsigned int bloom_sdbm_hash (const char *key);
unsigned int bloom_fnv_hash (const char *key);
unsigned int bloom_rs_hash (const char *key);
unsigned int bloom_js_hash (const char *key);
unsigned int bloom_elf_hash (const char *key);
unsigned int bloom_bkdr_hash (const char *key);
unsigned int bloom_ap_hash (const char *key);

#define DEFAULT_BLOOM_HASHES 8, bloom_sax_hash, bloom_sdbm_hash, bloom_fnv_hash, bloom_rs_hash, bloom_js_hash, bloom_elf_hash, bloom_bkdr_hash, bloom_ap_hash

bloom_filter_t* bloom_create (size_t size, size_t nfuncs, ...);
void bloom_destroy (bloom_filter_t * bloom);
gboolean bloom_add (bloom_filter_t * bloom, const char *s);
gboolean bloom_del (bloom_filter_t * bloom, const char *s);
gboolean bloom_check (bloom_filter_t * bloom, const char *s);

#endif