d6329d827e090d25ae7a031e305d4b5012d90b7a
[platform/upstream/freerdp.git] / winpr / include / winpr / environment.h
1 /**
2  * WinPR: Windows Portable Runtime
3  * Process Environment Functions
4  *
5  * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  * Copyright 2013 Thincast Technologies GmbH
7  * Copyright 2013 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *     http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21
22 #ifndef WINPR_ENVIRONMENT_H
23 #define WINPR_ENVIRONMENT_H
24
25 #include <winpr/winpr.h>
26 #include <winpr/wtypes.h>
27
28 #ifndef _WIN32
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 WINPR_API DWORD GetCurrentDirectoryA(DWORD nBufferLength, LPSTR lpBuffer);
35 WINPR_API DWORD GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer);
36
37 WINPR_API BOOL SetCurrentDirectoryA(LPCSTR lpPathName);
38 WINPR_API BOOL SetCurrentDirectoryW(LPCWSTR lpPathName);
39
40 WINPR_API DWORD SearchPathA(LPCSTR lpPath, LPCSTR lpFileName, LPCSTR lpExtension, DWORD nBufferLength, LPSTR lpBuffer, LPSTR* lpFilePart);
41 WINPR_API DWORD SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR* lpFilePart);
42
43 WINPR_API LPSTR GetCommandLineA(VOID);
44 WINPR_API LPWSTR GetCommandLineW(VOID);
45
46 WINPR_API BOOL NeedCurrentDirectoryForExePathA(LPCSTR ExeName);
47 WINPR_API BOOL NeedCurrentDirectoryForExePathW(LPCWSTR ExeName);
48
49 WINPR_API DWORD GetEnvironmentVariableA(LPCSTR lpName, LPSTR lpBuffer, DWORD nSize);
50 WINPR_API DWORD GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, DWORD nSize);
51
52 WINPR_API BOOL SetEnvironmentVariableA(LPCSTR lpName, LPCSTR lpValue);
53 WINPR_API BOOL SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue);
54
55 /**
56  * A brief history of the GetEnvironmentStrings functions:
57  * http://blogs.msdn.com/b/oldnewthing/archive/2013/01/17/10385718.aspx
58  */
59
60 WINPR_API LPCH GetEnvironmentStrings(VOID);
61 WINPR_API LPWCH GetEnvironmentStringsW(VOID);
62
63 WINPR_API BOOL SetEnvironmentStringsA(LPCH NewEnvironment);
64 WINPR_API BOOL SetEnvironmentStringsW(LPWCH NewEnvironment);
65
66 WINPR_API DWORD ExpandEnvironmentStringsA(LPCSTR lpSrc, LPSTR lpDst, DWORD nSize);
67 WINPR_API DWORD ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize);
68
69 WINPR_API BOOL FreeEnvironmentStringsA(LPCH lpszEnvironmentBlock);
70 WINPR_API BOOL FreeEnvironmentStringsW(LPWCH lpszEnvironmentBlock);
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #ifdef UNICODE
77 #define GetCurrentDirectory             GetCurrentDirectoryW
78 #define SetCurrentDirectory             SetCurrentDirectoryW
79 #define SearchPath                      SearchPathW
80 #define GetCommandLine                  GetCommandLineW
81 #define NeedCurrentDirectoryForExePath  NeedCurrentDirectoryForExePathW
82 #define GetEnvironmentVariable          GetEnvironmentVariableW
83 #define SetEnvironmentVariable          SetEnvironmentVariableW
84 #define GetEnvironmentStrings           GetEnvironmentStringsW
85 #define SetEnvironmentStrings           SetEnvironmentStringsW
86 #define ExpandEnvironmentStrings        ExpandEnvironmentStringsW
87 #define FreeEnvironmentStrings          FreeEnvironmentStringsW
88 #else
89 #define GetCurrentDirectory             GetCurrentDirectoryA
90 #define SetCurrentDirectory             SetCurrentDirectoryA
91 #define SearchPath                      SearchPathA
92 #define GetCommandLine                  GetCommandLineA
93 #define NeedCurrentDirectoryForExePath  NeedCurrentDirectoryForExePathA
94 #define GetEnvironmentVariable          GetEnvironmentVariableA
95 #define SetEnvironmentVariable          SetEnvironmentVariableA
96 #define GetEnvironmentStringsA          GetEnvironmentStrings
97 #define SetEnvironmentStrings           SetEnvironmentStringsA
98 #define ExpandEnvironmentStrings        ExpandEnvironmentStringsA
99 #define FreeEnvironmentStrings          FreeEnvironmentStringsA
100 #endif
101
102 #endif
103
104 #ifdef __cplusplus
105 extern "C" {
106 #endif
107
108 WINPR_API LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge);
109
110 WINPR_API DWORD GetEnvironmentVariableEBA(LPCSTR envBlock, LPCSTR lpName, LPSTR lpBuffer, DWORD nSize);
111 WINPR_API BOOL SetEnvironmentVariableEBA(LPSTR* envBlock, LPCSTR lpName, LPCSTR lpValue);
112
113 #ifdef __cplusplus
114 }
115 #endif
116
117 #endif /* WINPR_ENVIRONMENT_H */
118