1 /* Copyright (c) 2014, Google Inc. 2 * 3 * Permission to use, copy, modify, and/or distribute this software for any 4 * purpose with or without fee is hereby granted, provided that the above 5 * copyright notice and this permission notice appear in all copies. 6 * 7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 10 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 12 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 13 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ 14 15 #if !defined(IN_LHASH_H) 16 #error "Don't include this file directly. Include lhash.h" 17 #endif 18 19 /* ASN1_OBJECT */ 20 #define lh_ASN1_OBJECT_new(hash, comp) \ 21 ((LHASH_OF(ASN1_OBJECT) *)lh_new( \ 22 CHECKED_CAST(lhash_hash_func, uint32_t (*)(const ASN1_OBJECT *), hash), \ 23 CHECKED_CAST(lhash_cmp_func, \ 24 int (*)(const ASN1_OBJECT *a, const ASN1_OBJECT *b), \ 25 comp))) 26 27 #define lh_ASN1_OBJECT_free(lh) \ 28 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh)); 29 30 #define lh_ASN1_OBJECT_num_items(lh) \ 31 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh)) 32 33 #define lh_ASN1_OBJECT_retrieve(lh, data) \ 34 ((ASN1_OBJECT *)lh_retrieve( \ 35 CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ 36 CHECKED_CAST(void *, ASN1_OBJECT *, data))) 37 38 #define lh_ASN1_OBJECT_insert(lh, old_data, data) \ 39 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ 40 CHECKED_CAST(void **, ASN1_OBJECT **, old_data), \ 41 CHECKED_CAST(void *, ASN1_OBJECT *, data)) 42 43 #define lh_ASN1_OBJECT_delete(lh, data) \ 44 ((ASN1_OBJECT *)lh_delete( \ 45 CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ 46 CHECKED_CAST(void *, ASN1_OBJECT *, data))) 47 48 #define lh_ASN1_OBJECT_doall(lh, func) \ 49 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ 50 CHECKED_CAST(void (*)(void *), void (*)(ASN1_OBJECT *), func)); 51 52 #define lh_ASN1_OBJECT_doall_arg(lh, func, arg) \ 53 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(ASN1_OBJECT) *, lh), \ 54 CHECKED_CAST(void (*)(void *, void *), \ 55 void (*)(ASN1_OBJECT *, void *), func), \ 56 arg); 57 58 /* CONF_VALUE */ 59 #define lh_CONF_VALUE_new(hash, comp) \ 60 ((LHASH_OF(CONF_VALUE) *)lh_new( \ 61 CHECKED_CAST(lhash_hash_func, uint32_t (*)(const CONF_VALUE *), hash), \ 62 CHECKED_CAST(lhash_cmp_func, \ 63 int (*)(const CONF_VALUE *a, const CONF_VALUE *b), comp))) 64 65 #define lh_CONF_VALUE_free(lh) \ 66 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh)); 67 68 #define lh_CONF_VALUE_num_items(lh) \ 69 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh)) 70 71 #define lh_CONF_VALUE_retrieve(lh, data) \ 72 ((CONF_VALUE *)lh_retrieve( \ 73 CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 74 CHECKED_CAST(void *, CONF_VALUE *, data))) 75 76 #define lh_CONF_VALUE_insert(lh, old_data, data) \ 77 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 78 CHECKED_CAST(void **, CONF_VALUE **, old_data), \ 79 CHECKED_CAST(void *, CONF_VALUE *, data)) 80 81 #define lh_CONF_VALUE_delete(lh, data) \ 82 ((CONF_VALUE *)lh_delete(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 83 CHECKED_CAST(void *, CONF_VALUE *, data))) 84 85 #define lh_CONF_VALUE_doall(lh, func) \ 86 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 87 CHECKED_CAST(void (*)(void *), void (*)(CONF_VALUE *), func)); 88 89 #define lh_CONF_VALUE_doall_arg(lh, func, arg) \ 90 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 91 CHECKED_CAST(void (*)(void *, void *), \ 92 void (*)(CONF_VALUE *, void *), func), \ 93 arg); 94 95 /* ERR_STATE */ 96 #define lh_ERR_STATE_new(hash, comp) \ 97 ((LHASH_OF(ERR_STATE) *)lh_new( \ 98 CHECKED_CAST(lhash_hash_func, uint32_t (*)(const ERR_STATE *), hash), \ 99 CHECKED_CAST(lhash_cmp_func, \ 100 int (*)(const ERR_STATE *a, const ERR_STATE *b), comp))) 101 102 #define lh_ERR_STATE_free(lh) \ 103 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STATE) *, lh)); 104 105 #define lh_ERR_STATE_num_items(lh) \ 106 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STATE) *, lh)) 107 108 #define lh_ERR_STATE_retrieve(lh, data) \ 109 ((ERR_STATE *)lh_retrieve(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STATE) *, lh), \ 110 CHECKED_CAST(void *, ERR_STATE *, data))) 111 112 #define lh_ERR_STATE_insert(lh, old_data, data) \ 113 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STATE) *, lh), \ 114 CHECKED_CAST(void **, ERR_STATE **, old_data), \ 115 CHECKED_CAST(void *, ERR_STATE *, data)) 116 117 #define lh_ERR_STATE_delete(lh, data) \ 118 ((ERR_STATE *)lh_delete(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STATE) *, lh), \ 119 CHECKED_CAST(void *, ERR_STATE *, data))) 120 121 #define lh_ERR_STATE_doall(lh, func) \ 122 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STATE) *, lh), \ 123 CHECKED_CAST(void (*)(void *), void (*)(ERR_STATE *), func)); 124 125 #define lh_ERR_STATE_doall_arg(lh, func, arg) \ 126 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STATE) *, lh), \ 127 CHECKED_CAST(void (*)(void *, void *), \ 128 void (*)(ERR_STATE *, void *), func), \ 129 arg); 130 131 /* ERR_STRING_DATA */ 132 #define lh_ERR_STRING_DATA_new(hash, comp) \ 133 ((LHASH_OF(ERR_STRING_DATA) *)lh_new( \ 134 CHECKED_CAST(lhash_hash_func, uint32_t (*)(const ERR_STRING_DATA *), \ 135 hash), \ 136 CHECKED_CAST( \ 137 lhash_cmp_func, \ 138 int (*)(const ERR_STRING_DATA *a, const ERR_STRING_DATA *b), comp))) 139 140 #define lh_ERR_STRING_DATA_free(lh) \ 141 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh)); 142 143 #define lh_ERR_STRING_DATA_num_items(lh) \ 144 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh)) 145 146 #define lh_ERR_STRING_DATA_retrieve(lh, data) \ 147 ((ERR_STRING_DATA *)lh_retrieve( \ 148 CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \ 149 CHECKED_CAST(void *, ERR_STRING_DATA *, data))) 150 151 #define lh_ERR_STRING_DATA_insert(lh, old_data, data) \ 152 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \ 153 CHECKED_CAST(void **, ERR_STRING_DATA **, old_data), \ 154 CHECKED_CAST(void *, ERR_STRING_DATA *, data)) 155 156 #define lh_ERR_STRING_DATA_delete(lh, data) \ 157 ((ERR_STRING_DATA *)lh_delete( \ 158 CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \ 159 CHECKED_CAST(void *, ERR_STRING_DATA *, data))) 160 161 #define lh_ERR_STRING_DATA_doall(lh, func) \ 162 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \ 163 CHECKED_CAST(void (*)(void *), void (*)(ERR_STRING_DATA *), func)); 164 165 #define lh_ERR_STRING_DATA_doall_arg(lh, func, arg) \ 166 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(ERR_STRING_DATA) *, lh), \ 167 CHECKED_CAST(void (*)(void *, void *), \ 168 void (*)(ERR_STRING_DATA *, void *), func), \ 169 arg); 170 171 /* EX_CLASS_ITEM */ 172 #define lh_EX_CLASS_ITEM_new(hash, comp) \ 173 ((LHASH_OF(EX_CLASS_ITEM) *)lh_new( \ 174 CHECKED_CAST(lhash_hash_func, uint32_t (*)(const EX_CLASS_ITEM *), \ 175 hash), \ 176 CHECKED_CAST(lhash_cmp_func, \ 177 int (*)(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b), \ 178 comp))) 179 180 #define lh_EX_CLASS_ITEM_free(lh) \ 181 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(EX_CLASS_ITEM) *, lh)); 182 183 #define lh_EX_CLASS_ITEM_num_items(lh) \ 184 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(EX_CLASS_ITEM) *, lh)) 185 186 #define lh_EX_CLASS_ITEM_retrieve(lh, data) \ 187 ((EX_CLASS_ITEM *)lh_retrieve( \ 188 CHECKED_CAST(_LHASH *, LHASH_OF(EX_CLASS_ITEM) *, lh), \ 189 CHECKED_CAST(void *, EX_CLASS_ITEM *, data))) 190 191 #define lh_EX_CLASS_ITEM_insert(lh, old_data, data) \ 192 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(EX_CLASS_ITEM) *, lh), \ 193 CHECKED_CAST(void **, EX_CLASS_ITEM **, old_data), \ 194 CHECKED_CAST(void *, EX_CLASS_ITEM *, data)) 195 196 #define lh_EX_CLASS_ITEM_delete(lh, data) \ 197 ((EX_CLASS_ITEM *)lh_delete( \ 198 CHECKED_CAST(_LHASH *, LHASH_OF(EX_CLASS_ITEM) *, lh), \ 199 CHECKED_CAST(void *, EX_CLASS_ITEM *, data))) 200 201 #define lh_EX_CLASS_ITEM_doall(lh, func) \ 202 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(EX_CLASS_ITEM) *, lh), \ 203 CHECKED_CAST(void (*)(void *), void (*)(EX_CLASS_ITEM *), func)); 204 205 #define lh_EX_CLASS_ITEM_doall_arg(lh, func, arg) \ 206 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(EX_CLASS_ITEM) *, lh), \ 207 CHECKED_CAST(void (*)(void *, void *), \ 208 void (*)(EX_CLASS_ITEM *, void *), func), \ 209 arg); 210 211 /* SSL_SESSION */ 212 #define lh_SSL_SESSION_new(hash, comp) \ 213 ((LHASH_OF(SSL_SESSION) *)lh_new( \ 214 CHECKED_CAST(lhash_hash_func, uint32_t (*)(const SSL_SESSION *), hash), \ 215 CHECKED_CAST(lhash_cmp_func, \ 216 int (*)(const SSL_SESSION *a, const SSL_SESSION *b), \ 217 comp))) 218 219 #define lh_SSL_SESSION_free(lh) \ 220 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh)); 221 222 #define lh_SSL_SESSION_num_items(lh) \ 223 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh)) 224 225 #define lh_SSL_SESSION_retrieve(lh, data) \ 226 ((SSL_SESSION *)lh_retrieve( \ 227 CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 228 CHECKED_CAST(void *, SSL_SESSION *, data))) 229 230 #define lh_SSL_SESSION_insert(lh, old_data, data) \ 231 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 232 CHECKED_CAST(void **, SSL_SESSION **, old_data), \ 233 CHECKED_CAST(void *, SSL_SESSION *, data)) 234 235 #define lh_SSL_SESSION_delete(lh, data) \ 236 ((SSL_SESSION *)lh_delete( \ 237 CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 238 CHECKED_CAST(void *, SSL_SESSION *, data))) 239 240 #define lh_SSL_SESSION_doall(lh, func) \ 241 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 242 CHECKED_CAST(void (*)(void *), void (*)(SSL_SESSION *), func)); 243 244 #define lh_SSL_SESSION_doall_arg(lh, func, arg) \ 245 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 246 CHECKED_CAST(void (*)(void *, void *), \ 247 void (*)(SSL_SESSION *, void *), func), \ 248 arg); 249