Piotr Caban : msvcrt: Added fopen_s implementation.
Alexandre Julliard
julliard at winehq.org
Mon Apr 19 11:51:17 CDT 2010
Module: wine
Branch: master
Commit: 1b4bacea8c9b8bb4208cc5e91c473d595f7fbca4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1b4bacea8c9b8bb4208cc5e91c473d595f7fbca4
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Apr 19 10:59:02 2010 +0200
msvcrt: Added fopen_s implementation.
---
dlls/msvcr80/msvcr80.spec | 2 +-
dlls/msvcr90/msvcr90.spec | 2 +-
dlls/msvcrt/file.c | 30 +++++++++++++++++++++++++++++-
dlls/msvcrt/msvcrt.spec | 2 +-
4 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 04535b3..44507ec 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -1259,7 +1259,7 @@
@ cdecl floor(double) msvcrt.floor
@ cdecl fmod(double double) msvcrt.fmod
@ cdecl fopen(str str) msvcrt.fopen
-@ stub fopen_s
+@ cdecl fopen_s(ptr str str) msvcrt.fopen_s
@ varargs fprintf(ptr str) msvcrt.fprintf
@ stub fprintf_s
@ cdecl fputc(long ptr) msvcrt.fputc
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index ae13be4..1e6731f 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -1243,7 +1243,7 @@
@ cdecl floor(double) msvcrt.floor
@ cdecl fmod(double double) msvcrt.fmod
@ cdecl fopen(str str) msvcrt.fopen
-@ stub fopen_s
+@ cdecl fopen_s(ptr str str) msvcrt.fopen_s
@ varargs fprintf(ptr str) msvcrt.fprintf
@ stub fprintf_s
@ cdecl fputc(long ptr) msvcrt.fputc
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index c5b2798..6641999 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -218,6 +218,7 @@ static int msvcrt_alloc_fd_from(HANDLE hand, int flag, int fd)
if (fd >= MSVCRT_MAX_FILES)
{
WARN(":files exhausted!\n");
+ *MSVCRT__errno() = MSVCRT_ENFILE;
return -1;
}
MSVCRT_fdesc[fd].handle = hand;
@@ -1033,6 +1034,8 @@ static int msvcrt_get_flags(const MSVCRT_wchar_t* mode, int *open_flags, int* st
*stream_flags = plus ? MSVCRT__IORW : MSVCRT__IOWRT;
break;
default:
+ MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ *MSVCRT__errno() = MSVCRT_EINVAL;
return -1;
}
@@ -2649,10 +2652,16 @@ MSVCRT_FILE * CDECL MSVCRT__fsopen(const char *path, const char *mode, int share
MSVCRT_FILE *ret;
MSVCRT_wchar_t *pathW = NULL, *modeW = NULL;
- if (path && !(pathW = msvcrt_wstrdupa(path))) return NULL;
+ if (path && !(pathW = msvcrt_wstrdupa(path))) {
+ MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return NULL;
+ }
if (mode && !(modeW = msvcrt_wstrdupa(mode)))
{
MSVCRT_free(pathW);
+ MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ *MSVCRT__errno() = MSVCRT_EINVAL;
return NULL;
}
@@ -2672,6 +2681,25 @@ MSVCRT_FILE * CDECL MSVCRT_fopen(const char *path, const char *mode)
}
/*********************************************************************
+ * fopen_s (MSVCRT.@)
+ */
+int CDECL MSVCRT_fopen_s(MSVCRT_FILE** pFile,
+ const char *filename, const char *mode)
+{
+ if(!pFile) {
+ MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
+ *MSVCRT__errno() = MSVCRT_EINVAL;
+ return MSVCRT_EINVAL;
+ }
+
+ *pFile = MSVCRT_fopen(filename, mode);
+
+ if(!*pFile)
+ return *MSVCRT__errno();
+ return 0;
+}
+
+/*********************************************************************
* _wfopen (MSVCRT.@)
*/
MSVCRT_FILE * CDECL MSVCRT__wfopen(const MSVCRT_wchar_t *path, const MSVCRT_wchar_t *mode)
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index f4f9ee8..fdd58c2 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -1190,7 +1190,7 @@
@ cdecl floor(double) MSVCRT_floor
@ cdecl fmod(double double) MSVCRT_fmod
@ cdecl fopen(str str) MSVCRT_fopen
-# stub fopen_s
+@ cdecl fopen_s(ptr str str) MSVCRT_fopen_s
@ varargs fprintf(ptr str) MSVCRT_fprintf
# stub fprintf_s
@ cdecl fputc(long ptr) MSVCRT_fputc
More information about the wine-cvs
mailing list