Eric Pouech : msvcrt: Implemented _wputenv_s.

Alexandre Julliard julliard at winehq.org
Wed Nov 3 11:37:03 CDT 2010


Module: wine
Branch: master
Commit: 356b2d2bc07aabf771908eb4d217d42fb4cb949e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=356b2d2bc07aabf771908eb4d217d42fb4cb949e

Author: Eric Pouech <eric.pouech at orange.fr>
Date:   Tue Nov  2 22:02:59 2010 +0100

msvcrt: Implemented _wputenv_s.

---

 dlls/msvcr100/msvcr100.spec |    4 +-
 dlls/msvcr80/msvcr80.spec   |    4 +-
 dlls/msvcr90/msvcr90.spec   |    4 +-
 dlls/msvcrt/environ.c       |   52 +++++++++++++++++++++++++++++++++++++++++++
 dlls/msvcrt/msvcrt.spec     |    4 +-
 5 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index d4e5c38..6035f70 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1035,7 +1035,7 @@
 @ cdecl _putch(long) msvcrt._putch
 @ stub _putch_nolock
 @ cdecl _putenv(str) msvcrt._putenv
-@ stub _putenv_s
+@ cdecl _putenv_s(str str) msvcrt._putenv_s
 @ cdecl _putw(long ptr) msvcrt._putw
 @ stub _putwch
 @ stub _putwch_nolock
@@ -1371,7 +1371,7 @@
 @ stub _wprintf_p_l
 @ stub _wprintf_s_l
 @ cdecl _wputenv(wstr) msvcrt._wputenv
-@ stub _wputenv_s
+@ cdecl _wputenv_s(wstr wstr) msvcrt._wputenv_s
 @ cdecl _wremove(wstr) msvcrt._wremove
 @ cdecl _wrename(wstr wstr) msvcrt._wrename
 @ cdecl _write(long ptr long) msvcrt._write
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 7fb8eca..ce58a11 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -883,7 +883,7 @@
 @ cdecl _putch(long) msvcrt._putch
 @ stub _putch_nolock
 @ cdecl _putenv(str) msvcrt._putenv
-@ stub _putenv_s
+@ cdecl _putenv_s(str str) msvcrt._putenv_s
 @ cdecl _putw(long ptr) msvcrt._putw
 @ stub _putwch
 @ stub _putwch_nolock
@@ -1227,7 +1227,7 @@
 @ stub _wprintf_p_l
 @ stub _wprintf_s_l
 @ cdecl _wputenv(wstr) msvcrt._wputenv
-@ stub _wputenv_s
+@ cdecl _wputenv_s(wstr wstr) msvcrt._wputenv_s
 @ cdecl _wremove(wstr) msvcrt._wremove
 @ cdecl _wrename(wstr wstr) msvcrt._wrename
 @ cdecl _write(long ptr long) msvcrt._write
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index c38e5f9..d9f6fb4 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -869,7 +869,7 @@
 @ cdecl _putch(long) msvcrt._putch
 @ stub _putch_nolock
 @ cdecl _putenv(str) msvcrt._putenv
-@ stub _putenv_s
+@ cdecl _putenv_s(str str) msvcrt._putenv_s
 @ cdecl _putw(long ptr) msvcrt._putw
 @ stub _putwch
 @ stub _putwch_nolock
@@ -1211,7 +1211,7 @@
 @ stub _wprintf_p_l
 @ stub _wprintf_s_l
 @ cdecl _wputenv(wstr) msvcrt._wputenv
-@ stub _wputenv_s
+@ cdecl _wputenv_s(wstr wstr) msvcrt._wputenv_s
 @ cdecl _wremove(wstr) msvcrt._wremove
 @ cdecl _wrename(wstr wstr) msvcrt._wrename
 @ cdecl _write(long ptr long) msvcrt._write
diff --git a/dlls/msvcrt/environ.c b/dlls/msvcrt/environ.c
index add5905..75178bd 100644
--- a/dlls/msvcrt/environ.c
+++ b/dlls/msvcrt/environ.c
@@ -160,3 +160,55 @@ finish:
  HeapFree(GetProcessHeap(), 0, name);
  return ret;
 }
+
+/*********************************************************************
+ *		_putenv_s (MSVCRT.@)
+ */
+int CDECL _putenv_s(const char *name, const char *value)
+{
+    int ret;
+
+    TRACE("%s %s\n", debugstr_a(name), debugstr_a(value));
+
+    if (!MSVCRT_CHECK_PMT(name != NULL) || !MSVCRT_CHECK_PMT(value != NULL))
+    {
+        *MSVCRT__errno() = MSVCRT_EINVAL;
+        return -1;
+    }
+
+    ret = SetEnvironmentVariableA(name, value[0] ? value : NULL) ? 0 : -1;
+
+    /* _putenv returns success on deletion of nonexistent variable, unlike [Rtl]SetEnvironmentVariable */
+    if ((ret == -1) && (GetLastError() == ERROR_ENVVAR_NOT_FOUND)) ret = 0;
+
+    MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(MSVCRT__environ);
+    MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(MSVCRT__wenviron);
+
+    return ret;
+}
+
+/*********************************************************************
+ *		_wputenv_s (MSVCRT.@)
+ */
+int CDECL _wputenv_s(const MSVCRT_wchar_t *name, const MSVCRT_wchar_t *value)
+{
+    int ret;
+
+    TRACE("%s %s\n", debugstr_w(name), debugstr_w(value));
+
+    if (!MSVCRT_CHECK_PMT(name != NULL) || !MSVCRT_CHECK_PMT(value != NULL))
+    {
+        *MSVCRT__errno() = MSVCRT_EINVAL;
+        return -1;
+    }
+
+    ret = SetEnvironmentVariableW(name, value[0] ? value : NULL) ? 0 : -1;
+
+    /* _putenv returns success on deletion of nonexistent variable, unlike [Rtl]SetEnvironmentVariable */
+    if ((ret == -1) && (GetLastError() == ERROR_ENVVAR_NOT_FOUND)) ret = 0;
+
+    MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(MSVCRT__environ);
+    MSVCRT__wenviron = msvcrt_SnapshotOfEnvironmentW(MSVCRT__wenviron);
+
+    return ret;
+}
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index a1cd124..af86f2e 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -817,7 +817,7 @@
 @ cdecl _purecall()
 @ cdecl _putch(long)
 @ cdecl _putenv(str)
-# stub _putenv_s
+@ cdecl _putenv_s(str str)
 @ cdecl _putw(long ptr) MSVCRT__putw
 # stub _putwch
 @ cdecl _putws(wstr)
@@ -1146,7 +1146,7 @@
 # stub _wprintf_p_l
 # stub _wprintf_s_l
 @ cdecl _wputenv(wstr)
-# stub _wputenv_s
+@ cdecl _wputenv_s(wstr wstr)
 @ cdecl _wremove(wstr)
 @ cdecl _wrename(wstr wstr)
 @ cdecl _write(long ptr long) MSVCRT__write




More information about the wine-cvs mailing list