msvcrt: Implement _get_environ and _get_wenviron.

Signed-off-by: Martin Storsjo <martin@martin.st>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Martin Storsjo 2019-04-10 15:51:55 +03:00 committed by Alexandre Julliard
parent c4433a06b7
commit f20be3b00c
3 changed files with 50 additions and 2 deletions

View file

@ -310,3 +310,19 @@ int CDECL _wgetenv_s(MSVCRT_size_t *pReturnValue, MSVCRT_wchar_t *buffer, MSVCRT
strcpyW(buffer, e);
return 0;
}
/*********************************************************************
* _get_environ (MSVCRT.@)
*/
void CDECL MSVCRT__get_environ(char ***ptr)
{
*ptr = MSVCRT__environ;
}
/*********************************************************************
* _get_wenviron (MSVCRT.@)
*/
void CDECL MSVCRT__get_wenviron(MSVCRT_wchar_t ***ptr)
{
*ptr = MSVCRT__wenviron;
}

View file

@ -501,7 +501,7 @@
@ cdecl _gcvt_s(ptr long double long) MSVCRT__gcvt_s
@ cdecl _get_current_locale() MSVCRT__get_current_locale
@ cdecl _get_doserrno(ptr)
# stub _get_environ(ptr)
@ cdecl _get_environ(ptr) MSVCRT__get_environ
@ cdecl _get_errno(ptr)
# stub _get_fileinfo(ptr)
@ cdecl _get_fmode(ptr) MSVCRT__get_fmode
@ -512,7 +512,7 @@
@ cdecl _get_output_format() MSVCRT__get_output_format
@ cdecl _get_pgmptr(ptr)
@ cdecl _get_sbh_threshold()
# stub _get_wenviron(ptr)
@ cdecl _get_wenviron(ptr) MSVCRT__get_wenviron
@ cdecl _get_winmajor(ptr) MSVCRT__get_winmajor
@ cdecl _get_winminor(ptr) MSVCRT__get_winminor
# stub _get_winver(ptr)

View file

@ -47,6 +47,8 @@ void __cdecl __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, int *);
static char ***(__cdecl *p__p__environ)(void);
static WCHAR ***(__cdecl *p__p__wenviron)(void);
static void (*p_get_environ)(char ***);
static void (*p_get_wenviron)(WCHAR ***);
static char ***p_environ;
static WCHAR ***p_wenviron;
@ -59,6 +61,8 @@ static void init(void)
p__p__wenviron = (void *)GetProcAddress(hmod, "__p__wenviron");
p_environ = (void *)GetProcAddress(hmod, "_environ");
p_wenviron = (void *)GetProcAddress(hmod, "_wenviron");
p_get_environ = (void *)GetProcAddress(hmod, "_get_environ");
p_get_wenviron = (void *)GetProcAddress(hmod, "_get_wenviron");
}
static void test_system(void)
@ -95,6 +99,16 @@ static void test__environ(void)
else
win_skip( "__p__environ() is not available\n" );
if (p_get_environ)
{
char **retptr;
p_get_environ(&retptr);
ok( retptr == *p_environ,
"Expected _environ pointers to be identical\n" );
}
else
win_skip( "_get_environ() is not available\n" );
/* Note that msvcrt from Windows versions older than Vista
* expects the mode pointer parameter to be valid.*/
__getmainargs(&argc, &argv, &envp, 0, &mode);
@ -151,6 +165,16 @@ static void test__wenviron(void)
else
win_skip( "__p__wenviron() is not available\n" );
if (p_get_wenviron)
{
WCHAR **retptr;
p_get_wenviron(&retptr);
ok( retptr == NULL,
"Expected _wenviron pointers to be NULL\n" );
}
else
win_skip( "_get_wenviron() is not available\n" );
/* __getmainargs doesn't initialize _wenviron. */
__getmainargs(&argc, &argv, &envp, 0, &mode);
@ -191,6 +215,14 @@ static void test__wenviron(void)
"Expected _wenviron pointers to be identical\n" );
}
if (p_get_wenviron)
{
WCHAR **retptr;
p_get_wenviron(&retptr);
ok( retptr == *p_wenviron,
"Expected _wenviron pointers to be identical\n" );
}
for (i = 0; ; i++)
{
if ((*p_wenviron)[i])