msvcrt: Added fopen_s implementation.
This commit is contained in:
parent
8adfd63c21
commit
1b4bacea8c
|
@ -1259,7 +1259,7 @@
|
||||||
@ cdecl floor(double) msvcrt.floor
|
@ cdecl floor(double) msvcrt.floor
|
||||||
@ cdecl fmod(double double) msvcrt.fmod
|
@ cdecl fmod(double double) msvcrt.fmod
|
||||||
@ cdecl fopen(str str) msvcrt.fopen
|
@ cdecl fopen(str str) msvcrt.fopen
|
||||||
@ stub fopen_s
|
@ cdecl fopen_s(ptr str str) msvcrt.fopen_s
|
||||||
@ varargs fprintf(ptr str) msvcrt.fprintf
|
@ varargs fprintf(ptr str) msvcrt.fprintf
|
||||||
@ stub fprintf_s
|
@ stub fprintf_s
|
||||||
@ cdecl fputc(long ptr) msvcrt.fputc
|
@ cdecl fputc(long ptr) msvcrt.fputc
|
||||||
|
|
|
@ -1243,7 +1243,7 @@
|
||||||
@ cdecl floor(double) msvcrt.floor
|
@ cdecl floor(double) msvcrt.floor
|
||||||
@ cdecl fmod(double double) msvcrt.fmod
|
@ cdecl fmod(double double) msvcrt.fmod
|
||||||
@ cdecl fopen(str str) msvcrt.fopen
|
@ cdecl fopen(str str) msvcrt.fopen
|
||||||
@ stub fopen_s
|
@ cdecl fopen_s(ptr str str) msvcrt.fopen_s
|
||||||
@ varargs fprintf(ptr str) msvcrt.fprintf
|
@ varargs fprintf(ptr str) msvcrt.fprintf
|
||||||
@ stub fprintf_s
|
@ stub fprintf_s
|
||||||
@ cdecl fputc(long ptr) msvcrt.fputc
|
@ cdecl fputc(long ptr) msvcrt.fputc
|
||||||
|
|
|
@ -218,6 +218,7 @@ static int msvcrt_alloc_fd_from(HANDLE hand, int flag, int fd)
|
||||||
if (fd >= MSVCRT_MAX_FILES)
|
if (fd >= MSVCRT_MAX_FILES)
|
||||||
{
|
{
|
||||||
WARN(":files exhausted!\n");
|
WARN(":files exhausted!\n");
|
||||||
|
*MSVCRT__errno() = MSVCRT_ENFILE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
MSVCRT_fdesc[fd].handle = hand;
|
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;
|
*stream_flags = plus ? MSVCRT__IORW : MSVCRT__IOWRT;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
|
||||||
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2649,10 +2652,16 @@ MSVCRT_FILE * CDECL MSVCRT__fsopen(const char *path, const char *mode, int share
|
||||||
MSVCRT_FILE *ret;
|
MSVCRT_FILE *ret;
|
||||||
MSVCRT_wchar_t *pathW = NULL, *modeW = NULL;
|
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)))
|
if (mode && !(modeW = msvcrt_wstrdupa(mode)))
|
||||||
{
|
{
|
||||||
MSVCRT_free(pathW);
|
MSVCRT_free(pathW);
|
||||||
|
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
|
||||||
|
*MSVCRT__errno() = MSVCRT_EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2671,6 +2680,25 @@ MSVCRT_FILE * CDECL MSVCRT_fopen(const char *path, const char *mode)
|
||||||
return MSVCRT__fsopen( path, mode, MSVCRT__SH_DENYNO );
|
return MSVCRT__fsopen( path, mode, MSVCRT__SH_DENYNO );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* 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.@)
|
* _wfopen (MSVCRT.@)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1190,7 +1190,7 @@
|
||||||
@ cdecl floor(double) MSVCRT_floor
|
@ cdecl floor(double) MSVCRT_floor
|
||||||
@ cdecl fmod(double double) MSVCRT_fmod
|
@ cdecl fmod(double double) MSVCRT_fmod
|
||||||
@ cdecl fopen(str str) MSVCRT_fopen
|
@ cdecl fopen(str str) MSVCRT_fopen
|
||||||
# stub fopen_s
|
@ cdecl fopen_s(ptr str str) MSVCRT_fopen_s
|
||||||
@ varargs fprintf(ptr str) MSVCRT_fprintf
|
@ varargs fprintf(ptr str) MSVCRT_fprintf
|
||||||
# stub fprintf_s
|
# stub fprintf_s
|
||||||
@ cdecl fputc(long ptr) MSVCRT_fputc
|
@ cdecl fputc(long ptr) MSVCRT_fputc
|
||||||
|
|
Loading…
Reference in New Issue