2 #include <msvcrt/stdlib.h>
3 #include <msvcrt/string.h>
6 #include <msvcrt/msvcrtdbg.h>
9 extern int BlockEnvToEnviron(); // defined in misc/dllmain.c
11 int _putenv(const char *val)
17 DPRINT("_putenv('%s')\n", val);
18 epos = strchr(val, '=');
21 buffer = (char*)malloc(epos - val + 1);
24 strncpy(buffer, val, epos - val);
25 buffer[epos - val] = 0;
26 res = SetEnvironmentVariableA(buffer,epos+1);
28 if (BlockEnvToEnviron()) return 0;
32 int _wputenv(const wchar_t *val)
38 DPRINT("_wputenv('%S')\n", val);
39 epos = wcsrchr(val, L'=');
42 buffer = (char*)malloc((epos - val + 1) * sizeof (wchar_t));
45 wcsncpy(buffer, val, epos - val);
46 buffer[epos - val] = 0;
47 res = SetEnvironmentVariableW(buffer,epos+1);
49 if (BlockEnvToEnviron() ) return 0;