msvcrt: Implement _asctime_s and _wasctime_s.

Eryk Wieliczko ewdevel at gmail.com
Tue Nov 2 18:31:02 CDT 2010


Implemented _asctime_s and _wasctime_s as wrappers for asctime and _wasctime
with error handling.
---
 dlls/msvcr100/msvcr100.spec |    4 +-
 dlls/msvcr80/msvcr80.spec   |    4 +-
 dlls/msvcr90/msvcr90.spec   |    4 +-
 dlls/msvcrt/msvcrt.spec     |    4 +-
 dlls/msvcrt/time.c          |   55 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index b79e9b5..6471e6b 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1276,7 +1276,7 @@
 @ cdecl _waccess(wstr long) msvcrt._waccess
 @ stub _waccess_s
 @ cdecl _wasctime(ptr) msvcrt._wasctime
-@ stub _wasctime_s
+@ cdecl _wasctime_s(wstr long ptr) msvcrt._wasctime_s
 @ stub _wassert
 @ cdecl _wchdir(wstr) msvcrt._wchdir
 @ cdecl _wchmod(wstr long) msvcrt._wchmod
@@ -1423,7 +1423,7 @@
 @ cdecl abs(long) msvcrt.abs
 @ cdecl acos(double) msvcrt.acos
 @ cdecl asctime(ptr) msvcrt.asctime
-@ stub asctime_s
+@ cdecl asctime_s(wstr long ptr) msvcrt.asctime_s
 @ cdecl asin(double) msvcrt.asin
 @ cdecl atan(double) msvcrt.atan
 @ cdecl atan2(double double) msvcrt.atan2
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index ccf4ed9..5041b01 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -1129,7 +1129,7 @@
 @ cdecl _waccess(wstr long) msvcrt._waccess
 @ stub _waccess_s
 @ cdecl _wasctime(ptr) msvcrt._wasctime
-@ stub _wasctime_s
+@ cdecl _wasctime_s(wstr long ptr) msvcrt._wasctime_s
 @ stub _wassert
 @ cdecl _wchdir(wstr) msvcrt._wchdir
 @ cdecl _wchmod(wstr long) msvcrt._wchmod
@@ -1279,7 +1279,7 @@
 @ cdecl abs(long) msvcrt.abs
 @ cdecl acos(double) msvcrt.acos
 @ cdecl asctime(ptr) msvcrt.asctime
-@ stub asctime_s
+@ cdecl asctime_s(str long ptr) msvcrt.asctime_s
 @ cdecl asin(double) msvcrt.asin
 @ cdecl atan(double) msvcrt.atan
 @ cdecl atan2(double double) msvcrt.atan2
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index fc341fe..f1bb7e9 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -1116,7 +1116,7 @@
 @ cdecl _waccess(wstr long) msvcrt._waccess
 @ stub _waccess_s
 @ cdecl _wasctime(ptr) msvcrt._wasctime
-@ stub _wasctime_s
+@ cdecl _wasctime_s(wstr long ptr) msvcrt._wasctime_s
 @ stub _wassert
 @ cdecl _wchdir(wstr) msvcrt._wchdir
 @ cdecl _wchmod(wstr long) msvcrt._wchmod
@@ -1263,7 +1263,7 @@
 @ cdecl abs(long) msvcrt.abs
 @ cdecl acos(double) msvcrt.acos
 @ cdecl asctime(ptr) msvcrt.asctime
-@ stub asctime_s
+@ cdecl asctime_s(wstr long ptr) msvcrt.asctime_s
 @ cdecl asin(double) msvcrt.asin
 @ cdecl atan(double) msvcrt.atan
 @ cdecl atan2(double double) msvcrt.atan2
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 5fff5fb..848519e 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -1049,7 +1049,7 @@
 @ cdecl _waccess(wstr long)
 # stub _waccess_s
 @ cdecl _wasctime(ptr) MSVCRT__wasctime
-# stub _wasctime_s
+@ cdecl _wasctime_s(ptr long ptr) MSVCRT__wasctime_s
 # stub _wassert
 @ cdecl _wchdir(wstr)
 @ cdecl _wchmod(wstr long)
@@ -1201,7 +1201,7 @@
 @ cdecl acos(double) MSVCRT_acos
 @ cdecl -arch=x86_64 acosf(float) MSVCRT_acosf
 @ cdecl asctime(ptr) MSVCRT_asctime
-# stub asctime_s
+@ cdecl asctime_s(ptr long ptr) MSVCRT_asctime_s
 @ cdecl asin(double) MSVCRT_asin
 @ cdecl atan(double) MSVCRT_atan
 @ cdecl atan2(double double) MSVCRT_atan2
diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c
index 9d59625..261c57a 100644
--- a/dlls/msvcrt/time.c
+++ b/dlls/msvcrt/time.c
@@ -35,6 +35,7 @@
 #include "mtdll.h"
 #include "winbase.h"
 #include "winnls.h"
+#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
@@ -835,6 +836,33 @@ char * CDECL MSVCRT_asctime(const struct MSVCRT_tm *mstm)
 }
 
 /*********************************************************************
+ *		asctime_s (MSVCRT.@)
+ */
+MSVCRT_long CDECL MSVCRT_asctime_s(char *output, MSVCRT_size_t max, const struct MSVCRT_tm *mstm)
+{
+    char *buffer;
+    MSVCRT_size_t bufflen;
+
+    if (output && max > 0)
+	output[0] = '\0';
+    if (!output)
+    {
+        *MSVCRT__errno() = MSVCRT_EINVAL;
+        return MSVCRT_EINVAL;
+    }
+
+    buffer = MSVCRT_asctime( mstm );
+    bufflen = strlen( buffer )+1;
+    if (bufflen > max)
+    {
+        *MSVCRT__errno() = MSVCRT_EINVAL;
+        return MSVCRT_EINVAL;
+    }
+    memcpy( output, buffer, bufflen );
+    return 0;
+}
+
+/*********************************************************************
  *		_wasctime (MSVCRT.@)
  */
 MSVCRT_wchar_t * CDECL MSVCRT__wasctime(const struct MSVCRT_tm *mstm)
@@ -857,6 +885,33 @@ MSVCRT_wchar_t * CDECL MSVCRT__wasctime(const struct MSVCRT_tm *mstm)
 }
 
 /*********************************************************************
+ *		_wasctime_s (MSVCRT.@)
+ */
+MSVCRT_long CDECL MSVCRT__wasctime_s(MSVCRT_wchar_t *output, MSVCRT_size_t max, const struct MSVCRT_tm *mstm)
+{
+    MSVCRT_wchar_t *buffer;
+    MSVCRT_size_t bufflen;
+
+    if (output && max > 0)
+	output[0] = '\0';
+    if (!output)
+    {
+        *MSVCRT__errno() = MSVCRT_EINVAL;
+        return MSVCRT_EINVAL;
+    }
+
+    buffer = MSVCRT__wasctime( mstm );
+    bufflen = strlenW( buffer )+1;
+    if (bufflen > max)
+    {
+        *MSVCRT__errno() = MSVCRT_EINVAL;
+        return MSVCRT_EINVAL;
+    }
+    memcpy( output, buffer, bufflen*sizeof(MSVCRT_wchar_t) );
+    return 0;
+}
+
+/*********************************************************************
  *		_ctime64 (MSVCRT.@)
  */
 char * CDECL MSVCRT__ctime64(const MSVCRT___time64_t *time)
-- 
1.7.0.4




More information about the wine-patches mailing list