version 0.1.6
[fms.git] / libs / shttpd / ssl.h
1 /*
2  * Copyright (c) 2004-2005 Sergey Lyubka <valenok@gmail.com>
3  * All rights reserved
4  *
5  * "THE BEER-WARE LICENSE" (Revision 42):
6  * Sergey Lyubka wrote this file.  As long as you retain this notice you
7  * can do whatever you want with this stuff. If we meet some day, and you think
8  * this stuff is worth it, you can buy me a beer in return.
9  */
10
11 /*
12  * Snatched from OpenSSL includes. I put the prototypes here to be independent
13  * from the OpenSSL source installation. Having this, shttpd + SSL can be
14  * built on any system with binary SSL libraries installed.
15  */
16
17 typedef struct ssl_st SSL;
18 typedef struct ssl_method_st SSL_METHOD;
19 typedef struct ssl_ctx_st SSL_CTX;
20
21 #define SSL_ERROR_WANT_READ     2
22 #define SSL_ERROR_WANT_WRITE    3
23 #define SSL_FILETYPE_PEM        1
24
25 /*
26  * Dynamically loaded SSL functionality
27  */
28 struct ssl_func {
29         const char      *name;          /* SSL function name    */
30         union variant   ptr;            /* Function pointer     */
31 };
32
33 extern struct ssl_func  ssl_sw[];
34
35 #define FUNC(x) ssl_sw[x].ptr.v_func
36
37 #define SSL_free(x)     (* (void (*)(SSL *)) FUNC(0))(x)
38 #define SSL_accept(x)   (* (int (*)(SSL *)) FUNC(1))(x)
39 #define SSL_connect(x)  (* (int (*)(SSL *)) FUNC(2))(x)
40 #define SSL_read(x,y,z) (* (int (*)(SSL *, void *, int)) FUNC(3))((x),(y),(z))
41 #define SSL_write(x,y,z) \
42         (* (int (*)(SSL *, const void *,int)) FUNC(4))((x), (y), (z))
43 #define SSL_get_error(x,y)(* (int (*)(SSL *, int)) FUNC(5))((x), (y))
44 #define SSL_set_fd(x,y) (* (int (*)(SSL *, int)) FUNC(6))((x), (y))
45 #define SSL_new(x)      (* (SSL * (*)(SSL_CTX *)) FUNC(7))(x)
46 #define SSL_CTX_new(x)  (* (SSL_CTX * (*)(SSL_METHOD *)) FUNC(8))(x)
47 #define SSLv23_server_method()  (* (SSL_METHOD * (*)(void)) FUNC(9))()
48 #define SSL_library_init() (* (int (*)(void)) FUNC(10))()
49 #define SSL_CTX_use_PrivateKey_file(x,y,z)      (* (int (*)(SSL_CTX *, \
50                 const char *, int)) FUNC(11))((x), (y), (z))
51 #define SSL_CTX_use_certificate_file(x,y,z)     (* (int (*)(SSL_CTX *, \
52                 const char *, int)) FUNC(12))((x), (y), (z))