msvcrt: Implemented the _(w)getenv_s functions.

This commit is contained in:
Eric Pouech 2010-11-07 19:11:26 +01:00 committed by Alexandre Julliard
parent 2e7dc35786
commit b0c3dc35a8
5 changed files with 62 additions and 7 deletions

View File

@ -1356,7 +1356,7 @@
@ cdecl _wgetdcwd(long wstr long) msvcrt._wgetdcwd
@ stub _wgetdcwd_nolock
@ cdecl _wgetenv(wstr) msvcrt._wgetenv
@ stub _wgetenv_s
@ cdecl _wgetenv_s(ptr ptr long wstr) msvcrt._wgetenv_s
@ cdecl _wmakepath(ptr wstr wstr wstr wstr) msvcrt._wmakepath
@ cdecl _wmakepath_s(ptr long wstr wstr wstr wstr) msvcrt._wmakepath_s
@ cdecl _wmkdir(wstr) msvcrt._wmkdir
@ -1483,7 +1483,7 @@
@ cdecl getc(ptr) msvcrt.getc
@ cdecl getchar() msvcrt.getchar
@ cdecl getenv(str) msvcrt.getenv
@ stub getenv_s
@ cdecl getenv_s(ptr ptr long str) msvcrt.getenv_s
@ cdecl gets(str) msvcrt.gets
@ stub gets_s
@ cdecl getwc(ptr) msvcrt.getwc

View File

@ -1209,7 +1209,7 @@
@ cdecl _wgetdcwd(long wstr long) msvcrt._wgetdcwd
@ stub _wgetdcwd_nolock
@ cdecl _wgetenv(wstr) msvcrt._wgetenv
@ stub _wgetenv_s
@ cdecl _wgetenv_s(ptr ptr long wstr) msvcrt._wgetenv_s
@ extern _winmajor msvcrt._winmajor
@ extern _winminor msvcrt._winminor
@ extern _winver msvcrt._winver
@ -1339,7 +1339,7 @@
@ cdecl getc(ptr) msvcrt.getc
@ cdecl getchar() msvcrt.getchar
@ cdecl getenv(str) msvcrt.getenv
@ stub getenv_s
@ cdecl getenv_s(ptr ptr long str) msvcrt.getenv_s
@ cdecl gets(str) msvcrt.gets
@ stub gets_s
@ cdecl getwc(ptr) msvcrt.getwc

View File

@ -1196,7 +1196,7 @@
@ cdecl _wgetdcwd(long wstr long) msvcrt._wgetdcwd
@ stub _wgetdcwd_nolock
@ cdecl _wgetenv(wstr) msvcrt._wgetenv
@ stub _wgetenv_s
@ cdecl _wgetenv_s(ptr ptr long wstr) msvcrt._wgetenv_s
@ cdecl _wmakepath(ptr wstr wstr wstr wstr) msvcrt._wmakepath
@ cdecl _wmakepath_s(ptr long wstr wstr wstr wstr) msvcrt._wmakepath_s
@ cdecl _wmkdir(wstr) msvcrt._wmkdir

View File

@ -261,3 +261,58 @@ int _wdupenv_s(MSVCRT_wchar_t **buffer, MSVCRT_size_t *numberOfElements,
if (numberOfElements) *numberOfElements = sz;
return 0;
}
/******************************************************************
* getenv_s (MSVCRT.@)
*/
int getenv_s(MSVCRT_size_t *pReturnValue, char* buffer, MSVCRT_size_t numberOfElements, const char *varname)
{
char* e;
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL) ||
!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0)) ||
!MSVCRT_CHECK_PMT(varname != NULL))
{
return *MSVCRT__errno() = MSVCRT_EINVAL;
}
if (!(e = MSVCRT_getenv(varname)))
{
*pReturnValue = 0;
return *MSVCRT__errno() = MSVCRT_EINVAL;
}
*pReturnValue = strlen(e) + 1;
if (numberOfElements < *pReturnValue)
{
return *MSVCRT__errno() = MSVCRT_ERANGE;
}
strcpy(buffer, e);
return 0;
}
/******************************************************************
* _wgetenv_s (MSVCRT.@)
*/
int _wgetenv_s(MSVCRT_size_t *pReturnValue, MSVCRT_wchar_t *buffer, MSVCRT_size_t numberOfElements,
const MSVCRT_wchar_t *varname)
{
MSVCRT_wchar_t* e;
if (!MSVCRT_CHECK_PMT(pReturnValue != NULL) ||
!MSVCRT_CHECK_PMT(!(buffer == NULL && numberOfElements > 0)) ||
!MSVCRT_CHECK_PMT(varname != NULL))
{
return *MSVCRT__errno() = MSVCRT_EINVAL;
}
if (!(e = _wgetenv(varname)))
{
*pReturnValue = 0;
return *MSVCRT__errno() = MSVCRT_EINVAL;
}
*pReturnValue = strlenW(e) + 1;
if (numberOfElements < *pReturnValue)
{
return *MSVCRT__errno() = MSVCRT_ERANGE;
}
strcpyW(buffer, e);
return 0;
}

View File

@ -1128,7 +1128,7 @@
@ cdecl _wgetcwd(wstr long)
@ cdecl _wgetdcwd(long wstr long)
@ cdecl _wgetenv(wstr)
# stub _wgetenv_s
@ cdecl _wgetenv_s(ptr ptr long wstr)
@ extern _winmajor MSVCRT__winmajor
@ extern _winminor MSVCRT__winminor
# stub _winput_s
@ -1273,7 +1273,7 @@
@ cdecl getc(ptr) MSVCRT_getc
@ cdecl getchar() MSVCRT_getchar
@ cdecl getenv(str) MSVCRT_getenv
# stub getenv_s
@ cdecl getenv_s(ptr ptr long str)
@ cdecl gets(str) MSVCRT_gets
@ cdecl getwc(ptr) MSVCRT_getwc
@ cdecl getwchar() MSVCRT_getwchar