Go to the documentation of this file.00001 #ifndef HEADER_CURL_HASH_H
00002 #define HEADER_CURL_HASH_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "curl_setup.h"
00026
00027 #include <stddef.h>
00028
00029 #include "llist.h"
00030
00031
00032 typedef size_t (*hash_function) (void *key,
00033 size_t key_length,
00034 size_t slots_num);
00035
00036
00037
00038
00039 typedef size_t (*comp_function) (void *key1,
00040 size_t key1_len,
00041 void *key2,
00042 size_t key2_len);
00043
00044 typedef void (*curl_hash_dtor)(void *);
00045
00046 struct curl_hash {
00047 struct curl_llist **table;
00048
00049
00050 hash_function hash_func;
00051
00052
00053 comp_function comp_func;
00054 curl_hash_dtor dtor;
00055 int slots;
00056 size_t size;
00057 };
00058
00059 struct curl_hash_element {
00060 void *ptr;
00061 char *key;
00062 size_t key_len;
00063 };
00064
00065 struct curl_hash_iterator {
00066 struct curl_hash *hash;
00067 int slot_index;
00068 struct curl_llist_element *current_element;
00069 };
00070
00071 int Curl_hash_init(struct curl_hash *h,
00072 int slots,
00073 hash_function hfunc,
00074 comp_function comparator,
00075 curl_hash_dtor dtor);
00076
00077 void *Curl_hash_add(struct curl_hash *h, void *key, size_t key_len, void *p);
00078 int Curl_hash_delete(struct curl_hash *h, void *key, size_t key_len);
00079 void *Curl_hash_pick(struct curl_hash *, void *key, size_t key_len);
00080 void Curl_hash_apply(struct curl_hash *h, void *user,
00081 void (*cb)(void *user, void *ptr));
00082 int Curl_hash_count(struct curl_hash *h);
00083 void Curl_hash_destroy(struct curl_hash *h);
00084 void Curl_hash_clean(struct curl_hash *h);
00085 void Curl_hash_clean_with_criterium(struct curl_hash *h, void *user,
00086 int (*comp)(void *, void *));
00087 size_t Curl_hash_str(void *key, size_t key_length, size_t slots_num);
00088 size_t Curl_str_key_compare(void *k1, size_t key1_len, void *k2,
00089 size_t key2_len);
00090 void Curl_hash_start_iterate(struct curl_hash *hash,
00091 struct curl_hash_iterator *iter);
00092 struct curl_hash_element *
00093 Curl_hash_next_element(struct curl_hash_iterator *iter);
00094
00095 void Curl_hash_print(struct curl_hash *h,
00096 void (*func)(void *));
00097
00098
00099 #endif