Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:44

0001 /*
0002  * Copyright 2016 Klemens D. Morgenstern
0003  *
0004  * Distributed under the Boost Software License, Version 1.0.
0005  * See http://www.boost.org/LICENSE_1_0.txt
0006  */
0007 
0008 #ifndef BOOST_WINAPI_ENVIRONMENT_HPP_INCLUDED_
0009 #define BOOST_WINAPI_ENVIRONMENT_HPP_INCLUDED_
0010 
0011 #include <boost/winapi/basic_types.hpp>
0012 
0013 #ifdef BOOST_HAS_PRAGMA_ONCE
0014 #pragma once
0015 #endif
0016 
0017 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
0018 
0019 #include <boost/winapi/detail/header.hpp>
0020 
0021 #if defined(GetEnvironmentStrings)
0022 // Unlike most of the WinAPI, GetEnvironmentStrings is a real function and GetEnvironmentStringsA is a macro.
0023 // In UNICODE builds, GetEnvironmentStrings is also defined as a macro that redirects to GetEnvironmentStringsW,
0024 // and the narrow character version become inaccessible. Facepalm.
0025 #if defined(_MSC_VER) || defined(__GNUC__)
0026 #pragma push_macro("GetEnvironmentStrings")
0027 #endif
0028 #undef GetEnvironmentStrings
0029 #define BOOST_WINAPI_DETAIL_GET_ENVIRONMENT_STRINGS_UNDEFINED
0030 #endif // defined(GetEnvironmentStrings)
0031 
0032 #if !defined( BOOST_USE_WINDOWS_H )
0033 extern "C" {
0034 #if !defined( BOOST_NO_ANSI_APIS )
0035 BOOST_WINAPI_IMPORT boost::winapi::LPSTR_ BOOST_WINAPI_WINAPI_CC GetEnvironmentStrings();
0036 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC FreeEnvironmentStringsA(boost::winapi::LPSTR_);
0037 
0038 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC GetEnvironmentVariableA(
0039     boost::winapi::LPCSTR_ lpName,
0040     boost::winapi::LPSTR_ lpBuffer,
0041     boost::winapi::DWORD_ nSize
0042 );
0043 
0044 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC SetEnvironmentVariableA(
0045     boost::winapi::LPCSTR_ lpName,
0046     boost::winapi::LPCSTR_ lpValue
0047 );
0048 #endif // !defined( BOOST_NO_ANSI_APIS )
0049 
0050 BOOST_WINAPI_IMPORT boost::winapi::LPWSTR_ BOOST_WINAPI_WINAPI_CC GetEnvironmentStringsW();
0051 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC FreeEnvironmentStringsW(boost::winapi::LPWSTR_);
0052 
0053 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC GetEnvironmentVariableW(
0054     boost::winapi::LPCWSTR_ lpName,
0055     boost::winapi::LPWSTR_ lpBuffer,
0056     boost::winapi::DWORD_ nSize
0057 );
0058 
0059 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC SetEnvironmentVariableW(
0060     boost::winapi::LPCWSTR_ lpName,
0061     boost::winapi::LPCWSTR_ lpValue
0062 );
0063 } // extern "C"
0064 #endif // !defined( BOOST_USE_WINDOWS_H )
0065 
0066 namespace boost {
0067 namespace winapi {
0068 
0069 #if !defined( BOOST_NO_ANSI_APIS )
0070 using ::GetEnvironmentStrings;
0071 using ::FreeEnvironmentStringsA;
0072 using ::GetEnvironmentVariableA;
0073 using ::SetEnvironmentVariableA;
0074 #endif // !defined( BOOST_NO_ANSI_APIS )
0075 
0076 using ::GetEnvironmentStringsW;
0077 using ::FreeEnvironmentStringsW;
0078 using ::GetEnvironmentVariableW;
0079 using ::SetEnvironmentVariableW;
0080 
0081 template< typename Char >
0082 Char* get_environment_strings();
0083 
0084 #if !defined( BOOST_NO_ANSI_APIS )
0085 
0086 template< >
0087 BOOST_FORCEINLINE char* get_environment_strings< char >()
0088 {
0089     return GetEnvironmentStrings();
0090 }
0091 
0092 BOOST_FORCEINLINE BOOL_ free_environment_strings(LPSTR_ p)
0093 {
0094     return FreeEnvironmentStringsA(p);
0095 }
0096 
0097 BOOST_FORCEINLINE DWORD_ get_environment_variable(LPCSTR_ name, LPSTR_ buffer, DWORD_ size)
0098 {
0099     return GetEnvironmentVariableA(name, buffer, size);
0100 }
0101 
0102 BOOST_FORCEINLINE BOOL_ set_environment_variable(LPCSTR_ name, LPCSTR_ value)
0103 {
0104     return SetEnvironmentVariableA(name, value);
0105 }
0106 
0107 #endif // !defined( BOOST_NO_ANSI_APIS )
0108 
0109 template< >
0110 BOOST_FORCEINLINE wchar_t* get_environment_strings< wchar_t >()
0111 {
0112     return GetEnvironmentStringsW();
0113 }
0114 
0115 BOOST_FORCEINLINE BOOL_ free_environment_strings(LPWSTR_ p)
0116 {
0117     return FreeEnvironmentStringsW(p);
0118 }
0119 
0120 BOOST_FORCEINLINE DWORD_ get_environment_variable(LPCWSTR_ name, LPWSTR_ buffer, DWORD_ size)
0121 {
0122     return GetEnvironmentVariableW(name, buffer, size);
0123 }
0124 
0125 BOOST_FORCEINLINE BOOL_ set_environment_variable(LPCWSTR_ name, LPCWSTR_ value)
0126 {
0127     return SetEnvironmentVariableW(name, value);
0128 }
0129 
0130 } // namespace winapi
0131 } // namespace boost
0132 
0133 #if defined(BOOST_WINAPI_DETAIL_GET_ENVIRONMENT_STRINGS_UNDEFINED)
0134 #if defined(_MSC_VER) || defined(__GNUC__)
0135 #pragma pop_macro("GetEnvironmentStrings")
0136 #elif defined(UNICODE)
0137 #define GetEnvironmentStrings GetEnvironmentStringsW
0138 #endif
0139 #undef BOOST_WINAPI_DETAIL_GET_ENVIRONMENT_STRINGS_UNDEFINED
0140 #endif // defined(BOOST_WINAPI_DETAIL_GET_ENVIRONMENT_STRINGS_UNDEFINED)
0141 
0142 #include <boost/winapi/detail/footer.hpp>
0143 
0144 #endif // BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
0145 
0146 #endif // BOOST_WINAPI_ENVIRONMENT_HPP_INCLUDED_