Module: wine Branch: master Commit: fc186c3bdab8c1b42e402f3db1dda7be201b9027 URL: http://source.winehq.org/git/wine.git/?a=commit;h=fc186c3bdab8c1b42e402f3db1...
Author: Eric Pouech eric.pouech@orange.fr Date: Tue Nov 2 22:03:05 2010 +0100
msvcrt: Implemented _(w)dupenv_s.
---
dlls/msvcr100/msvcr100.spec | 4 +- dlls/msvcr80/msvcr80.spec | 4 +- dlls/msvcr90/msvcr90.spec | 4 +- dlls/msvcrt/environ.c | 49 +++++++++++++++++++++++++++++++++++++++++++ dlls/msvcrt/msvcrt.spec | 2 + 5 files changed, 57 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 6035f70..9ceb3e2 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 ce58a11..2dec3a4 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 d9f6fb4..9b87c0a 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 75178bd..99efd4b 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 af86f2e..ca2607c 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)