File indexing completed on 2025-01-18 09:50:09
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 #include <boost/throw_exception.hpp>
0025 #include <boost/process/exception.hpp>
0026 #include <boost/assert/source_location.hpp>
0027
0028 #if defined(BOOST_POSIX_API)
0029 #include <errno.h>
0030 #if defined(__GLIBC__)
0031 #include <features.h>
0032 #else
0033 extern char **environ;
0034 #endif
0035 #elif defined(BOOST_WINDOWS_API)
0036 #include <boost/winapi/get_last_error.hpp>
0037 #else
0038 #error "System API not supported by boost.process"
0039 #endif
0040
0041 namespace boost { namespace process { namespace detail
0042 {
0043
0044 #if !defined(BOOST_PROCESS_PIPE_SIZE)
0045 #define BOOST_PROCESS_PIPE_SIZE 1024
0046 #endif
0047
0048 #if defined(BOOST_POSIX_API)
0049 namespace posix {namespace extensions {}}
0050 namespace api = posix;
0051
0052 inline std::error_code get_last_error() noexcept
0053 {
0054 return std::error_code(errno, std::system_category());
0055 }
0056
0057
0058 #if (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
0059 #define BOOST_POSIX_HAS_VFORK 1
0060 #endif
0061
0062 #if (_POSIX_C_SOURCE >= 199309L)
0063 #define BOOST_POSIX_HAS_SIGTIMEDWAIT 1
0064 #endif
0065
0066 #elif defined(BOOST_WINDOWS_API)
0067 namespace windows {namespace extensions {}}
0068 namespace api = windows;
0069
0070 inline std::error_code get_last_error() noexcept
0071 {
0072 return std::error_code(::boost::winapi::GetLastError(), std::system_category());
0073 }
0074 #endif
0075
0076 inline void throw_last_error(const std::string & msg, boost::source_location const & loc = boost::source_location())
0077 {
0078 boost::throw_exception(process_error(get_last_error(), msg), loc);
0079 }
0080
0081 inline void throw_last_error(const char * msg, boost::source_location const & loc = boost::source_location())
0082 {
0083 boost::throw_exception(process_error(get_last_error(), msg), loc);
0084 }
0085
0086 inline void throw_last_error(boost::source_location const & loc = boost::source_location())
0087 {
0088 boost::throw_exception(process_error(get_last_error()), loc);
0089 }
0090
0091 inline void throw_error(const std::error_code& ec,
0092 boost::source_location const & loc = boost::source_location())
0093 {
0094 if (ec)
0095 boost::throw_exception(process_error(ec), loc);
0096 }
0097
0098 inline void throw_error(const std::error_code& ec, const char* msg,
0099 boost::source_location const & loc = boost::source_location())
0100 {
0101 if (ec)
0102 boost::throw_exception(process_error(ec, msg), loc);
0103 }
0104
0105 template<typename Char> constexpr Char null_char();
0106 template<> constexpr char null_char<char> (){return '\0';}
0107 template<> constexpr wchar_t null_char<wchar_t> (){return L'\0';}
0108
0109 template<typename Char> constexpr Char equal_sign();
0110 template<> constexpr char equal_sign<char> () {return '='; }
0111 template<> constexpr wchar_t equal_sign<wchar_t> () {return L'='; }
0112
0113 template<typename Char> constexpr Char quote_sign();
0114 template<> constexpr char quote_sign<char> () {return '"'; }
0115 template<> constexpr wchar_t quote_sign<wchar_t> () {return L'"'; }
0116
0117 template<typename Char> constexpr Char space_sign();
0118 template<> constexpr char space_sign<char> () {return ' '; }
0119 template<> constexpr wchar_t space_sign<wchar_t> () {return L' '; }
0120
0121 }
0122 }
0123 }
0124
0125 #endif