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 59 /* CONF_VALUE */ 60 #define lh_CONF_VALUE_new(hash, comp) \ 61 ((LHASH_OF(CONF_VALUE) *)lh_new( \ 62 CHECKED_CAST(lhash_hash_func, uint32_t(*)(const CONF_VALUE *), hash), \ 63 CHECKED_CAST(lhash_cmp_func, \ 64 int (*)(const CONF_VALUE *a, const CONF_VALUE *b), comp))) 65 66 #define lh_CONF_VALUE_free(lh) \ 67 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh)); 68 69 #define lh_CONF_VALUE_num_items(lh) \ 70 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh)) 71 72 #define lh_CONF_VALUE_retrieve(lh, data) \ 73 ((CONF_VALUE *)lh_retrieve( \ 74 CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 75 CHECKED_CAST(void *, CONF_VALUE *, data))) 76 77 #define lh_CONF_VALUE_insert(lh, old_data, data) \ 78 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 79 CHECKED_CAST(void **, CONF_VALUE **, old_data), \ 80 CHECKED_CAST(void *, CONF_VALUE *, data)) 81 82 #define lh_CONF_VALUE_delete(lh, data) \ 83 ((CONF_VALUE *)lh_delete(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 84 CHECKED_CAST(void *, CONF_VALUE *, data))) 85 86 #define lh_CONF_VALUE_doall(lh, func) \ 87 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 88 CHECKED_CAST(void (*)(void *), void (*)(CONF_VALUE *), func)); 89 90 #define lh_CONF_VALUE_doall_arg(lh, func, arg) \ 91 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(CONF_VALUE) *, lh), \ 92 CHECKED_CAST(void (*)(void *, void *), \ 93 void (*)(CONF_VALUE *, void *), func), \ 94 arg); 95 96 97 /* CRYPTO_BUFFER */ 98 #define lh_CRYPTO_BUFFER_new(hash, comp) \ 99 ((LHASH_OF(CRYPTO_BUFFER) *)lh_new( \ 100 CHECKED_CAST(lhash_hash_func, uint32_t(*)(const CRYPTO_BUFFER *), hash), \ 101 CHECKED_CAST(lhash_cmp_func, \ 102 int (*)(const CRYPTO_BUFFER *a, const CRYPTO_BUFFER *b), \ 103 comp))) 104 105 #define lh_CRYPTO_BUFFER_free(lh) \ 106 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(CRYPTO_BUFFER) *, lh)); 107 108 #define lh_CRYPTO_BUFFER_num_items(lh) \ 109 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(CRYPTO_BUFFER) *, lh)) 110 111 #define lh_CRYPTO_BUFFER_retrieve(lh, data) \ 112 ((CRYPTO_BUFFER *)lh_retrieve( \ 113 CHECKED_CAST(_LHASH *, LHASH_OF(CRYPTO_BUFFER) *, lh), \ 114 CHECKED_CAST(void *, CRYPTO_BUFFER *, data))) 115 116 #define lh_CRYPTO_BUFFER_insert(lh, old_data, data) \ 117 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(CRYPTO_BUFFER) *, lh), \ 118 CHECKED_CAST(void **, CRYPTO_BUFFER **, old_data), \ 119 CHECKED_CAST(void *, CRYPTO_BUFFER *, data)) 120 121 #define lh_CRYPTO_BUFFER_delete(lh, data) \ 122 ((CRYPTO_BUFFER *)lh_delete( \ 123 CHECKED_CAST(_LHASH *, LHASH_OF(CRYPTO_BUFFER) *, lh), \ 124 CHECKED_CAST(void *, CRYPTO_BUFFER *, data))) 125 126 #define lh_CRYPTO_BUFFER_doall(lh, func) \ 127 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(CRYPTO_BUFFER) *, lh), \ 128 CHECKED_CAST(void (*)(void *), void (*)(CRYPTO_BUFFER *), func)); 129 130 #define lh_CRYPTO_BUFFER_doall_arg(lh, func, arg) \ 131 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(CRYPTO_BUFFER) *, lh), \ 132 CHECKED_CAST(void (*)(void *, void *), \ 133 void (*)(CRYPTO_BUFFER *, void *), func), \ 134 arg); 135 136 137 /* SSL_SESSION */ 138 #define lh_SSL_SESSION_new(hash, comp) \ 139 ((LHASH_OF(SSL_SESSION) *)lh_new( \ 140 CHECKED_CAST(lhash_hash_func, uint32_t(*)(const SSL_SESSION *), hash), \ 141 CHECKED_CAST(lhash_cmp_func, \ 142 int (*)(const SSL_SESSION *a, const SSL_SESSION *b), \ 143 comp))) 144 145 #define lh_SSL_SESSION_free(lh) \ 146 lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh)); 147 148 #define lh_SSL_SESSION_num_items(lh) \ 149 lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh)) 150 151 #define lh_SSL_SESSION_retrieve(lh, data) \ 152 ((SSL_SESSION *)lh_retrieve( \ 153 CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 154 CHECKED_CAST(void *, SSL_SESSION *, data))) 155 156 #define lh_SSL_SESSION_insert(lh, old_data, data) \ 157 lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 158 CHECKED_CAST(void **, SSL_SESSION **, old_data), \ 159 CHECKED_CAST(void *, SSL_SESSION *, data)) 160 161 #define lh_SSL_SESSION_delete(lh, data) \ 162 ((SSL_SESSION *)lh_delete( \ 163 CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 164 CHECKED_CAST(void *, SSL_SESSION *, data))) 165 166 #define lh_SSL_SESSION_doall(lh, func) \ 167 lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 168 CHECKED_CAST(void (*)(void *), void (*)(SSL_SESSION *), func)); 169 170 #define lh_SSL_SESSION_doall_arg(lh, func, arg) \ 171 lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \ 172 CHECKED_CAST(void (*)(void *, void *), \ 173 void (*)(SSL_SESSION *, void *), func), \ 174 arg); 175