]> granicus.if.org Git - libevent/blob - openssl-compat.h
Merge pull request #1315 from yogo1212/http_per_socket_bebcb
[libevent] / openssl-compat.h
1 #ifndef OPENSSL_COMPAT_H
2 #define OPENSSL_COMPAT_H
3
4 #include <openssl/bio.h>
5 #include "util-internal.h"
6
7 #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
8         (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
9
10 static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
11 {
12         BIO_METHOD *biom = calloc(1, sizeof(BIO_METHOD));
13
14         if (biom != NULL) {
15                 biom->type = type;
16                 biom->name = name;
17         }
18         return biom;
19 }
20
21 #define BIO_meth_set_write(b, f) (b)->bwrite = (f)
22 #define BIO_meth_set_read(b, f) (b)->bread = (f)
23 #define BIO_meth_set_puts(b, f) (b)->bputs = (f)
24 #define BIO_meth_set_ctrl(b, f) (b)->ctrl = (f)
25 #define BIO_meth_set_create(b, f) (b)->create = (f)
26 #define BIO_meth_set_destroy(b, f) (b)->destroy = (f)
27
28 #define BIO_set_init(b, val) (b)->init = (val)
29 #define BIO_set_data(b, val) (b)->ptr = (val)
30 #define BIO_set_shutdown(b, val) (b)->shutdown = (val)
31 #define BIO_get_init(b) (b)->init
32 #define BIO_get_data(b) (b)->ptr
33 #define BIO_get_shutdown(b) (b)->shutdown
34
35 #define TLS_method SSLv23_method
36
37 #define X509_getm_notBefore X509_get_notBefore
38 #define X509_getm_notAfter X509_get_notAfter
39
40 #endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
41         (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) */
42
43 #if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L && \
44         LIBRESSL_VERSION_NUMBER < 0x30500000L
45 #define BIO_get_init(b) (b)->init
46 #endif
47
48 #endif /* OPENSSL_COMPAT_H */