ustream-openssl: clear error stack before SSL_read/SSL_write
[oweals/ustream-ssl.git] / openssl_bio_compat.h
1 #ifndef OPENSSL_BIO_COMPAT_H
2 #define OPENSSL_BIO_COMPAT_H
3
4 #include <openssl/opensslv.h>
5 #if OPENSSL_VERSION_NUMBER < 0x10100000L
6
7 #include <openssl/bio.h>
8 #include <string.h>
9
10 #define BIO_get_data(b) (b->ptr)
11 #define BIO_set_data(b, v) (b->ptr = v)
12 #define BIO_set_init(b, v) (b->init = v)
13 #define BIO_meth_set_write(m, f) (m->bwrite = f)
14 #define BIO_meth_set_read(m, f) (m->bread = f)
15 #define BIO_meth_set_puts(m, f) (m->bputs = f)
16 #define BIO_meth_set_gets(m, f) (m->bgets = f)
17 #define BIO_meth_set_ctrl(m, f) (m->ctrl = f)
18 #define BIO_meth_set_create(m, f) (m->create = f)
19 #define BIO_meth_set_destroy(m, f) (m->destroy = f)
20
21 static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
22 {
23         BIO_METHOD *bm = calloc(1, sizeof(BIO_METHOD));
24         if (bm) {
25                 bm->type = type;
26                 bm->name = name;
27         }
28         return bm;
29 }
30
31 #endif /* OPENSSL_VERSION_NUMBER */
32
33 #endif /* OPENSSL_BIO_COMPAT_H */