File indexing completed on 2025-04-19 08:42:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef BOOST_PROCESS_DETAIL_CONFIG_HPP
0018 #define BOOST_PROCESS_DETAIL_CONFIG_HPP
0019
0020 #include <boost/config.hpp>
0021 #include <system_error>
0022 #include <boost/system/api_config.hpp>
0023
0024 #if !defined(BOOST_PROCESS_VERSION)
0025 #define BOOST_PROCESS_VERSION 1
0026 #endif
0027
0028 #if BOOST_PROCESS_VERSION == 1
0029 #define BOOST_PROCESS_V1_INLINE inline
0030 #else
0031 #define BOOST_PROCESS_V1_INLINE
0032 #endif
0033
0034 #include <boost/throw_exception.hpp>
0035 #include <boost/process/v1/exception.hpp>
0036 #include <boost/assert/source_location.hpp>
0037
0038 #if defined(BOOST_POSIX_API)
0039 #include <errno.h>
0040 #if defined(__GLIBC__)
0041 #include <features.h>
0042 #else
0043 extern char **environ;
0044 #endif
0045 #elif defined(BOOST_WINDOWS_API)
0046 #include <boost/winapi/get_last_error.hpp>
0047 #else
0048 #error "System API not supported by boost.process"
0049 #endif
0050
0051
0052
0053 namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail
0054 {
0055
0056 #if !defined(BOOST_PROCESS_PIPE_SIZE)
0057 #define BOOST_PROCESS_PIPE_SIZE 1024
0058 #endif
0059
0060 #if defined(BOOST_POSIX_API)
0061 namespace posix {namespace extensions {}}
0062 namespace api = posix;
0063
0064 inline std::error_code get_last_error() noexcept
0065 {
0066 return std::error_code(errno, std::system_category());
0067 }
0068
0069
0070 #if (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
0071 #define BOOST_POSIX_HAS_VFORK 1
0072 #endif
0073
0074 #if (_POSIX_C_SOURCE >= 199309L)
0075 #define BOOST_POSIX_HAS_SIGTIMEDWAIT 1
0076 #endif
0077
0078 #elif defined(BOOST_WINDOWS_API)
0079 namespace windows {namespace extensions {}}
0080 namespace api = windows;
0081
0082 inline std::error_code get_last_error() noexcept
0083 {
0084 return std::error_code(::boost::winapi::GetLastError(), std::system_category());
0085 }
0086 #endif
0087
0088 inline void throw_last_error(const std::string & msg, boost::source_location const & loc = boost::source_location())
0089 {
0090 boost::throw_exception(process_error(get_last_error(), msg), loc);
0091 }
0092
0093 inline void throw_last_error(const char * msg, boost::source_location const & loc = boost::source_location())
0094 {
0095 boost::throw_exception(process_error(get_last_error(), msg), loc);
0096 }
0097
0098 inline void throw_last_error(boost::source_location const & loc = boost::source_location())
0099 {
0100 boost::throw_exception(process_error(get_last_error()), loc);
0101 }
0102
0103 inline void throw_error(const std::error_code& ec,
0104 boost::source_location const & loc = boost::source_location())
0105 {
0106 if (ec)
0107 boost::throw_exception(process_error(ec), loc);
0108 }
0109
0110 inline void throw_error(const std::error_code& ec, const char* msg,
0111 boost::source_location const & loc = boost::source_location())
0112 {
0113 if (ec)
0114 boost::throw_exception(process_error(ec, msg), loc);
0115 }
0116
0117 template<typename Char> constexpr Char null_char();
0118 template<> constexpr char null_char<char> (){return '\0';}
0119 template<> constexpr wchar_t null_char<wchar_t> (){return L'\0';}
0120
0121 template<typename Char> constexpr Char equal_sign();
0122 template<> constexpr char equal_sign<char> () {return '='; }
0123 template<> constexpr wchar_t equal_sign<wchar_t> () {return L'='; }
0124
0125 template<typename Char> constexpr Char quote_sign();
0126 template<> constexpr char quote_sign<char> () {return '"'; }
0127 template<> constexpr wchar_t quote_sign<wchar_t> () {return L'"'; }
0128
0129 template<typename Char> constexpr Char space_sign();
0130 template<> constexpr char space_sign<char> () {return ' '; }
0131 template<> constexpr wchar_t space_sign<wchar_t> () {return L' '; }
0132
0133 }
0134 }
0135 }
0136 }
0137
0138
0139 #endif