msvcrt: Add tmpfile_s implementation.
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 70bcbd0..090e82c 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1609,7 +1609,7 @@
@ cdecl tan(double) msvcrt.tan
@ cdecl tanh(double) msvcrt.tanh
@ cdecl tmpfile() msvcrt.tmpfile
-@ stub tmpfile_s
+@ cdecl tmpfile_s(ptr) msvcrt.tmpfile_s
@ cdecl tmpnam(ptr) msvcrt.tmpnam
@ stub tmpnam_s
@ cdecl tolower(long) msvcrt.tolower
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index d758176..3644345 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -1463,7 +1463,7 @@
@ cdecl tan(double) msvcrt.tan
@ cdecl tanh(double) msvcrt.tanh
@ cdecl tmpfile() msvcrt.tmpfile
-@ stub tmpfile_s
+@ cdecl tmpfile_s(ptr) msvcrt.tmpfile_s
@ cdecl tmpnam(ptr) msvcrt.tmpnam
@ stub tmpnam_s
@ cdecl tolower(long) msvcrt.tolower
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 5c27fca..d10c78e 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -1474,7 +1474,7 @@
@ cdecl tanh(double) msvcrt.tanh
@ cdecl -arch=x86_64 tanhf(float) msvcrt.tanhf
@ cdecl tmpfile() msvcrt.tmpfile
-@ stub tmpfile_s
+@ cdecl tmpfile_s(ptr) msvcrt.tmpfile_s
@ cdecl tmpnam(ptr) msvcrt.tmpnam
@ stub tmpnam_s
@ cdecl tolower(long) msvcrt.tolower
diff --git a/dlls/msvcr90/tests/msvcr90.c b/dlls/msvcr90/tests/msvcr90.c
index 92945ae..c746400 100644
--- a/dlls/msvcr90/tests/msvcr90.c
+++ b/dlls/msvcr90/tests/msvcr90.c
@@ -75,6 +75,7 @@
static void* (__cdecl *p_bsearch_s)(const void *, const void *, size_t, size_t,
int (__cdecl *compare)(void *, const void *, const void *), void *);
static int (__cdecl *p_controlfp_s)(unsigned int *, unsigned int, unsigned int);
+static int (__cdecl *p_tmpfile_s)(FILE**);
static int (__cdecl *p_atoflt)(_CRT_FLOAT *, char *);
static unsigned int (__cdecl *p_set_abort_behavior)(unsigned int, unsigned int);
static int (__cdecl *p_sopen_s)(int*, const char*, int, int, int);
@@ -255,6 +256,7 @@
SET(p_qsort_s, "qsort_s");
SET(p_bsearch_s, "bsearch_s");
SET(p_controlfp_s, "_controlfp_s");
+ SET(p_tmpfile_s, "tmpfile_s");
SET(p_atoflt, "_atoflt");
SET(p_set_abort_behavior, "_set_abort_behavior");
SET(p_sopen_s, "_sopen_s");
@@ -833,6 +835,18 @@
ok( cur != 0xdeadbeef, "value not set\n" );
}
+static void test_tmpfile_s( void )
+{
+ int ret;
+
+ errno = 0xdeadbeef;
+ SET_EXPECT(invalid_parameter_handler);
+ ret = p_tmpfile_s(NULL);
+ ok(ret == EINVAL, "Expected tmpfile_s to return EINVAL, got %i\n", ret);
+ CHECK_CALLED(invalid_parameter_handler);
+ ok(errno == 0xdeadbeef, "errno = %x\n", errno);
+}
+
typedef struct
{
const char *str;
@@ -1211,6 +1225,7 @@
test_qsort_s();
test_bsearch_s();
test_controlfp_s();
+ test_tmpfile_s();
test__atoflt();
test__set_abort_behavior();
test__sopen_s();
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index df2c7cd..fe8f8b6 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -3792,6 +3792,18 @@
return file;
}
+/*********************************************************************
+ * tmpfile_s (MSVCRT.@)
+ */
+int CDECL MSVCRT_tmpfile_s(MSVCRT_FILE** file)
+{
+ if (!MSVCRT_CHECK_PMT(file != NULL))
+ return MSVCRT_EINVAL;
+
+ *file = MSVCRT_tmpfile();
+ return 0;
+}
+
static int puts_clbk_file_a(void *file, int len, const char *str)
{
return MSVCRT_fwrite(str, sizeof(char), len, file);
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index 934c247..c84ecba 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -1422,7 +1422,7 @@
@ cdecl -arch=x86_64 tanhf(float) MSVCRT_tanhf
@ cdecl time(ptr) MSVCRT_time
@ cdecl tmpfile() MSVCRT_tmpfile
-# stub tmpfile_s(ptr)
+@ cdecl tmpfile_s(ptr) MSVCRT_tmpfile_s
@ cdecl tmpnam(ptr) MSVCRT_tmpnam
# stub tmpnam_s(ptr long)
@ cdecl tolower(long) MSVCRT_tolower