00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #ifndef HEADER_LHASH_H
00067 #define HEADER_LHASH_H
00068
00069 #if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
00070 #define SYMBIAN
00071 #endif
00072
00073 #ifdef SYMBIAN
00074 #include <e32def.h>
00075 #endif
00076 #include <openssl/e_os2.h>
00077 #ifndef OPENSSL_NO_FP_API
00078 #include <stdio.h>
00079 #endif
00080
00081 #ifndef OPENSSL_NO_BIO
00082 #include <openssl/bio.h>
00083 #endif
00084
00085 #ifdef __cplusplus
00086 extern "C" {
00087 #endif
00088
00089 typedef struct lhash_node_st
00090 {
00091 void *data;
00092 struct lhash_node_st *next;
00093 #ifndef OPENSSL_NO_HASH_COMP
00094 unsigned long hash;
00095 #endif
00096 } LHASH_NODE;
00097
00098 typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
00099 typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
00100 typedef void (*LHASH_DOALL_FN_TYPE)(void *);
00101 typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 #define DECLARE_LHASH_HASH_FN(f_name,o_type) \
00112 unsigned long f_name##_LHASH_HASH(const void *);
00113 #define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
00114 unsigned long f_name##_LHASH_HASH(const void *arg) { \
00115 o_type a = (o_type)arg; \
00116 return f_name(a); }
00117 #define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
00118
00119
00120 #define DECLARE_LHASH_COMP_FN(f_name,o_type) \
00121 int f_name##_LHASH_COMP(const void *, const void *);
00122 #define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
00123 int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
00124 o_type a = (o_type)arg1; \
00125 o_type b = (o_type)arg2; \
00126 return f_name(a,b); }
00127 #define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
00128
00129
00130 #define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
00131 void f_name##_LHASH_DOALL(void *);
00132 #define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
00133 void f_name##_LHASH_DOALL(void *arg) { \
00134 o_type a = (o_type)arg; \
00135 f_name(a); }
00136 #define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
00137
00138
00139 #define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
00140 void f_name##_LHASH_DOALL_ARG(void *, void *);
00141 #define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
00142 void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
00143 o_type a = (o_type)arg1; \
00144 a_type b = (a_type)arg2; \
00145 f_name(a,b); }
00146 #define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
00147
00148 typedef struct lhash_st
00149 {
00150 LHASH_NODE **b;
00151 LHASH_COMP_FN_TYPE comp;
00152 LHASH_HASH_FN_TYPE hash;
00153 unsigned int num_nodes;
00154 unsigned int num_alloc_nodes;
00155 unsigned int p;
00156 unsigned int pmax;
00157 unsigned long up_load;
00158 unsigned long down_load;
00159 unsigned long num_items;
00160
00161 unsigned long num_expands;
00162 unsigned long num_expand_reallocs;
00163 unsigned long num_contracts;
00164 unsigned long num_contract_reallocs;
00165 unsigned long num_hash_calls;
00166 unsigned long num_comp_calls;
00167 unsigned long num_insert;
00168 unsigned long num_replace;
00169 unsigned long num_delete;
00170 unsigned long num_no_delete;
00171 unsigned long num_retrieve;
00172 unsigned long num_retrieve_miss;
00173 unsigned long num_hash_comps;
00174
00175 int error;
00176 } LHASH;
00177
00178 #define LH_LOAD_MULT 256
00179
00180
00181
00182 #define lh_error(lh) ((lh)->error)
00183
00184 IMPORT_C LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
00185 IMPORT_C void lh_free(LHASH *lh);
00186 IMPORT_C void *lh_insert(LHASH *lh, void *data);
00187 IMPORT_C void *lh_delete(LHASH *lh, const void *data);
00188 IMPORT_C void *lh_retrieve(LHASH *lh, const void *data);
00189 IMPORT_C void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func);
00190 IMPORT_C void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
00191 IMPORT_C unsigned long lh_strhash(const char *c);
00192 IMPORT_C unsigned long lh_num_items(const LHASH *lh);
00193
00194 #ifndef OPENSSL_NO_FP_API
00195 IMPORT_C void lh_stats(const LHASH *lh, FILE *out);
00196 IMPORT_C void lh_node_stats(const LHASH *lh, FILE *out);
00197 IMPORT_C void lh_node_usage_stats(const LHASH *lh, FILE *out);
00198 #endif
00199
00200 #ifndef OPENSSL_NO_BIO
00201 IMPORT_C void lh_stats_bio(const LHASH *lh, BIO *out);
00202 IMPORT_C void lh_node_stats_bio(const LHASH *lh, BIO *out);
00203 IMPORT_C void lh_node_usage_stats_bio(const LHASH *lh, BIO *out);
00204 #endif
00205 #ifdef __cplusplus
00206 }
00207 #endif
00208
00209 #endif
00210