tor  0.4.2.1-alpha-dev
conscache.h
1 /* Copyright (c) 2017-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 #ifndef TOR_CONSCACHE_H
5 #define TOR_CONSCACHE_H
6 
8 
11 
12 HANDLE_DECL(consensus_cache_entry, consensus_cache_entry_t, )
13 #define consensus_cache_entry_handle_free(h) \
14  FREE_AND_NULL(consensus_cache_entry_handle_t, \
15  consensus_cache_entry_handle_free_, (h))
16 
17 consensus_cache_t *consensus_cache_open(const char *subdir, int max_entries);
18 void consensus_cache_free_(consensus_cache_t *cache);
19 #define consensus_cache_free(cache) \
20  FREE_AND_NULL(consensus_cache_t, consensus_cache_free_, (cache))
21 struct sandbox_cfg_elem;
22 int consensus_cache_may_overallocate(consensus_cache_t *cache);
23 int consensus_cache_register_with_sandbox(consensus_cache_t *cache,
24  struct sandbox_cfg_elem **cfg);
25 void consensus_cache_unmap_lazy(consensus_cache_t *cache, time_t cutoff);
26 void consensus_cache_delete_pending(consensus_cache_t *cache,
27  int force);
28 int consensus_cache_get_n_filenames_available(consensus_cache_t *cache);
29 consensus_cache_entry_t *consensus_cache_add(consensus_cache_t *cache,
30  const struct config_line_t *labels,
31  const uint8_t *data,
32  size_t datalen);
33 
34 consensus_cache_entry_t *consensus_cache_find_first(
35  consensus_cache_t *cache,
36  const char *key,
37  const char *value);
38 
39 void consensus_cache_find_all(smartlist_t *out,
40  consensus_cache_t *cache,
41  const char *key,
42  const char *value);
43 void consensus_cache_filter_list(smartlist_t *lst,
44  const char *key,
45  const char *value);
46 
47 const char *consensus_cache_entry_get_value(const consensus_cache_entry_t *ent,
48  const char *key);
49 const struct config_line_t *consensus_cache_entry_get_labels(
50  const consensus_cache_entry_t *ent);
51 
52 void consensus_cache_entry_incref(consensus_cache_entry_t *ent);
53 void consensus_cache_entry_decref(consensus_cache_entry_t *ent);
54 
55 void consensus_cache_entry_mark_for_removal(consensus_cache_entry_t *ent);
56 void consensus_cache_entry_mark_for_aggressive_release(
58 int consensus_cache_entry_get_body(const consensus_cache_entry_t *ent,
59  const uint8_t **body_out,
60  size_t *sz_out);
61 
62 #ifdef TOR_UNIT_TESTS
63 int consensus_cache_entry_is_mapped(consensus_cache_entry_t *ent);
64 #endif
65 
66 #endif /* !defined(TOR_CONSCACHE_H) */
Macros for C weak-handle implementation.
Definition: conscache.c:27
unsigned max_entries
Definition: conscache.c:66