xref: /reactos/sdk/lib/crt/stdlib/putenv.c (revision 8a978a17)
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/sdk/crt/stdlib/putenv.c
5  * PURPOSE:     Unknown
6  * PROGRAMER:   Unknown
7  * UPDATE HISTORY:
8  *              25/11/05: Added license header
9  */
10 #include <precomp.h>
11 
12 /* misc/environ.c */
13 int SetEnv(const wchar_t *option);
14 
15 /*
16  * @implemented
17  */
18 int _putenv(const char* val)
19 {
20    int size, result;
21    wchar_t *woption;
22 
23    size = MultiByteToWideChar(CP_ACP, 0, val, -1, NULL, 0);
24    woption = malloc(size* sizeof(wchar_t));
25    if (woption == NULL)
26       return -1;
27    MultiByteToWideChar(CP_ACP, 0, val, -1, woption, size);
28    result = SetEnv(woption);
29    free(woption);
30    return result;
31 }
32