Home | History | Annotate | Download | only in openssl
      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 /* SSL_SESSION */
     96 #define lh_SSL_SESSION_new(hash, comp)                                        \
     97   ((LHASH_OF(SSL_SESSION) *)lh_new(                                           \
     98       CHECKED_CAST(lhash_hash_func, uint32_t (*)(const SSL_SESSION *), hash), \
     99       CHECKED_CAST(lhash_cmp_func,                                            \
    100                    int (*)(const SSL_SESSION *a, const SSL_SESSION *b),       \
    101                    comp)))
    102 
    103 #define lh_SSL_SESSION_free(lh) \
    104   lh_free(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh));
    105 
    106 #define lh_SSL_SESSION_num_items(lh) \
    107   lh_num_items(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh))
    108 
    109 #define lh_SSL_SESSION_retrieve(lh, data)                  \
    110   ((SSL_SESSION *)lh_retrieve(                             \
    111       CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \
    112       CHECKED_CAST(void *, SSL_SESSION *, data)))
    113 
    114 #define lh_SSL_SESSION_insert(lh, old_data, data)                \
    115   lh_insert(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \
    116             CHECKED_CAST(void **, SSL_SESSION **, old_data),     \
    117             CHECKED_CAST(void *, SSL_SESSION *, data))
    118 
    119 #define lh_SSL_SESSION_delete(lh, data)                    \
    120   ((SSL_SESSION *)lh_delete(                               \
    121       CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \
    122       CHECKED_CAST(void *, SSL_SESSION *, data)))
    123 
    124 #define lh_SSL_SESSION_doall(lh, func)                          \
    125   lh_doall(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \
    126            CHECKED_CAST(void (*)(void *), void (*)(SSL_SESSION *), func));
    127 
    128 #define lh_SSL_SESSION_doall_arg(lh, func, arg)                     \
    129   lh_doall_arg(CHECKED_CAST(_LHASH *, LHASH_OF(SSL_SESSION) *, lh), \
    130                CHECKED_CAST(void (*)(void *, void *),               \
    131                             void (*)(SSL_SESSION *, void *), func), \
    132                arg);
    133