Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:48:46

0001 //
0002 // process/environment/detail/environment_posix.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2021 Klemens D. Morgenstern (klemens dot morgenstern at gmx dot net)
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_PROCESS_V2_DETAIL_ENVIRONMENT_POSIX_HPP
0012 #define BOOST_PROCESS_V2_DETAIL_ENVIRONMENT_POSIX_HPP
0013 
0014 #include <boost/process/v2/detail/config.hpp>
0015 #include <boost/process/v2/cstring_ref.hpp>
0016 
0017 #if defined(__APPLE__)
0018 # include <crt_externs.h>
0019 # if !defined(environ)
0020 #  define environ (*_NSGetEnviron())
0021 # endif
0022 #elif defined(__MACH__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun)
0023  extern "C" { extern char **environ; }
0024 #endif
0025 
0026 BOOST_PROCESS_V2_BEGIN_NAMESPACE
0027 
0028 namespace environment
0029 {
0030 
0031 using char_type = char;
0032 
0033 template<typename Char>
0034 using key_char_traits = std::char_traits<Char>;
0035 
0036 template<typename Char>
0037 using value_char_traits = std::char_traits<Char>;
0038 
0039 
0040 constexpr char_type equality_sign = '=';
0041 constexpr char_type delimiter = ':';
0042 
0043 namespace detail
0044 {
0045 
0046 BOOST_PROCESS_V2_DECL
0047 basic_cstring_ref<char_type, value_char_traits<char>>
0048 get(basic_cstring_ref<char_type, key_char_traits<char_type>> key, error_code & ec);
0049 
0050 BOOST_PROCESS_V2_DECL
0051 void set(basic_cstring_ref<char_type, key_char_traits<char_type>> key,
0052          basic_cstring_ref<char_type, value_char_traits<char_type>> value,
0053          error_code & ec);
0054 
0055 BOOST_PROCESS_V2_DECL
0056 void unset(basic_cstring_ref<char_type, key_char_traits<char_type>> key,
0057            error_code & ec);
0058 }
0059 
0060 
0061 using native_handle_type   = const char * const *;
0062 using native_iterator = native_handle_type;
0063 
0064 namespace detail
0065 {
0066 
0067 BOOST_PROCESS_V2_DECL native_handle_type load_native_handle();
0068 struct native_handle_deleter
0069 {
0070     void operator()(native_handle_type) const {}
0071 };
0072 
0073 BOOST_PROCESS_V2_DECL native_iterator next(native_handle_type nh);
0074 BOOST_PROCESS_V2_DECL native_iterator find_end(native_handle_type nh);
0075 inline const char_type * dereference(native_iterator iterator) {return *iterator;}
0076 
0077 BOOST_PROCESS_V2_DECL bool has_x_access(const char * pth);
0078 
0079 inline bool is_executable(const filesystem::path & pth, error_code & ec)
0080 {
0081   return filesystem::is_regular_file(pth, ec) && has_x_access(pth.c_str());
0082 }
0083 
0084 }
0085 
0086 }
0087 
0088 BOOST_PROCESS_V2_END_NAMESPACE
0089 
0090 #endif