]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // environment.hpp --------------------------------------------------------------// |
2 | ||
3 | // Copyright 2016 Klemens D. Morgenstern | |
4 | ||
5 | // Distributed under the Boost Software License, Version 1.0. | |
6 | // See http://www.boost.org/LICENSE_1_0.txt | |
7 | ||
8 | #ifndef BOOST_DETAIL_WINAPI_ENVIRONMENT_HPP_ | |
9 | #define BOOST_DETAIL_WINAPI_ENVIRONMENT_HPP_ | |
10 | ||
11 | #include <boost/detail/winapi/basic_types.hpp> | |
12 | ||
13 | #ifdef BOOST_HAS_PRAGMA_ONCE | |
14 | #pragma once | |
15 | #endif | |
16 | ||
17 | #if !defined( BOOST_USE_WINDOWS_H ) | |
18 | extern "C" { | |
19 | #if !defined( BOOST_NO_ANSI_APIS ) | |
20 | BOOST_SYMBOL_IMPORT boost::detail::winapi::LPSTR_ WINAPI GetEnvironmentStringsA(); | |
21 | BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI FreeEnvironmentStringsA(boost::detail::winapi::LPSTR_); | |
22 | ||
23 | BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetEnvironmentVariableA( | |
24 | boost::detail::winapi::LPCSTR_ lpName, | |
25 | boost::detail::winapi::LPSTR_ lpBuffer, | |
26 | boost::detail::winapi::DWORD_ nSize | |
27 | ); | |
28 | ||
29 | BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI SetEnvironmentVariableA( | |
30 | boost::detail::winapi::LPCSTR_ lpName, | |
31 | boost::detail::winapi::LPCSTR_ lpValue | |
32 | ); | |
33 | #endif // !defined( BOOST_NO_ANSI_APIS ) | |
34 | ||
35 | BOOST_SYMBOL_IMPORT boost::detail::winapi::LPWSTR_ WINAPI GetEnvironmentStringsW(); | |
36 | BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI FreeEnvironmentStringsW(boost::detail::winapi::LPWSTR_); | |
37 | ||
38 | BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetEnvironmentVariableW( | |
39 | boost::detail::winapi::LPCWSTR_ lpName, | |
40 | boost::detail::winapi::LPWSTR_ lpBuffer, | |
41 | boost::detail::winapi::DWORD_ nSize | |
42 | ); | |
43 | ||
44 | BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI SetEnvironmentVariableW( | |
45 | boost::detail::winapi::LPCWSTR_ lpName, | |
46 | boost::detail::winapi::LPCWSTR_ lpValue | |
47 | ); | |
48 | } // extern "C" | |
49 | #endif // !defined( BOOST_USE_WINDOWS_H ) | |
50 | ||
51 | namespace boost { namespace detail { namespace winapi { | |
52 | ||
53 | #if !defined( BOOST_NO_ANSI_APIS ) | |
54 | using ::GetEnvironmentStringsA; | |
55 | using ::FreeEnvironmentStringsA; | |
56 | using ::GetEnvironmentVariableA; | |
57 | using ::SetEnvironmentVariableA; | |
58 | #endif // !defined( BOOST_NO_ANSI_APIS ) | |
59 | ||
60 | using ::GetEnvironmentStringsW; | |
61 | using ::FreeEnvironmentStringsW; | |
62 | using ::GetEnvironmentVariableW; | |
63 | using ::SetEnvironmentVariableW; | |
64 | ||
65 | template< typename Char > | |
66 | Char* get_environment_strings(); | |
67 | ||
68 | #if !defined( BOOST_NO_ANSI_APIS ) | |
69 | ||
70 | template< > | |
71 | BOOST_FORCEINLINE char* get_environment_strings< char >() | |
72 | { | |
73 | return GetEnvironmentStringsA(); | |
74 | } | |
75 | ||
76 | BOOST_FORCEINLINE BOOL_ free_environment_strings(boost::detail::winapi::LPSTR_ p) | |
77 | { | |
78 | return FreeEnvironmentStringsA(p); | |
79 | } | |
80 | ||
81 | BOOST_FORCEINLINE DWORD_ get_environment_variable(LPCSTR_ name, LPSTR_ buffer, DWORD_ size) | |
82 | { | |
83 | return GetEnvironmentVariableA(name, buffer, size); | |
84 | } | |
85 | ||
86 | BOOST_FORCEINLINE BOOL_ set_environment_variable(LPCSTR_ name, LPCSTR_ value) | |
87 | { | |
88 | return SetEnvironmentVariableA(name, value); | |
89 | } | |
90 | ||
91 | #endif // !defined( BOOST_NO_ANSI_APIS ) | |
92 | ||
93 | template< > | |
94 | BOOST_FORCEINLINE wchar_t* get_environment_strings< wchar_t >() | |
95 | { | |
96 | return GetEnvironmentStringsW(); | |
97 | } | |
98 | ||
99 | BOOST_FORCEINLINE BOOL_ free_environment_strings(boost::detail::winapi::LPWSTR_ p) | |
100 | { | |
101 | return FreeEnvironmentStringsW(p); | |
102 | } | |
103 | ||
104 | BOOST_FORCEINLINE DWORD_ get_environment_variable(LPCWSTR_ name, LPWSTR_ buffer, DWORD_ size) | |
105 | { | |
106 | return GetEnvironmentVariableW(name, buffer, size); | |
107 | } | |
108 | ||
109 | BOOST_FORCEINLINE BOOL_ set_environment_variable(LPCWSTR_ name, LPCWSTR_ value) | |
110 | { | |
111 | return SetEnvironmentVariableW(name, value); | |
112 | } | |
113 | ||
114 | } // namespace winapi | |
115 | } // namespace detail | |
116 | } // namespace boost | |
117 | ||
118 | #endif // BOOST_DETAIL_WINAPI_ENVIRONMENT_HPP_ |