Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 107 lines (87 sloc) 3.585 kb
ec691ca @yangtse lib/*.h: use our standard naming scheme for header inclusion guards
yangtse authored
1 #ifndef HEADER_CURL_HASH_H
2 #define HEADER_CURL_HASH_H
ba4e69b @bagder updated source code boilerplate/header
authored
3 /***************************************************************************
c39858a @bagder Source cleanups. The major one being that we now _always_ use a Curl_add...
authored
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
8 * \___|\___/|_| \_\_____|
9 *
62f0f55 @bagder Robert Iakobashvili re-arranged the internal hash code to work with a cu...
authored
10 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
11 *
ba4e69b @bagder updated source code boilerplate/header
authored
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at http://curl.haxx.se/docs/copyright.html.
c39858a @bagder Source cleanups. The major one being that we now _always_ use a Curl_add...
authored
15 *
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
ba4e69b @bagder updated source code boilerplate/header
authored
18 * furnished to do so, under the terms of the COPYING file.
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
ba4e69b @bagder updated source code boilerplate/header
authored
23 ***************************************************************************/
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
24
5a053ff @yangtse build: fix circular header inclusion with other packages
yangtse authored
25 #include "curl_setup.h"
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
26
27 #include <stddef.h>
28
4a5aa66 @yangtse Revert changes relative to lib/*.[ch] recent renaming
yangtse authored
29 #include "llist.h"
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
30
62f0f55 @bagder Robert Iakobashvili re-arranged the internal hash code to work with a cu...
authored
31 /* Hash function prototype */
32 typedef size_t (*hash_function) (void* key,
33 size_t key_length,
34 size_t slots_num);
35
36 /*
37 Comparator function prototype. Compares two keys.
38 */
39 typedef size_t (*comp_function) (void* key1,
40 size_t key1_len,
41 void*key2,
42 size_t key2_len);
43
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
44 typedef void (*curl_hash_dtor)(void *);
45
043d70f @bagder Use plain structs and not typedef'ed ones in the hash and linked-list co...
authored
46 struct curl_hash {
47 struct curl_llist **table;
62f0f55 @bagder Robert Iakobashvili re-arranged the internal hash code to work with a cu...
authored
48
49 /* Hash function to be used for this hash table */
50 hash_function hash_func;
51
52 /* Comparator function to compare keys */
53 comp_function comp_func;
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
54 curl_hash_dtor dtor;
043d70f @bagder Use plain structs and not typedef'ed ones in the hash and linked-list co...
authored
55 int slots;
56 size_t size;
57 };
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
58
043d70f @bagder Use plain structs and not typedef'ed ones in the hash and linked-list co...
authored
59 struct curl_hash_element {
9ebcfe9 Speed up the hash code considerably, removing a bunch of legacy crud
Sterling Hughes authored
60 void *ptr;
61 char *key;
2cff251 @bagder Curl_resolv() now returns a different struct, and it contains a referenc...
authored
62 size_t key_len;
043d70f @bagder Use plain structs and not typedef'ed ones in the hash and linked-list co...
authored
63 };
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
64
d021f2e @linusnielsen Introducing a new persistent connection caching system using "bundles".
linusnielsen authored
65 struct curl_hash_iterator {
66 struct curl_hash *hash;
67 int slot_index;
68 struct curl_llist_element *current_element;
69 };
6de7dc5 @bagder Sterling Hughes' provided initial DNS cache source code.
authored
70
62f0f55 @bagder Robert Iakobashvili re-arranged the internal hash code to work with a cu...
authored
71 int Curl_hash_init(struct curl_hash *h,
72 int slots,
73 hash_function hfunc,
74 comp_function comparator,
75 curl_hash_dtor dtor);
76
77 struct curl_hash *Curl_hash_alloc(int slots,
78 hash_function hfunc,
79 comp_function comparator,
80 curl_hash_dtor dtor);
81
82 void *Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p);
83 int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len);
84 void *Curl_hash_pick(struct curl_hash *, void * key, size_t key_len);
043d70f @bagder Use plain structs and not typedef'ed ones in the hash and linked-list co...
authored
85 void Curl_hash_apply(struct curl_hash *h, void *user,
2cff251 @bagder Curl_resolv() now returns a different struct, and it contains a referenc...
authored
86 void (*cb)(void *user, void *ptr));
043d70f @bagder Use plain structs and not typedef'ed ones in the hash and linked-list co...
authored
87 int Curl_hash_count(struct curl_hash *h);
88 void Curl_hash_clean(struct curl_hash *h);
89 void Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
90 int (*comp)(void *, void *));
91 void Curl_hash_destroy(struct curl_hash *h);
9ebcfe9 Speed up the hash code considerably, removing a bunch of legacy crud
Sterling Hughes authored
92
62f0f55 @bagder Robert Iakobashvili re-arranged the internal hash code to work with a cu...
authored
93 size_t Curl_hash_str(void* key, size_t key_length, size_t slots_num);
94 size_t Curl_str_key_compare(void*k1, size_t key1_len, void*k2,
95 size_t key2_len);
96
d021f2e @linusnielsen Introducing a new persistent connection caching system using "bundles".
linusnielsen authored
97 void Curl_hash_start_iterate(struct curl_hash *hash,
98 struct curl_hash_iterator *iter);
99 struct curl_hash_element *
100 Curl_hash_next_element(struct curl_hash_iterator *iter);
101
102 void Curl_hash_print(struct curl_hash *h,
103 void (*func)(void *));
104
105
ec691ca @yangtse lib/*.h: use our standard naming scheme for header inclusion guards
yangtse authored
106 #endif /* HEADER_CURL_HASH_H */
Something went wrong with that request. Please try again.