[PATCH 04/14] [Msvcrt*]: implemented _wputenv_s

Eric Pouech eric.pouech at orange.fr
Tue Nov 2 16:02:59 CDT 2010




A+
---

 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 498abfc..bb481d9 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 3d6bb47..0b6dcde 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 b0089af..9ef0a80 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 13fd742..4d34221 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -814,7 +814,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)
@@ -1142,7 +1142,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-patches mailing list