You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bloom.h 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef __RSPAMD_BLOOM_H__
  2. #define __RSPAMD_BLOOM_H__
  3. #include "config.h"
  4. typedef struct rspamd_bloom_filter_s {
  5. size_t asize;
  6. gchar *a;
  7. size_t nfuncs;
  8. guint32 *seeds;
  9. } rspamd_bloom_filter_t;
  10. /*
  11. * Some random uint32 seeds for hashing
  12. */
  13. #define RSPAMD_DEFAULT_BLOOM_HASHES 8, 0x61782caaU, 0x79ab8141U, 0xe45ee2d1U, \
  14. 0xf97542d1U, 0x1e2623edU, 0xf5a23cfeU, 0xa41b2508U, 0x85abdce8U
  15. /*
  16. * Create new bloom filter
  17. * @param size length of bloom buffer
  18. * @param nfuncs number of hash functions
  19. * @param ... hash functions list
  20. */
  21. rspamd_bloom_filter_t * rspamd_bloom_create (size_t size, size_t nfuncs, ...);
  22. /*
  23. * Destroy bloom filter
  24. */
  25. void rspamd_bloom_destroy (rspamd_bloom_filter_t * bloom);
  26. /*
  27. * Add a string to bloom filter
  28. */
  29. gboolean rspamd_bloom_add (rspamd_bloom_filter_t * bloom, const gchar *s);
  30. /*
  31. * Delete a string from bloom filter
  32. */
  33. gboolean rspamd_bloom_del (rspamd_bloom_filter_t * bloom, const gchar *s);
  34. /*
  35. * Check whether this string is in bloom filter (algorithm produces FALSE-POSITIVES, so result must be checked if it is positive)
  36. */
  37. gboolean rspamd_bloom_check (rspamd_bloom_filter_t * bloom, const gchar *s);
  38. #endif