Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:02

0001 //
0002 // ssl/impl/error.ipp
0003 // ~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_SSL_IMPL_ERROR_IPP
0012 #define BOOST_ASIO_SSL_IMPL_ERROR_IPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/ssl/error.hpp>
0020 #include <boost/asio/ssl/detail/openssl_init.hpp>
0021 
0022 #include <boost/asio/detail/push_options.hpp>
0023 
0024 namespace boost {
0025 namespace asio {
0026 namespace error {
0027 namespace detail {
0028 
0029 class ssl_category : public boost::system::error_category
0030 {
0031 public:
0032   const char* name() const noexcept
0033   {
0034     return "asio.ssl";
0035   }
0036 
0037   std::string message(int value) const
0038   {
0039     const char* reason = ::ERR_reason_error_string(value);
0040     if (reason)
0041     {
0042       const char* lib = ::ERR_lib_error_string(value);
0043 #if (OPENSSL_VERSION_NUMBER < 0x30000000L)
0044       const char* func = ::ERR_func_error_string(value);
0045 #else // (OPENSSL_VERSION_NUMBER < 0x30000000L)
0046       const char* func = 0;
0047 #endif // (OPENSSL_VERSION_NUMBER < 0x30000000L)
0048       std::string result(reason);
0049       if (lib || func)
0050       {
0051         result += " (";
0052         if (lib)
0053           result += lib;
0054         if (lib && func)
0055           result += ", ";
0056         if (func)
0057           result += func;
0058         result += ")";
0059       }
0060       return result;
0061     }
0062     return "asio.ssl error";
0063   }
0064 };
0065 
0066 } // namespace detail
0067 
0068 const boost::system::error_category& get_ssl_category()
0069 {
0070   static detail::ssl_category instance;
0071   return instance;
0072 }
0073 
0074 } // namespace error
0075 namespace ssl {
0076 namespace error {
0077 
0078 #if (OPENSSL_VERSION_NUMBER < 0x10100000L) && !defined(OPENSSL_IS_BORINGSSL)
0079 
0080 const boost::system::error_category& get_stream_category()
0081 {
0082   return boost::asio::error::get_ssl_category();
0083 }
0084 
0085 #else
0086 
0087 namespace detail {
0088 
0089 class stream_category : public boost::system::error_category
0090 {
0091 public:
0092   const char* name() const noexcept
0093   {
0094     return "asio.ssl.stream";
0095   }
0096 
0097   std::string message(int value) const
0098   {
0099     switch (value)
0100     {
0101     case stream_truncated: return "stream truncated";
0102     case unspecified_system_error: return "unspecified system error";
0103     case unexpected_result: return "unexpected result";
0104     default: return "asio.ssl.stream error";
0105     }
0106   }
0107 };
0108 
0109 } // namespace detail
0110 
0111 const boost::system::error_category& get_stream_category()
0112 {
0113   static detail::stream_category instance;
0114   return instance;
0115 }
0116 
0117 #endif
0118 
0119 } // namespace error
0120 } // namespace ssl
0121 } // namespace asio
0122 } // namespace boost
0123 
0124 #include <boost/asio/detail/pop_options.hpp>
0125 
0126 #endif // BOOST_ASIO_SSL_IMPL_ERROR_IPP