1 #ifndef HEADER_CURL_HASH_H
2 #define HEADER_CURL_HASH_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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
18 * furnished to do so, under the terms of the COPYING file.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
25 #include "curl_setup.h"
31 /* Hash function prototype */
32 typedef size_t (*hash_function) (void* key,
37 Comparator function prototype. Compares two keys.
39 typedef size_t (*comp_function) (void* key1,
44 typedef void (*curl_hash_dtor)(void *);
47 struct curl_llist **table;
49 /* Hash function to be used for this hash table */
50 hash_function hash_func;
52 /* Comparator function to compare keys */
53 comp_function comp_func;
59 struct curl_hash_element {
65 struct curl_hash_iterator {
66 struct curl_hash *hash;
68 struct curl_llist_element *current_element;
71 int Curl_hash_init(struct curl_hash *h,
74 comp_function comparator,
77 struct curl_hash *Curl_hash_alloc(int slots,
79 comp_function comparator,
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);
85 void Curl_hash_apply(struct curl_hash *h, void *user,
86 void (*cb)(void *user, void *ptr));
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);
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,
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);
102 void Curl_hash_print(struct curl_hash *h,
103 void (*func)(void *));
106 #endif /* HEADER_CURL_HASH_H */