conscache.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Copyright (c) 2017, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef TOR_CONSCACHE_H
  4. #define TOR_CONSCACHE_H
  5. #include "handles.h"
  6. typedef struct consensus_cache_entry_t consensus_cache_entry_t;
  7. typedef struct consensus_cache_t consensus_cache_t;
  8. HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, )
  9. #define consensus_cache_entry_handle_free(h) \
  10. FREE_AND_NULL(consensus_cache_entry_handle_t, consensus_cache_entry_handle_free_, (h))
  11. consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
  12. void consensus_cache_free_(consensus_cache_t *cache);
  13. #define consensus_cache_free(cache) FREE_AND_NULL(consensus_cache_t, consensus_cache_free_, (cache))
  14. struct sandbox_cfg_elem;
  15. int consensus_cache_may_overallocate(consensus_cache_t *cache);
  16. int consensus_cache_register_with_sandbox(consensus_cache_t *cache,
  17. struct sandbox_cfg_elem **cfg);
  18. void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
  19. void consensus_cache_delete_pending(consensus_cache_t *cache,
  20. int force);
  21. int consensus_cache_get_n_filenames_available(consensus_cache_t *cache);
  22. consensus_cache_entry_t *consensus_cache_add(consensus_cache_t *cache,
  23. const config_line_t *labels,
  24. const uint8_t *data,
  25. size_t datalen);
  26. consensus_cache_entry_t *consensus_cache_find_first(
  27. consensus_cache_t *cache,
  28. const char *key,
  29. const char *value);
  30. void consensus_cache_find_all(smartlist_t *out,
  31. consensus_cache_t *cache,
  32. const char *key,
  33. const char *value);
  34. void consensus_cache_filter_list(smartlist_t *lst,
  35. const char *key,
  36. const char *value);
  37. const char *consensus_cache_entry_get_value(const consensus_cache_entry_t *ent,
  38. const char *key);
  39. const config_line_t *consensus_cache_entry_get_labels(
  40. const consensus_cache_entry_t *ent);
  41. void consensus_cache_entry_incref(consensus_cache_entry_t *ent);
  42. void consensus_cache_entry_decref(consensus_cache_entry_t *ent);
  43. void consensus_cache_entry_mark_for_removal(consensus_cache_entry_t *ent);
  44. void consensus_cache_entry_mark_for_aggressive_release(
  45. consensus_cache_entry_t *ent);
  46. int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent,
  47. const uint8_t **body_out,
  48. size_t *sz_out);
  49. #ifdef TOR_UNIT_TESTS
  50. int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent);
  51. #endif
  52. #endif /* !defined(TOR_CONSCACHE_H) */