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.

fuzzy_backend.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*-
  2. * Copyright 2016 Vsevolod Stakhov
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef FUZZY_BACKEND_H_
  17. #define FUZZY_BACKEND_H_
  18. #include "config.h"
  19. #include "fuzzy_storage.h"
  20. struct rspamd_fuzzy_backend;
  21. /**
  22. * Open fuzzy backend
  23. * @param path file to open (legacy file will be converted automatically)
  24. * @param err error pointer
  25. * @return backend structure or NULL
  26. */
  27. struct rspamd_fuzzy_backend *rspamd_fuzzy_backend_open (const gchar *path,
  28. gboolean vacuum,
  29. GError **err);
  30. /**
  31. * Check specified fuzzy in the backend
  32. * @param backend
  33. * @param cmd
  34. * @return reply with probability and weight
  35. */
  36. struct rspamd_fuzzy_reply rspamd_fuzzy_backend_check (
  37. struct rspamd_fuzzy_backend *backend,
  38. const struct rspamd_fuzzy_cmd *cmd,
  39. gint64 expire);
  40. /**
  41. * Prepare storage for updates (by starting transaction)
  42. */
  43. gboolean rspamd_fuzzy_backend_prepare_update (struct rspamd_fuzzy_backend *backend);
  44. /**
  45. * Add digest to the database
  46. * @param backend
  47. * @param cmd
  48. * @return
  49. */
  50. gboolean rspamd_fuzzy_backend_add (
  51. struct rspamd_fuzzy_backend *backend,
  52. const struct rspamd_fuzzy_cmd *cmd);
  53. /**
  54. * Delete digest from the database
  55. * @param backend
  56. * @param cmd
  57. * @return
  58. */
  59. gboolean rspamd_fuzzy_backend_del (
  60. struct rspamd_fuzzy_backend *backend,
  61. const struct rspamd_fuzzy_cmd *cmd);
  62. /**
  63. * Commit updates to storage
  64. */
  65. gboolean rspamd_fuzzy_backend_finish_update (struct rspamd_fuzzy_backend *backend);
  66. /**
  67. * Sync storage
  68. * @param backend
  69. * @return
  70. */
  71. gboolean rspamd_fuzzy_backend_sync (struct rspamd_fuzzy_backend *backend,
  72. gint64 expire,
  73. gboolean clean_orphaned);
  74. /**
  75. * Close storage
  76. * @param backend
  77. */
  78. void rspamd_fuzzy_backend_close (struct rspamd_fuzzy_backend *backend);
  79. gsize rspamd_fuzzy_backend_count (struct rspamd_fuzzy_backend *backend);
  80. gsize rspamd_fuzzy_backend_expired (struct rspamd_fuzzy_backend *backend);
  81. const gchar * rspamd_fuzzy_backend_id (struct rspamd_fuzzy_backend *backend);
  82. #endif /* FUZZY_BACKEND_H_ */