diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 6035f700bba..9ceb3e2f4ab 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -581,7 +581,7 @@ @ extern _dstbias msvcrt._dstbias @ cdecl _dup(long) msvcrt._dup @ cdecl _dup2(long long) msvcrt._dup2 -@ stub _dupenv_s +@ cdecl _dupenv_s(ptr ptr str) msvcrt._dupenv_s @ cdecl _ecvt(double long ptr ptr) msvcrt._ecvt @ stub _ecvt_s @ cdecl _encoded_null() msvcr90._encoded_null @@ -1327,7 +1327,7 @@ @ stub _wctomb_l @ stub _wctomb_s_l @ stub _wctype -@ stub _wdupenv_s +@ cdecl _wdupenv_s(ptr ptr wstr) msvcrt._wdupenv_s @ extern _wenviron msvcrt._wenviron @ varargs _wexecl(wstr wstr) msvcrt._wexecl @ varargs _wexecle(wstr wstr) msvcrt._wexecle diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index ce58a11a32d..2dec3a454b0 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -421,7 +421,7 @@ @ extern _dstbias msvcrt._dstbias @ cdecl _dup(long) msvcrt._dup @ cdecl _dup2(long long) msvcrt._dup2 -@ stub _dupenv_s +@ cdecl _dupenv_s(ptr ptr str) msvcrt._dupenv_s @ cdecl _ecvt(double long ptr ptr) msvcrt._ecvt @ stub _ecvt_s @ cdecl _encode_pointer(ptr) msvcr90._encode_pointer @@ -1180,7 +1180,7 @@ @ stub _wctomb_l @ stub _wctomb_s_l @ stub _wctype -@ stub _wdupenv_s +@ cdecl _wdupenv_s(ptr ptr wstr) msvcrt._wdupenv_s @ extern _wenviron msvcrt._wenviron @ varargs _wexecl(wstr wstr) msvcrt._wexecl @ varargs _wexecle(wstr wstr) msvcrt._wexecle diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index d9f6fb4b7de..9b87c0a7ee7 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -413,7 +413,7 @@ @ extern _dstbias msvcrt._dstbias @ cdecl _dup(long) msvcrt._dup @ cdecl _dup2(long long) msvcrt._dup2 -@ stub _dupenv_s +@ cdecl _dupenv_s(ptr ptr str) msvcrt._dupenv_s @ cdecl _ecvt(double long ptr ptr) msvcrt._ecvt @ stub _ecvt_s @ cdecl _encode_pointer(ptr) MSVCR90_encode_pointer @@ -1167,7 +1167,7 @@ @ stub _wctomb_l @ stub _wctomb_s_l @ stub _wctype -@ stub _wdupenv_s +@ cdecl _wdupenv_s(ptr ptr wstr) msvcrt._wdupenv_s @ extern _wenviron msvcrt._wenviron @ varargs _wexecl(wstr wstr) msvcrt._wexecl @ varargs _wexecle(wstr wstr) msvcrt._wexecle diff --git a/dlls/msvcrt/environ.c b/dlls/msvcrt/environ.c index 75178bd8cf7..99efd4b4ea4 100644 --- a/dlls/msvcrt/environ.c +++ b/dlls/msvcrt/environ.c @@ -212,3 +212,52 @@ int CDECL _wputenv_s(const MSVCRT_wchar_t *name, const MSVCRT_wchar_t *value) return ret; } + +/****************************************************************** + * _dupenv_s (MSVCRT.@) + */ +int _dupenv_s(char **buffer, MSVCRT_size_t *numberOfElements, const char *varname) +{ + char* e; + MSVCRT_size_t sz; + + if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(varname) || + !(e = MSVCRT_getenv(varname))) + { + return *MSVCRT__errno() = MSVCRT_EINVAL; + } + sz = strlen(e) + 1; + if (!(*buffer = MSVCRT_malloc(sz))) + { + if (numberOfElements) *numberOfElements = 0; + return *MSVCRT__errno() = MSVCRT_ENOMEM; + } + strcpy(*buffer, e); + if (numberOfElements) *numberOfElements = sz; + return 0; +} + +/****************************************************************** + * _wdupenv_s (MSVCRT.@) + */ +int _wdupenv_s(MSVCRT_wchar_t **buffer, MSVCRT_size_t *numberOfElements, + const MSVCRT_wchar_t *varname) +{ + MSVCRT_wchar_t* e; + MSVCRT_size_t sz; + + if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(varname) || + !(e = _wgetenv(varname))) + { + return *MSVCRT__errno() = MSVCRT_EINVAL; + } + sz = strlenW(e) + 1; + if (!(*buffer = MSVCRT_malloc(sz * sizeof(MSVCRT_wchar_t)))) + { + if (numberOfElements) *numberOfElements = 0; + return *MSVCRT__errno() = MSVCRT_ENOMEM; + } + strcpyW(*buffer, e); + if (numberOfElements) *numberOfElements = sz; + return 0; +} diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index af86f2ebd56..ca2607c9ef6 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -1480,3 +1480,5 @@ @ cdecl _wcstod_l(wstr ptr) MSVCRT__wcstod_l @ cdecl ___mb_cur_max_l_func(ptr) @ cdecl _set_purecall_handler(ptr) +@ cdecl _dupenv_s(ptr ptr str) +@ cdecl _wdupenv_s(ptr ptr str)