#include <precomp.h>
Go to the source code of this file.
◆ _wputenv()
Definition at line 10 of file wputenv.c.
11{
13}
int SetEnv(const wchar_t *option)
◆ SetEnv()
Internal version of _wputenv and _putenv. It works duplicates the original envirnments created during initilization if needed to prevent having spurious pointers floating around. Then it updates the internal environment tables (_environ and _wenviron) and at last updates the OS environemnt.
Note that there can happen situation when the internal [_w]environ arrays will be updated, but the OS environment update will fail. In this case we don't undo the changes to the [_w]environ tables to comply with the Microsoft behaviour (and it's also much easier :-).
Definition at line 210 of file environ.c.
211{
212 wchar_t *epos, *
name;
213 wchar_t **wenvptr;
214 wchar_t *woption;
215 char *mboption;
217 wchar_t **wnewenv;
218 char **mbnewenv;
219
221 return -1;
223
224
226 {
228 return -1;
229 }
231 {
234 return -1;
235 }
236
237
240 return -1;
243
244
246 {
248 {
249 found = 1;
250 break;
251 }
252 }
253
255 {
256 if (!found)
257 {
259 return 0;
260 }
261
262
265 *wenvptr = *(wenvptr + 1);
269
270
271
272
276 if (mbnewenv !=
NULL)
278
280 }
281 else
282 {
283
286 {
288 return -1;
289 }
290
291
294 if (mboption ==
NULL)
295 {
298 return -1;
299 }
301
302 if (found)
303 {
304
306 *wenvptr = woption;
309 }
310 else
311 {
312
314 ;
315
316
318 {
322 return -1;
323 }
326 {
330 return -1;
331 }
333
334
339 }
340
341
343 }
345
347}
#define WideCharToMultiByte
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
GLuint GLuint GLsizei count
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
char ** DuplicateEnvironment(char **original_environment, int wide)
Referenced by _wputenv().