]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/winapi/environment.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / winapi / environment.hpp
1 /*
2 * Copyright 2016 Klemens D. Morgenstern
3 *
4 * Distributed under the Boost Software License, Version 1.0.
5 * See http://www.boost.org/LICENSE_1_0.txt
6 */
7
8 #ifndef BOOST_WINAPI_ENVIRONMENT_HPP_INCLUDED_
9 #define BOOST_WINAPI_ENVIRONMENT_HPP_INCLUDED_
10
11 #include <boost/winapi/basic_types.hpp>
12
13 #ifdef BOOST_HAS_PRAGMA_ONCE
14 #pragma once
15 #endif
16
17 #if BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
18
19 #include <boost/winapi/detail/header.hpp>
20
21 #if defined(GetEnvironmentStrings)
22 // Unlike most of the WinAPI, GetEnvironmentStrings is a real function and GetEnvironmentStringsA is a macro.
23 // In UNICODE builds, GetEnvironmentStrings is also defined as a macro that redirects to GetEnvironmentStringsW,
24 // and the narrow character version become inaccessible. Facepalm.
25 #if defined(_MSC_VER) || defined(__GNUC__)
26 #pragma push_macro("GetEnvironmentStrings")
27 #endif
28 #undef GetEnvironmentStrings
29 #define BOOST_WINAPI_DETAIL_GET_ENVIRONMENT_STRINGS_UNDEFINED
30 #endif // defined(GetEnvironmentStrings)
31
32 #if !defined( BOOST_USE_WINDOWS_H )
33 extern "C" {
34 #if !defined( BOOST_NO_ANSI_APIS )
35 BOOST_WINAPI_IMPORT boost::winapi::LPSTR_ BOOST_WINAPI_WINAPI_CC GetEnvironmentStrings();
36 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC FreeEnvironmentStringsA(boost::winapi::LPSTR_);
37
38 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC GetEnvironmentVariableA(
39 boost::winapi::LPCSTR_ lpName,
40 boost::winapi::LPSTR_ lpBuffer,
41 boost::winapi::DWORD_ nSize
42 );
43
44 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC SetEnvironmentVariableA(
45 boost::winapi::LPCSTR_ lpName,
46 boost::winapi::LPCSTR_ lpValue
47 );
48 #endif // !defined( BOOST_NO_ANSI_APIS )
49
50 BOOST_WINAPI_IMPORT boost::winapi::LPWSTR_ BOOST_WINAPI_WINAPI_CC GetEnvironmentStringsW();
51 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC FreeEnvironmentStringsW(boost::winapi::LPWSTR_);
52
53 BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC GetEnvironmentVariableW(
54 boost::winapi::LPCWSTR_ lpName,
55 boost::winapi::LPWSTR_ lpBuffer,
56 boost::winapi::DWORD_ nSize
57 );
58
59 BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC SetEnvironmentVariableW(
60 boost::winapi::LPCWSTR_ lpName,
61 boost::winapi::LPCWSTR_ lpValue
62 );
63 } // extern "C"
64 #endif // !defined( BOOST_USE_WINDOWS_H )
65
66 namespace boost {
67 namespace winapi {
68
69 #if !defined( BOOST_NO_ANSI_APIS )
70 using ::GetEnvironmentStrings;
71 using ::FreeEnvironmentStringsA;
72 using ::GetEnvironmentVariableA;
73 using ::SetEnvironmentVariableA;
74 #endif // !defined( BOOST_NO_ANSI_APIS )
75
76 using ::GetEnvironmentStringsW;
77 using ::FreeEnvironmentStringsW;
78 using ::GetEnvironmentVariableW;
79 using ::SetEnvironmentVariableW;
80
81 template< typename Char >
82 Char* get_environment_strings();
83
84 #if !defined( BOOST_NO_ANSI_APIS )
85
86 template< >
87 BOOST_FORCEINLINE char* get_environment_strings< char >()
88 {
89 return GetEnvironmentStrings();
90 }
91
92 BOOST_FORCEINLINE BOOL_ free_environment_strings(LPSTR_ p)
93 {
94 return FreeEnvironmentStringsA(p);
95 }
96
97 BOOST_FORCEINLINE DWORD_ get_environment_variable(LPCSTR_ name, LPSTR_ buffer, DWORD_ size)
98 {
99 return GetEnvironmentVariableA(name, buffer, size);
100 }
101
102 BOOST_FORCEINLINE BOOL_ set_environment_variable(LPCSTR_ name, LPCSTR_ value)
103 {
104 return SetEnvironmentVariableA(name, value);
105 }
106
107 #endif // !defined( BOOST_NO_ANSI_APIS )
108
109 template< >
110 BOOST_FORCEINLINE wchar_t* get_environment_strings< wchar_t >()
111 {
112 return GetEnvironmentStringsW();
113 }
114
115 BOOST_FORCEINLINE BOOL_ free_environment_strings(LPWSTR_ p)
116 {
117 return FreeEnvironmentStringsW(p);
118 }
119
120 BOOST_FORCEINLINE DWORD_ get_environment_variable(LPCWSTR_ name, LPWSTR_ buffer, DWORD_ size)
121 {
122 return GetEnvironmentVariableW(name, buffer, size);
123 }
124
125 BOOST_FORCEINLINE BOOL_ set_environment_variable(LPCWSTR_ name, LPCWSTR_ value)
126 {
127 return SetEnvironmentVariableW(name, value);
128 }
129
130 } // namespace winapi
131 } // namespace boost
132
133 #if defined(BOOST_WINAPI_DETAIL_GET_ENVIRONMENT_STRINGS_UNDEFINED)
134 #if defined(_MSC_VER) || defined(__GNUC__)
135 #pragma pop_macro("GetEnvironmentStrings")
136 #elif defined(UNICODE)
137 #define GetEnvironmentStrings GetEnvironmentStringsW
138 #endif
139 #undef BOOST_WINAPI_DETAIL_GET_ENVIRONMENT_STRINGS_UNDEFINED
140 #endif // defined(BOOST_WINAPI_DETAIL_GET_ENVIRONMENT_STRINGS_UNDEFINED)
141
142 #include <boost/winapi/detail/footer.hpp>
143
144 #endif // BOOST_WINAPI_PARTITION_DESKTOP || BOOST_WINAPI_PARTITION_SYSTEM
145
146 #endif // BOOST_WINAPI_ENVIRONMENT_HPP_INCLUDED_