ssl.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. * Snatched from OpenSSL includes. I put the prototypes here to be independent
  12. * from the OpenSSL source installation. Having this, shttpd + SSL can be
  13. * built on any system with binary SSL libraries installed.
  14. */
  15. typedef struct ssl_st SSL;
  16. typedef struct ssl_method_st SSL_METHOD;
  17. typedef struct ssl_ctx_st SSL_CTX;
  18. #define SSL_ERROR_WANT_READ 2
  19. #define SSL_ERROR_WANT_WRITE 3
  20. #define SSL_FILETYPE_PEM 1
  21. /*
  22. * Dynamically loaded SSL functionality
  23. */
  24. struct ssl_func {
  25. const char *name; /* SSL function name */
  26. union variant ptr; /* Function pointer */
  27. };
  28. extern struct ssl_func ssl_sw[];
  29. #define FUNC(x) ssl_sw[x].ptr.v_func
  30. #define SSL_free(x) (* (void (*)(SSL *)) FUNC(0))(x)
  31. #define SSL_accept(x) (* (int (*)(SSL *)) FUNC(1))(x)
  32. #define SSL_connect(x) (* (int (*)(SSL *)) FUNC(2))(x)
  33. #define SSL_read(x,y,z) (* (int (*)(SSL *, void *, int)) FUNC(3))((x),(y),(z))
  34. #define SSL_write(x,y,z) \
  35. (* (int (*)(SSL *, const void *,int)) FUNC(4))((x), (y), (z))
  36. #define SSL_get_error(x,y)(* (int (*)(SSL *, int)) FUNC(5))((x), (y))
  37. #define SSL_set_fd(x,y) (* (int (*)(SSL *, int)) FUNC(6))((x), (y))
  38. #define SSL_new(x) (* (SSL * (*)(SSL_CTX *)) FUNC(7))(x)
  39. #define SSL_CTX_new(x) (* (SSL_CTX * (*)(SSL_METHOD *)) FUNC(8))(x)
  40. #define SSLv23_server_method() (* (SSL_METHOD * (*)(void)) FUNC(9))()
  41. #define SSL_library_init() (* (int (*)(void)) FUNC(10))()
  42. #define SSL_CTX_use_PrivateKey_file(x,y,z) (* (int (*)(SSL_CTX *, \
  43. const char *, int)) FUNC(11))((x), (y), (z))
  44. #define SSL_CTX_use_certificate_file(x,y,z) (* (int (*)(SSL_CTX *, \
  45. const char *, int)) FUNC(12))((x), (y), (z))