diff --git a/reactos/dll/win32/msvcrt/msvcrt.spec b/reactos/dll/win32/msvcrt/msvcrt.spec
index 6b5a8266ff1..d95b758e245 100644
--- a/reactos/dll/win32/msvcrt/msvcrt.spec
+++ b/reactos/dll/win32/msvcrt/msvcrt.spec
@@ -428,9 +428,9 @@
# @ varargs _fwscanf_s_l(ptr wstr ptr)
@ cdecl _gcvt(double long str)
# stub _gcvt_s
-# stub _get_doserrno
+@ cdecl _get_doserrno(ptr)
# stub _get_environ
-# stub _get_errno
+@ cdecl _get_errno(ptr)
# stub _get_fileinfo
# stub _get_fmode
# @ cdecl _get_heap_handle()
@@ -466,7 +466,7 @@
@ cdecl _getws(ptr)
@ cdecl -i386 _global_unwind2(ptr)
@ cdecl _gmtime32(ptr)
-# stub _gmtime32_s
+@ cdecl _gmtime32_s(ptr ptr)
@ cdecl _gmtime64(ptr)
@ cdecl _gmtime64_s(ptr ptr)
@ cdecl _heapadd(ptr long)
@@ -812,7 +812,7 @@
@ stdcall -i386 _seh_longjmp_unwind(ptr)
# stub _set_SSE2_enable
# stub _set_controlfp
-# stub _set_doserrno
+@ cdecl _set_doserrno(long)
@ cdecl _set_errno(long)
@ cdecl _set_error_mode(long)
# stub _set_fileinfo
diff --git a/reactos/lib/sdk/crt/crt.cmake b/reactos/lib/sdk/crt/crt.cmake
index bca6785e6de..e1e45d57d21 100644
--- a/reactos/lib/sdk/crt/crt.cmake
+++ b/reactos/lib/sdk/crt/crt.cmake
@@ -131,25 +131,35 @@ list(APPEND CRT_SOURCE
misc/stubs.c
misc/tls.c
printf/_cprintf.c
+ printf/_cwprintf.c
printf/_snprintf.c
printf/_snwprintf.c
printf/_vcprintf.c
- printf/_vsprintf_p.c
+ printf/_vcwprintf.c
printf/_vsnprintf.c
printf/_vsnwprintf.c
+ printf/_vsprintf_p.c
printf/fprintf.c
+ printf/fprintf_s.c
printf/fwprintf.c
+ printf/fwprintf_s.c
printf/printf.c
+ printf/printf_s.c
printf/sprintf.c
printf/streamout.c
printf/swprintf.c
printf/vfprintf.c
+ printf/vfprintf_s.c
printf/vfwprintf.c
+ printf/vfwprintf_s.c
printf/vprintf.c
+ printf/vprintf_s.c
printf/vsprintf.c
printf/vswprintf.c
printf/vwprintf.c
+ printf/vwprintf_s.c
printf/wprintf.c
+ printf/wprintf_s.c
printf/wstreamout.c
process/_cwait.c
process/_system.c
diff --git a/reactos/lib/sdk/crt/crt.rbuild b/reactos/lib/sdk/crt/crt.rbuild
index 5fe9329cbb8..191b8f56486 100644
--- a/reactos/lib/sdk/crt/crt.rbuild
+++ b/reactos/lib/sdk/crt/crt.rbuild
@@ -31,25 +31,35 @@
_cprintf.c
+ _cwprintf.c
_snprintf.c
_snwprintf.c
_vcprintf.c
- _vsprintf_p.c
+ _vcwprintf.c
_vsnprintf.c
_vsnwprintf.c
+ _vsprintf_p.c
fprintf.c
+ fprintf_s.c
fwprintf.c
+ fwprintf_s.c
printf.c
+ printf_s.c
sprintf.c
streamout.c
swprintf.c
vfprintf.c
+ vfprintf_s.c
vfwprintf.c
+ vfwprintf_s.c
vprintf.c
+ vprintf_s.c
vsprintf.c
vswprintf.c
vwprintf.c
+ vwprintf_s.c
wprintf.c
+ wprintf_s.c
wstreamout.c
diff --git a/reactos/lib/sdk/crt/include/internal/safecrt.h b/reactos/lib/sdk/crt/include/internal/safecrt.h
index 4ad767afe0d..ad948fe0c92 100644
--- a/reactos/lib/sdk/crt/include/internal/safecrt.h
+++ b/reactos/lib/sdk/crt/include/internal/safecrt.h
@@ -1,4 +1,6 @@
+#include
+
extern void * __pInvalidArgHandler;
void _invalid_parameter(
@@ -10,7 +12,7 @@ void _invalid_parameter(
#ifndef _LIBCNT_
#define MSVCRT_INVALID_PMT(x) _invalid_parameter(NULL, NULL, NULL, 0, 0)
-#define MSVCRT_CHECK_PMT(x) ((x) || (MSVCRT_INVALID_PMT(0),FALSE))
+#define MSVCRT_CHECK_PMT(x) ((x) || (MSVCRT_INVALID_PMT(0),0))
#else
/* disable secure crt parameter checks */
#define MSVCRT_CHECK_PMT
diff --git a/reactos/lib/sdk/crt/printf/_cprintf.c b/reactos/lib/sdk/crt/printf/_cprintf.c
index c2ceaf0ea75..ee8f7065f6c 100644
--- a/reactos/lib/sdk/crt/printf/_cprintf.c
+++ b/reactos/lib/sdk/crt/printf/_cprintf.c
@@ -4,7 +4,6 @@
* FILE: lib/sdk/crt/printf/_cprintf.c
* PURPOSE: Implementation of _cprintf
* PROGRAMMER: Timo Kreuzer
- * Samuel Serapión
*/
#include
@@ -22,17 +21,3 @@ _cprintf(const char * format, ...)
va_end(argptr);
return result;
}
-
-int
-__cdecl
-_cwprintf(const wchar_t* format, ...)
-{
- int retval;
- va_list valist;
-
- va_start( valist, format );
- retval = _vcwprintf(format, valist);
- va_end(valist);
-
- return retval;
-}
diff --git a/reactos/lib/sdk/crt/printf/_cwprintf.c b/reactos/lib/sdk/crt/printf/_cwprintf.c
new file mode 100644
index 00000000000..b701e615a05
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/_cwprintf.c
@@ -0,0 +1,24 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/_cwprintf.c
+ * PURPOSE: Implementation of _cwprintf
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#include
+#include
+
+int
+_cdecl
+_cwprintf(const wchar_t* format, ...)
+{
+ int retval;
+ va_list valist;
+
+ va_start( valist, format );
+ retval = _vcwprintf(format, valist);
+ va_end(valist);
+
+ return retval;
+}
diff --git a/reactos/lib/sdk/crt/printf/_vcprintf.c b/reactos/lib/sdk/crt/printf/_vcprintf.c
index 84b582ad4ea..95bad9af7eb 100644
--- a/reactos/lib/sdk/crt/printf/_vcprintf.c
+++ b/reactos/lib/sdk/crt/printf/_vcprintf.c
@@ -15,10 +15,3 @@ _vcprintf(const char* format, va_list va)
{
return vfprintf(stdout, format, va);
}
-
-int
-__cdecl
-_vcwprintf(const wchar_t* format, va_list va)
-{
- return vfwprintf(stdout, format, va);
-}
diff --git a/reactos/lib/sdk/crt/printf/_vcwprintf.c b/reactos/lib/sdk/crt/printf/_vcwprintf.c
new file mode 100644
index 00000000000..1ed71d30f21
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/_vcwprintf.c
@@ -0,0 +1,17 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/_vcwprintf.c
+ * PURPOSE: Implementation of _vcwprintf
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#include
+#include
+
+int
+__cdecl
+_vcwprintf(const wchar_t* format, va_list va)
+{
+ return vfwprintf(stdout, format, va);
+}
diff --git a/reactos/lib/sdk/crt/printf/fprintf.c b/reactos/lib/sdk/crt/printf/fprintf.c
index 4d953bfefdf..69b2e6aed4a 100644
--- a/reactos/lib/sdk/crt/printf/fprintf.c
+++ b/reactos/lib/sdk/crt/printf/fprintf.c
@@ -4,13 +4,13 @@
* FILE: lib/sdk/crt/printf/fprintf.c
* PURPOSE: Implementation of fprintf
* PROGRAMMER: Timo Kreuzer
- * Samuel Serapión
*/
-#include
+#include
+#include
int
-__cdecl
+_cdecl
fprintf(FILE *file, const char *format, ...)
{
va_list argptr;
@@ -21,15 +21,3 @@ fprintf(FILE *file, const char *format, ...)
va_end(argptr);
return result;
}
-
-int
-__cdecl
-fprintf_s(FILE* file, const char *format, ...)
-{
- va_list argptr;
- int result;
- va_start(argptr, format);
- result = vfprintf_s(file, format, argptr);
- va_end(argptr);
- return result;
-}
diff --git a/reactos/lib/sdk/crt/printf/fprintf_s.c b/reactos/lib/sdk/crt/printf/fprintf_s.c
new file mode 100644
index 00000000000..f7553259fd1
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/fprintf_s.c
@@ -0,0 +1,24 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/fprintf_s.c
+ * PURPOSE: Implementation of fprintf_s
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#define MINGW_HAS_SECURE_API 1
+
+#include
+#include
+
+int
+_cdecl
+fprintf_s(FILE* file, const char *format, ...)
+{
+ va_list argptr;
+ int result;
+ va_start(argptr, format);
+ result = vfprintf_s(file, format, argptr);
+ va_end(argptr);
+ return result;
+}
diff --git a/reactos/lib/sdk/crt/printf/fwprintf.c b/reactos/lib/sdk/crt/printf/fwprintf.c
index e0e2d3a61a0..6cea7e4e317 100644
--- a/reactos/lib/sdk/crt/printf/fwprintf.c
+++ b/reactos/lib/sdk/crt/printf/fwprintf.c
@@ -4,13 +4,13 @@
* FILE: lib/sdk/crt/printf/fwprintf.c
* PURPOSE: Implementation of fwprintf
* PROGRAMMER: Timo Kreuzer
- * Samuel Serapión
*/
-#include
+#include
+#include
int
-__cdecl
+_cdecl
fwprintf(FILE* file, const wchar_t *format, ...)
{
va_list argptr;
@@ -22,14 +22,3 @@ fwprintf(FILE* file, const wchar_t *format, ...)
return result;
}
-int
-__cdecl
-fwprintf_s(FILE* file, const wchar_t *format, ...)
-{
- va_list valist;
- int res;
- va_start(valist, format);
- res = vfwprintf_s(file, format, valist);
- va_end(valist);
- return res;
-}
diff --git a/reactos/lib/sdk/crt/printf/fwprintf_s.c b/reactos/lib/sdk/crt/printf/fwprintf_s.c
new file mode 100644
index 00000000000..a9e0ac9d454
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/fwprintf_s.c
@@ -0,0 +1,24 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/fwprintf_s.c
+ * PURPOSE: Implementation of fwprintf_s
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#define MINGW_HAS_SECURE_API 1
+
+#include
+#include
+
+int
+_cdecl
+fwprintf_s(FILE* file, const wchar_t *format, ...)
+{
+ va_list valist;
+ int res;
+ va_start(valist, format);
+ res = vfwprintf_s(file, format, valist);
+ va_end(valist);
+ return res;
+}
diff --git a/reactos/lib/sdk/crt/printf/printf.c b/reactos/lib/sdk/crt/printf/printf.c
index c3b66ac1980..1ad0200ab25 100644
--- a/reactos/lib/sdk/crt/printf/printf.c
+++ b/reactos/lib/sdk/crt/printf/printf.c
@@ -7,7 +7,8 @@
* Samuel Serapión
*/
-#include
+#include
+#include
int
_cdecl
@@ -17,22 +18,8 @@ printf(const char *format, ...)
int result;
va_start(argptr, format);
- result = vprintf(format, argptr);
+ result = vfprintf(stdout, format, argptr);
va_end(argptr);
return result;
}
-
-int
-_cdecl
-printf_s(const char *format, ...)
-{
- va_list argptr;
- int res;
-
- va_start(argptr, format);
- res = vprintf_s(format, argptr);
- va_end(argptr);
- return res;
-}
-
diff --git a/reactos/lib/sdk/crt/printf/printf_s.c b/reactos/lib/sdk/crt/printf/printf_s.c
new file mode 100644
index 00000000000..d512e85ebfc
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/printf_s.c
@@ -0,0 +1,25 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/printf_s.c
+ * PURPOSE: Implementation of printf_s
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#define MINGW_HAS_SECURE_API 1
+
+#include
+#include
+
+int
+_cdecl
+printf_s(const char *format, ...)
+{
+ va_list argptr;
+ int res;
+
+ va_start(argptr, format);
+ res = vfprintf_s(stdout, format, argptr);
+ va_end(argptr);
+ return res;
+}
diff --git a/reactos/lib/sdk/crt/printf/vfprintf.c b/reactos/lib/sdk/crt/printf/vfprintf.c
index dadf00e7c33..6ecbff57228 100644
--- a/reactos/lib/sdk/crt/printf/vfprintf.c
+++ b/reactos/lib/sdk/crt/printf/vfprintf.c
@@ -4,17 +4,15 @@
* FILE: lib/sdk/crt/printf/vfprintf.c
* PURPOSE: Implementation of vfprintf
* PROGRAMMER: Timo Kreuzer
- * Samuel Serapión
*/
-#include
+#include
+#include
-void CDECL _lock_file(FILE* file);
-void CDECL _unlock_file(FILE* file);
-int CDECL streamout(FILE *stream, const char *format, va_list argptr);
+int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
int
-CDECL
+_cdecl
vfprintf(FILE *file, const char *format, va_list argptr)
{
int result;
@@ -26,20 +24,3 @@ vfprintf(FILE *file, const char *format, va_list argptr)
return result;
}
-int
-CDECL
-vfprintf_s(FILE* file, const char *format, va_list argptr)
-{
- int result;
-
- if(!MSVCRT_CHECK_PMT(format != NULL)) {
- *_errno() = EINVAL;
- return -1;
- }
-
- _lock_file(file);
- result = streamout(file, format, argptr);
- _unlock_file(file);
-
- return result;
-}
diff --git a/reactos/lib/sdk/crt/printf/vfprintf_s.c b/reactos/lib/sdk/crt/printf/vfprintf_s.c
new file mode 100644
index 00000000000..9182c26f43a
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/vfprintf_s.c
@@ -0,0 +1,33 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/vfprintf_s.c
+ * PURPOSE: Implementation of vfprintf_s
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#define MINGW_HAS_SECURE_API 1
+
+#include
+#include
+#include
+
+int _cdecl streamout(FILE *stream, const char *format, va_list argptr);
+
+int
+_cdecl
+vfprintf_s(FILE* file, const char *format, va_list argptr)
+{
+ int result;
+
+ if(!MSVCRT_CHECK_PMT(format != NULL)) {
+ _set_errno(EINVAL);
+ return -1;
+ }
+
+ _lock_file(file);
+ result = streamout(file, format, argptr);
+ _unlock_file(file);
+
+ return result;
+}
diff --git a/reactos/lib/sdk/crt/printf/vfwprintf.c b/reactos/lib/sdk/crt/printf/vfwprintf.c
index 2200b00c4e4..d017abba48a 100644
--- a/reactos/lib/sdk/crt/printf/vfwprintf.c
+++ b/reactos/lib/sdk/crt/printf/vfwprintf.c
@@ -4,18 +4,15 @@
* FILE: lib/sdk/crt/printf/vfwprintf.c
* PURPOSE: Implementation of vfwprintf
* PROGRAMMER: Timo Kreuzer
- * Samuel Serapión
*/
-#include
-#include
+#include
+#include
-void CDECL _lock_file(FILE* file);
-void CDECL _unlock_file(FILE* file);
-int CDECL wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
+int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
int
-CDECL
+_cdecl
vfwprintf(FILE* file, const wchar_t *format, va_list argptr)
{
int ret;
@@ -26,21 +23,3 @@ vfwprintf(FILE* file, const wchar_t *format, va_list argptr)
return ret;
}
-
-int
-CDECL
-vfwprintf_s(FILE* file, const wchar_t *format, va_list argptr)
-{
- int ret;
-
- if(!MSVCRT_CHECK_PMT( file != NULL)) {
- *_errno() = EINVAL;
- return -1;
- }
-
- _lock_file(file);
- ret = wstreamout(file, format, argptr);
- _unlock_file(file);
-
- return ret;
-}
diff --git a/reactos/lib/sdk/crt/printf/vfwprintf_s.c b/reactos/lib/sdk/crt/printf/vfwprintf_s.c
new file mode 100644
index 00000000000..ddc0b116fe6
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/vfwprintf_s.c
@@ -0,0 +1,34 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/vfwprintf.c
+ * PURPOSE: Implementation of vfwprintf
+ * PROGRAMMER: Timo Kreuzer
+ * Samuel Serapión
+ */
+
+#define MINGW_HAS_SECURE_API 1
+
+#include
+#include
+#include
+
+int _cdecl wstreamout(FILE *stream, const wchar_t *format, va_list argptr);
+
+int
+_cdecl
+vfwprintf_s(FILE* file, const wchar_t *format, va_list argptr)
+{
+ int ret;
+
+ if(!MSVCRT_CHECK_PMT( file != NULL)) {
+ _set_errno(EINVAL);
+ return -1;
+ }
+
+ _lock_file(file);
+ ret = wstreamout(file, format, argptr);
+ _unlock_file(file);
+
+ return ret;
+}
diff --git a/reactos/lib/sdk/crt/printf/vprintf.c b/reactos/lib/sdk/crt/printf/vprintf.c
index 2c5f52c4285..95ad5c67474 100644
--- a/reactos/lib/sdk/crt/printf/vprintf.c
+++ b/reactos/lib/sdk/crt/printf/vprintf.c
@@ -4,21 +4,14 @@
* FILE: lib/sdk/crt/printf/vprintf.c
* PURPOSE: Implementation of vprintf
* PROGRAMMER: Timo Kreuzer
- * Samuel Serapión
*/
-#include
+#include
+#include
int
-__cdecl
+_cdecl
vprintf(const char *format, va_list argptr)
{
return vfprintf(stdout, format, argptr);
}
-
-int
-__cdecl
-vprintf_s(const char *format, va_list valist)
-{
- return vfprintf_s(stdout,format,valist);
-}
diff --git a/reactos/lib/sdk/crt/printf/vprintf_s.c b/reactos/lib/sdk/crt/printf/vprintf_s.c
new file mode 100644
index 00000000000..9128088f4c7
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/vprintf_s.c
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/vprintf.c
+ * PURPOSE: Implementation of vprintf
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#define MINGW_HAS_SECURE_API 1
+
+#include
+#include
+
+int
+_cdecl
+vprintf_s(const char *format, va_list valist)
+{
+ return vfprintf_s(stdout,format,valist);
+}
diff --git a/reactos/lib/sdk/crt/printf/vwprintf.c b/reactos/lib/sdk/crt/printf/vwprintf.c
index 3fda2e5c591..83e1e4a8510 100644
--- a/reactos/lib/sdk/crt/printf/vwprintf.c
+++ b/reactos/lib/sdk/crt/printf/vwprintf.c
@@ -4,21 +4,14 @@
* FILE: lib/sdk/crt/printf/vwprintf.c
* PURPOSE: Implementation of vwprintf
* PROGRAMMER: Timo Kreuzer
- * Samuel Serapión
*/
-#include
+#include
+#include
int
-__cdecl
+_cdecl
vwprintf(const wchar_t *format, va_list valist)
{
return vfwprintf(stdout,format,valist);
}
-
-int
-__cdecl
-vwprintf_s(const wchar_t *format, va_list valist)
-{
- return vfwprintf_s(stdout,format,valist);
-}
diff --git a/reactos/lib/sdk/crt/printf/vwprintf_s.c b/reactos/lib/sdk/crt/printf/vwprintf_s.c
new file mode 100644
index 00000000000..15c44aeb613
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/vwprintf_s.c
@@ -0,0 +1,19 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/vwprintf.c
+ * PURPOSE: Implementation of vwprintf
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#define MINGW_HAS_SECURE_API 1
+
+#include
+#include
+
+int
+_cdecl
+vwprintf_s(const wchar_t *format, va_list valist)
+{
+ return vfwprintf_s(stdout,format,valist);
+}
diff --git a/reactos/lib/sdk/crt/printf/wprintf.c b/reactos/lib/sdk/crt/printf/wprintf.c
index 2ebd11a01ae..b1c89f76acb 100644
--- a/reactos/lib/sdk/crt/printf/wprintf.c
+++ b/reactos/lib/sdk/crt/printf/wprintf.c
@@ -7,10 +7,11 @@
* Samuel Serapión
*/
-#include
+#include
+#include
int
-__cdecl
+_cdecl
wprintf(const wchar_t *format, ...)
{
va_list argptr;
@@ -21,15 +22,3 @@ wprintf(const wchar_t *format, ...)
va_end(argptr);
return result;
}
-
-int
-__cdecl
-wprintf_s(const wchar_t *format, ...)
-{
- va_list argptr;
- int res;
- va_start(argptr, format);
- res = vwprintf_s(format, argptr);
- va_end(argptr);
- return res;
-}
diff --git a/reactos/lib/sdk/crt/printf/wprintf_s.c b/reactos/lib/sdk/crt/printf/wprintf_s.c
new file mode 100644
index 00000000000..11ce3e8ce4e
--- /dev/null
+++ b/reactos/lib/sdk/crt/printf/wprintf_s.c
@@ -0,0 +1,24 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/printf/wprintf.c
+ * PURPOSE: Implementation of wprintf
+ * PROGRAMMER: Samuel Serapión
+ */
+
+#define MINGW_HAS_SECURE_API 1
+
+#include
+#include
+
+int
+_cdecl
+wprintf_s(const wchar_t *format, ...)
+{
+ va_list argptr;
+ int res;
+ va_start(argptr, format);
+ res = vwprintf_s(format, argptr);
+ va_end(argptr);
+ return res;
+}
diff --git a/reactos/lib/sdk/crt/stdio/file.c b/reactos/lib/sdk/crt/stdio/file.c
index 0c85935f837..9c5a49df5f9 100644
--- a/reactos/lib/sdk/crt/stdio/file.c
+++ b/reactos/lib/sdk/crt/stdio/file.c
@@ -596,7 +596,7 @@ int CDECL _access(const char *filename, int mode)
if (!filename || attr == INVALID_FILE_ATTRIBUTES)
{
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
if ((attr & FILE_ATTRIBUTE_READONLY) && (mode & W_OK))
@@ -633,7 +633,7 @@ int CDECL _waccess(const wchar_t *filename, int mode)
if (!filename || attr == INVALID_FILE_ATTRIBUTES)
{
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
if ((attr & FILE_ATTRIBUTE_READONLY) && (mode & W_OK))
@@ -674,7 +674,7 @@ int CDECL _chmod(const char *path, int flags)
if (newFlags == oldFlags || SetFileAttributesA(path, newFlags))
return 0;
}
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
@@ -693,7 +693,7 @@ int CDECL _wchmod(const wchar_t *path, int flags)
if (newFlags == oldFlags || SetFileAttributesW(path, newFlags))
return 0;
}
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
@@ -706,7 +706,7 @@ int CDECL _unlink(const char *path)
if(DeleteFileA(path))
return 0;
TRACE("failed (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
@@ -719,7 +719,7 @@ int CDECL _wunlink(const wchar_t *path)
if(DeleteFileW(path))
return 0;
TRACE("failed (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
@@ -787,7 +787,7 @@ int CDECL _close(int fd)
else if (!CloseHandle(hand))
{
WARN(":failed-last error (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
ret = -1;
}
else
@@ -821,7 +821,7 @@ int CDECL _commit(int fd)
return 0;
}
TRACE(":failed-last error (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
TRACE(":ok\n");
@@ -867,7 +867,7 @@ int CDECL _dup2(int od, int nd)
else
{
ret = -1;
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
}
}
else
@@ -1008,7 +1008,7 @@ __int64 CDECL _lseeki64(int fd, __int64 offset, int whence)
return ofs.QuadPart;
}
TRACE(":error-last error (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
@@ -1172,7 +1172,7 @@ int CDECL _chsize(int fd, long size)
if (pos >= 0)
{
ret = SetEndOfFile(handle);
- if (!ret) _set_errno(GetLastError());
+ if (!ret) _dosmaperr(GetLastError());
}
/* restore the file pointer */
@@ -1507,7 +1507,7 @@ int CDECL _pipe(int *pfds, unsigned int psize, int textmode)
UNLOCK_FILES();
}
else
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return ret;
}
@@ -1598,7 +1598,7 @@ int CDECL _sopen_s( int *fd, const char *path, int oflags, int shflags, int pmod
hand = CreateFileA(path, access, sharing, &sa, creation, attrib, 0);
if (hand == INVALID_HANDLE_VALUE) {
WARN(":failed-last error (%d)\n", GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return *_errno();
}
@@ -1718,7 +1718,7 @@ int CDECL _wsopen_s( int *fd, const wchar_t* path, int oflags, int shflags, int
if (hand == INVALID_HANDLE_VALUE) {
WARN(":failed-last error (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return *_errno();
}
@@ -2783,7 +2783,7 @@ FILE* CDECL _wfreopen(const wchar_t *path, const wchar_t *mode, FILE* file)
{
file->_flag = 0;
WARN(":failed-last error (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
file = NULL;
}
}
@@ -3103,7 +3103,7 @@ int CDECL remove(const char *path)
if (DeleteFileA(path))
return 0;
TRACE(":failed (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
@@ -3116,7 +3116,7 @@ int CDECL _wremove(const wchar_t *path)
if (DeleteFileW(path))
return 0;
TRACE(":failed (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
@@ -3129,7 +3129,7 @@ int CDECL rename(const char *oldpath,const char *newpath)
if (MoveFileExA(oldpath, newpath, MOVEFILE_COPY_ALLOWED))
return 0;
TRACE(":failed (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
@@ -3142,7 +3142,7 @@ int CDECL _wrename(const wchar_t *oldpath,const wchar_t *newpath)
if (MoveFileExW(oldpath, newpath, MOVEFILE_COPY_ALLOWED))
return 0;
TRACE(":failed (%d)\n",GetLastError());
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
diff --git a/reactos/lib/sdk/crt/stdlib/errno.c b/reactos/lib/sdk/crt/stdlib/errno.c
index 1446cc703e0..a56c0dd6d4e 100644
--- a/reactos/lib/sdk/crt/stdlib/errno.c
+++ b/reactos/lib/sdk/crt/stdlib/errno.c
@@ -47,7 +47,7 @@ errno_t CDECL _get_doserrno(unsigned long *pValue)
errno_t CDECL _set_doserrno(unsigned long error)
{
*__doserrno() = error;
- return error;
+ return 0;
}
/*
@@ -68,7 +68,7 @@ errno_t CDECL _get_errno(int *pValue)
int CDECL _set_errno(int error)
{
*_errno() = error;
- return error;
+ return 0;
}
/*
diff --git a/reactos/lib/sdk/crt/stdlib/senv.c b/reactos/lib/sdk/crt/stdlib/senv.c
index 76584268087..a7a45438b2c 100644
--- a/reactos/lib/sdk/crt/stdlib/senv.c
+++ b/reactos/lib/sdk/crt/stdlib/senv.c
@@ -71,7 +71,7 @@ int _tsearchenv_s(const _TCHAR* file, const _TCHAR* env, _TCHAR *buf, size_t cou
if (GetFileAttributes( file ) != INVALID_FILE_ATTRIBUTES)
{
GetFullPathName( file, MAX_PATH, buf, NULL );
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return 0;
}
diff --git a/reactos/lib/sdk/crt/time/futime.c b/reactos/lib/sdk/crt/time/futime.c
index 57cc95723af..b86e4e0b1ac 100644
--- a/reactos/lib/sdk/crt/time/futime.c
+++ b/reactos/lib/sdk/crt/time/futime.c
@@ -86,7 +86,7 @@ _futime(int fd, struct _utimbuf *filetime)
if (!SetFileTime(handle, NULL, &at, &wt))
{
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1 ;
}
diff --git a/reactos/lib/sdk/crt/time/localtime.c b/reactos/lib/sdk/crt/time/localtime.c
index eca83afe60c..1d7c03360f7 100644
--- a/reactos/lib/sdk/crt/time/localtime.c
+++ b/reactos/lib/sdk/crt/time/localtime.c
@@ -15,7 +15,6 @@
00:00:00, 01/01/1970 UTC to
23:59:59. 12/31/3000 UTC */
-
errno_t
localtime_s(struct tm* _tm, const time_t *ptime)
{
@@ -28,6 +27,7 @@ localtime_s(struct tm* _tm, const time_t *ptime)
_CRT_WIDE(__FILE__),
__LINE__,
0);
+ _set_errno(EINVAL);
return EINVAL;
}
@@ -35,6 +35,7 @@ localtime_s(struct tm* _tm, const time_t *ptime)
if (*ptime < 0 || *ptime > _MAX__TIME64_T)
{
memset(_tm, 0xFF, sizeof(struct tm));
+ _set_errno(EINVAL);
return EINVAL;
}
diff --git a/reactos/lib/sdk/crt/wine/heap.c b/reactos/lib/sdk/crt/wine/heap.c
index 118602fc5b5..41817fb61e1 100644
--- a/reactos/lib/sdk/crt/wine/heap.c
+++ b/reactos/lib/sdk/crt/wine/heap.c
@@ -173,7 +173,7 @@ int CDECL _heapchk(void)
{
if (!HeapValidate( GetProcessHeap(), 0, NULL))
{
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return _HEAPBADNODE;
}
return _HEAPOK;
@@ -187,7 +187,7 @@ int CDECL _heapmin(void)
if (!HeapCompact( GetProcessHeap(), 0 ))
{
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return -1;
}
return 0;
@@ -209,7 +209,7 @@ int CDECL _heapwalk(_HEAPINFO* next)
!HeapValidate( GetProcessHeap(), 0, phe.lpData ))
{
UNLOCK_HEAP;
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
return _HEAPBADNODE;
}
@@ -220,7 +220,7 @@ int CDECL _heapwalk(_HEAPINFO* next)
UNLOCK_HEAP;
if (GetLastError() == ERROR_NO_MORE_ITEMS)
return _HEAPEND;
- _set_errno(GetLastError());
+ _dosmaperr(GetLastError());
if (!phe.lpData)
return _HEAPBADBEGIN;
return _HEAPBADNODE;