Tor  0.4.7.0-alpha-dev
fp_pair.h
Go to the documentation of this file.
1 /* Copyright (c) 2013-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 /**
5  * \file fp_pair.h
6  * \brief Header file for fp_pair.c.
7  **/
8 
9 #ifndef _TOR_FP_PAIR_H
10 #define _TOR_FP_PAIR_H
11 
12 /** A pair of digests created by dir_split_resource_info_fingerprint_pairs() */
13 typedef struct {
14  char first[DIGEST_LEN];
15  char second[DIGEST_LEN];
16 } fp_pair_t;
17 
18 /*
19  * Declare fp_pair_map_t functions and structs
20  */
21 
23 typedef struct fp_pair_map_t fp_pair_map_t;
25 
27 void * fp_pair_map_set(fp_pair_map_t *map, const fp_pair_t *key, void *val);
29  const char *first, const char *second,
30  void *val);
31 void * fp_pair_map_get(const fp_pair_map_t *map, const fp_pair_t *key);
33  const char *first, const char *second);
34 void * fp_pair_map_remove(fp_pair_map_t *map, const fp_pair_t *key);
35 void fp_pair_map_free_(fp_pair_map_t *map, void (*free_val)(void*));
36 #define fp_pair_map_free(map, free_val) do { \
37  fp_pair_map_free_((map), (free_val)); \
38  (map) = NULL; \
39  } while (0)
40 
41 int fp_pair_map_isempty(const fp_pair_map_t *map);
42 int fp_pair_map_size(const fp_pair_map_t *map);
45  fp_pair_map_iter_t *iter);
47  fp_pair_map_iter_t *iter);
49  fp_pair_t *key_out, void **val_out);
51 void fp_pair_map_assert_ok(const fp_pair_map_t *map);
52 
53 #undef DECLARE_MAP_FNS
54 
55 #endif /* !defined(_TOR_FP_PAIR_H) */
56 
#define DIGEST_LEN
Definition: digest_sizes.h:20
int fp_pair_map_isempty(const fp_pair_map_t *map)
Definition: fp_pair.c:221
void fp_pair_map_iter_get(fp_pair_map_iter_t *iter, fp_pair_t *key_out, void **val_out)
Definition: fp_pair.c:287
fp_pair_map_t * fp_pair_map_new(void)
Definition: fp_pair.c:69
void * fp_pair_map_get_by_digests(const fp_pair_map_t *map, const char *first, const char *second)
Definition: fp_pair.c:154
int fp_pair_map_size(const fp_pair_map_t *map)
Definition: fp_pair.c:232
void * fp_pair_map_remove(fp_pair_map_t *map, const fp_pair_t *key)
Definition: fp_pair.c:175
fp_pair_map_iter_t * fp_pair_map_iter_next(fp_pair_map_t *map, fp_pair_map_iter_t *iter)
Definition: fp_pair.c:255
int fp_pair_map_iter_done(fp_pair_map_iter_t *iter)
Definition: fp_pair.c:301
fp_pair_map_iter_t * fp_pair_map_iter_init(fp_pair_map_t *map)
Definition: fp_pair.c:243
void fp_pair_map_assert_ok(const fp_pair_map_t *map)
Definition: fp_pair.c:311
void * fp_pair_map_get(const fp_pair_map_t *map, const fp_pair_t *key)
Definition: fp_pair.c:133
fp_pair_map_iter_t * fp_pair_map_iter_next_rmv(fp_pair_map_t *map, fp_pair_map_iter_t *iter)
Definition: fp_pair.c:268
void fp_pair_map_free_(fp_pair_map_t *map, void(*free_val)(void *))
Definition: fp_pair.c:199
void * fp_pair_map_set(fp_pair_map_t *map, const fp_pair_t *key, void *val)
Definition: fp_pair.c:83
void * fp_pair_map_set_by_digests(fp_pair_map_t *map, const char *first, const char *second, void *val)
Definition: fp_pair.c:114
Definition: fp_pair.c:25