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_sqlite.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_wire.h"
  20. struct rspamd_fuzzy_backend_sqlite;
  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_sqlite *rspamd_fuzzy_backend_sqlite_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_sqlite_check (
  37. struct rspamd_fuzzy_backend_sqlite *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_sqlite_prepare_update (struct rspamd_fuzzy_backend_sqlite *backend,
  44. const gchar *source);
  45. /**
  46. * Add digest to the database
  47. * @param backend
  48. * @param cmd
  49. * @return
  50. */
  51. gboolean rspamd_fuzzy_backend_sqlite_add (struct rspamd_fuzzy_backend_sqlite *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_sqlite_del (
  60. struct rspamd_fuzzy_backend_sqlite *backend,
  61. const struct rspamd_fuzzy_cmd *cmd);
  62. /**
  63. * Commit updates to storage
  64. */
  65. gboolean rspamd_fuzzy_backend_sqlite_finish_update (struct rspamd_fuzzy_backend_sqlite *backend,
  66. const gchar *source, gboolean version_bump);
  67. /**
  68. * Sync storage
  69. * @param backend
  70. * @return
  71. */
  72. gboolean rspamd_fuzzy_backend_sqlite_sync (struct rspamd_fuzzy_backend_sqlite *backend,
  73. gint64 expire,
  74. gboolean clean_orphaned);
  75. /**
  76. * Close storage
  77. * @param backend
  78. */
  79. void rspamd_fuzzy_backend_sqlite_close (struct rspamd_fuzzy_backend_sqlite *backend);
  80. gsize rspamd_fuzzy_backend_sqlite_count (struct rspamd_fuzzy_backend_sqlite *backend);
  81. gint rspamd_fuzzy_backend_sqlite_version (struct rspamd_fuzzy_backend_sqlite *backend, const gchar *source);
  82. gsize rspamd_fuzzy_backend_sqlite_expired (struct rspamd_fuzzy_backend_sqlite *backend);
  83. const gchar * rspamd_fuzzy_sqlite_backend_id (struct rspamd_fuzzy_backend_sqlite *backend);
  84. #endif /* FUZZY_BACKEND_H_ */