msvcrt: Remove non-needed defines from msvcrt.h.
Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
951968c88a
commit
f67f1ce79e
|
@ -18,6 +18,7 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <math.h>
|
||||
#include "msvcrt.h"
|
||||
#include <winnls.h>
|
||||
|
@ -276,7 +277,7 @@ int* CDECL __p__fmode(void) { return &MSVCRT__fmode; }
|
|||
int CDECL _set_fmode(int mode)
|
||||
{
|
||||
/* TODO: support _O_WTEXT */
|
||||
if(!MSVCRT_CHECK_PMT(mode==MSVCRT__O_TEXT || mode==MSVCRT__O_BINARY))
|
||||
if(!MSVCRT_CHECK_PMT(mode==_O_TEXT || mode==_O_BINARY))
|
||||
return EINVAL;
|
||||
|
||||
MSVCRT__fmode = mode;
|
||||
|
@ -435,7 +436,7 @@ void msvcrt_init_args(void)
|
|||
MSVCRT__HUGE = HUGE_VAL;
|
||||
MSVCRT___setlc_active = 0;
|
||||
MSVCRT___unguarded_readlc_active = 0;
|
||||
MSVCRT__fmode = MSVCRT__O_TEXT;
|
||||
MSVCRT__fmode = _O_TEXT;
|
||||
|
||||
MSVCRT__environ = msvcrt_SnapshotOfEnvironmentA(NULL);
|
||||
MSVCRT___initenv = msvcrt_SnapshotOfEnvironmentA(NULL);
|
||||
|
|
|
@ -50,8 +50,8 @@ static CRITICAL_SECTION MSVCRT_onexit_cs = { &MSVCRT_onexit_cs_debug, -1, 0, 0,
|
|||
extern int MSVCRT_app_type;
|
||||
extern wchar_t *MSVCRT__wpgmptr;
|
||||
|
||||
static unsigned int MSVCRT_abort_behavior = MSVCRT__WRITE_ABORT_MSG | MSVCRT__CALL_REPORTFAULT;
|
||||
static int MSVCRT_error_mode = MSVCRT__OUT_TO_DEFAULT;
|
||||
static unsigned int MSVCRT_abort_behavior = _WRITE_ABORT_MSG | _CALL_REPORTFAULT;
|
||||
static int MSVCRT_error_mode = _OUT_TO_DEFAULT;
|
||||
|
||||
void (*CDECL _aexit_rtn)(int) = _exit;
|
||||
|
||||
|
@ -230,8 +230,8 @@ void CDECL _amsg_exit(int errnum)
|
|||
{
|
||||
TRACE("(%d)\n", errnum);
|
||||
|
||||
if ((MSVCRT_error_mode == MSVCRT__OUT_TO_MSGBOX) ||
|
||||
((MSVCRT_error_mode == MSVCRT__OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
|
||||
if ((MSVCRT_error_mode == _OUT_TO_MSGBOX) ||
|
||||
((MSVCRT_error_mode == _OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
|
||||
{
|
||||
char text[32];
|
||||
sprintf(text, "Error: R60%d",errnum);
|
||||
|
@ -249,10 +249,10 @@ void CDECL abort(void)
|
|||
{
|
||||
TRACE("()\n");
|
||||
|
||||
if (MSVCRT_abort_behavior & MSVCRT__WRITE_ABORT_MSG)
|
||||
if (MSVCRT_abort_behavior & _WRITE_ABORT_MSG)
|
||||
{
|
||||
if ((MSVCRT_error_mode == MSVCRT__OUT_TO_MSGBOX) ||
|
||||
((MSVCRT_error_mode == MSVCRT__OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
|
||||
if ((MSVCRT_error_mode == _OUT_TO_MSGBOX) ||
|
||||
((MSVCRT_error_mode == _OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
|
||||
{
|
||||
DoMessageBox("Runtime error!", "abnormal program termination");
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ unsigned int CDECL _set_abort_behavior(unsigned int flags, unsigned int mask)
|
|||
unsigned int old = MSVCRT_abort_behavior;
|
||||
|
||||
TRACE("%x, %x\n", flags, mask);
|
||||
if (mask & MSVCRT__CALL_REPORTFAULT)
|
||||
if (mask & _CALL_REPORTFAULT)
|
||||
FIXME("_WRITE_CALL_REPORTFAULT unhandled\n");
|
||||
|
||||
MSVCRT_abort_behavior = (MSVCRT_abort_behavior & ~mask) | (flags & mask);
|
||||
|
@ -288,8 +288,8 @@ void CDECL _wassert(const wchar_t* str, const wchar_t* file, unsigned int line)
|
|||
{
|
||||
TRACE("(%s,%s,%d)\n", debugstr_w(str), debugstr_w(file), line);
|
||||
|
||||
if ((MSVCRT_error_mode == MSVCRT__OUT_TO_MSGBOX) ||
|
||||
((MSVCRT_error_mode == MSVCRT__OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
|
||||
if ((MSVCRT_error_mode == _OUT_TO_MSGBOX) ||
|
||||
((MSVCRT_error_mode == _OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
|
||||
{
|
||||
wchar_t text[2048];
|
||||
_snwprintf(text, sizeof(text), L"File: %ls\nLine: %d\n\nExpression: \"%ls\"", file, line, str);
|
||||
|
@ -510,7 +510,7 @@ int CDECL _set_error_mode(int mode)
|
|||
{
|
||||
|
||||
const int old = MSVCRT_error_mode;
|
||||
if ( MSVCRT__REPORT_ERRMODE != mode ) {
|
||||
if ( _REPORT_ERRMODE != mode ) {
|
||||
MSVCRT_error_mode = mode;
|
||||
}
|
||||
return old;
|
||||
|
|
|
@ -27,8 +27,11 @@
|
|||
*/
|
||||
|
||||
#include <direct.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <share.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/locking.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/utime.h>
|
||||
#include <time.h>
|
||||
|
@ -66,9 +69,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
|
|||
#undef _wstat64
|
||||
|
||||
/* for stat mode, permissions apply to all,owner and group */
|
||||
#define ALL_S_IREAD (MSVCRT__S_IREAD | (MSVCRT__S_IREAD >> 3) | (MSVCRT__S_IREAD >> 6))
|
||||
#define ALL_S_IWRITE (MSVCRT__S_IWRITE | (MSVCRT__S_IWRITE >> 3) | (MSVCRT__S_IWRITE >> 6))
|
||||
#define ALL_S_IEXEC (MSVCRT__S_IEXEC | (MSVCRT__S_IEXEC >> 3) | (MSVCRT__S_IEXEC >> 6))
|
||||
#define ALL_S_IREAD (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
|
||||
#define ALL_S_IWRITE (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
|
||||
#define ALL_S_IEXEC (_S_IEXEC | (_S_IEXEC >> 3) | (_S_IEXEC >> 6))
|
||||
|
||||
/* _access() bit flags FIXME: incomplete */
|
||||
#define MSVCRT_W_OK 0x02
|
||||
|
@ -894,7 +897,7 @@ int CDECL _chmod(const char *path, int flags)
|
|||
|
||||
if (oldFlags != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
DWORD newFlags = (flags & MSVCRT__S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
|
||||
DWORD newFlags = (flags & _S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
|
||||
oldFlags | FILE_ATTRIBUTE_READONLY;
|
||||
|
||||
if (newFlags == oldFlags || SetFileAttributesA(path, newFlags))
|
||||
|
@ -913,7 +916,7 @@ int CDECL _wchmod(const wchar_t *path, int flags)
|
|||
|
||||
if (oldFlags != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
DWORD newFlags = (flags & MSVCRT__S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
|
||||
DWORD newFlags = (flags & _S_IWRITE)? oldFlags & ~FILE_ATTRIBUTE_READONLY:
|
||||
oldFlags | FILE_ATTRIBUTE_READONLY;
|
||||
|
||||
if (newFlags == oldFlags || SetFileAttributesW(path, newFlags))
|
||||
|
@ -1127,7 +1130,7 @@ int CDECL _dup2(int od, int nd)
|
|||
if (DuplicateHandle(GetCurrentProcess(), info_od->handle,
|
||||
GetCurrentProcess(), &handle, 0, TRUE, DUPLICATE_SAME_ACCESS))
|
||||
{
|
||||
int wxflag = info_od->wxflag & ~MSVCRT__O_NOINHERIT;
|
||||
int wxflag = info_od->wxflag & ~_O_NOINHERIT;
|
||||
|
||||
if (info_nd->wxflag & WX_OPEN)
|
||||
_close(nd);
|
||||
|
@ -1370,11 +1373,11 @@ int CDECL _locking(int fd, int mode, __msvcrt_long nbytes)
|
|||
}
|
||||
|
||||
TRACE(":fd (%d) by 0x%08Ix mode %s\n",
|
||||
fd,nbytes,(mode==MSVCRT__LK_UNLCK)?"_LK_UNLCK":
|
||||
(mode==MSVCRT__LK_LOCK)?"_LK_LOCK":
|
||||
(mode==MSVCRT__LK_NBLCK)?"_LK_NBLCK":
|
||||
(mode==MSVCRT__LK_RLCK)?"_LK_RLCK":
|
||||
(mode==MSVCRT__LK_NBRLCK)?"_LK_NBRLCK":
|
||||
fd,nbytes,(mode==_LK_UNLCK)?"_LK_UNLCK":
|
||||
(mode==_LK_LOCK)?"_LK_LOCK":
|
||||
(mode==_LK_NBLCK)?"_LK_NBLCK":
|
||||
(mode==_LK_RLCK)?"_LK_RLCK":
|
||||
(mode==_LK_NBRLCK)?"_LK_NBRLCK":
|
||||
"UNKNOWN");
|
||||
|
||||
if ((cur_locn = SetFilePointer(info->handle, 0L, NULL, FILE_CURRENT)) == INVALID_SET_FILE_POINTER)
|
||||
|
@ -1384,7 +1387,7 @@ int CDECL _locking(int fd, int mode, __msvcrt_long nbytes)
|
|||
*_errno() = EINVAL; /* FIXME */
|
||||
return -1;
|
||||
}
|
||||
if (mode == MSVCRT__LK_LOCK || mode == MSVCRT__LK_RLCK)
|
||||
if (mode == _LK_LOCK || mode == _LK_RLCK)
|
||||
{
|
||||
int nretry = 10;
|
||||
ret = 1; /* just to satisfy gcc */
|
||||
|
@ -1395,7 +1398,7 @@ int CDECL _locking(int fd, int mode, __msvcrt_long nbytes)
|
|||
Sleep(1);
|
||||
}
|
||||
}
|
||||
else if (mode == MSVCRT__LK_UNLCK)
|
||||
else if (mode == _LK_UNLCK)
|
||||
ret = UnlockFile(info->handle, cur_locn, 0L, nbytes, 0L);
|
||||
else
|
||||
ret = LockFile(info->handle, cur_locn, 0L, nbytes, 0L);
|
||||
|
@ -1556,15 +1559,15 @@ static int msvcrt_get_flags(const wchar_t* mode, int *open_flags, int* stream_fl
|
|||
switch(*mode++)
|
||||
{
|
||||
case 'R': case 'r':
|
||||
*open_flags = plus ? MSVCRT__O_RDWR : MSVCRT__O_RDONLY;
|
||||
*open_flags = plus ? _O_RDWR : _O_RDONLY;
|
||||
*stream_flags = plus ? _IORW : _IOREAD;
|
||||
break;
|
||||
case 'W': case 'w':
|
||||
*open_flags = MSVCRT__O_CREAT | MSVCRT__O_TRUNC | (plus ? MSVCRT__O_RDWR : MSVCRT__O_WRONLY);
|
||||
*open_flags = _O_CREAT | _O_TRUNC | (plus ? _O_RDWR : _O_WRONLY);
|
||||
*stream_flags = plus ? _IORW : _IOWRT;
|
||||
break;
|
||||
case 'A': case 'a':
|
||||
*open_flags = MSVCRT__O_CREAT | MSVCRT__O_APPEND | (plus ? MSVCRT__O_RDWR : MSVCRT__O_WRONLY);
|
||||
*open_flags = _O_CREAT | _O_APPEND | (plus ? _O_RDWR : _O_WRONLY);
|
||||
*stream_flags = plus ? _IORW : _IOWRT;
|
||||
break;
|
||||
default:
|
||||
|
@ -1578,18 +1581,18 @@ static int msvcrt_get_flags(const wchar_t* mode, int *open_flags, int* stream_fl
|
|||
switch (*mode++)
|
||||
{
|
||||
case 'B': case 'b':
|
||||
*open_flags |= MSVCRT__O_BINARY;
|
||||
*open_flags &= ~MSVCRT__O_TEXT;
|
||||
*open_flags |= _O_BINARY;
|
||||
*open_flags &= ~_O_TEXT;
|
||||
break;
|
||||
case 't':
|
||||
*open_flags |= MSVCRT__O_TEXT;
|
||||
*open_flags &= ~MSVCRT__O_BINARY;
|
||||
*open_flags |= _O_TEXT;
|
||||
*open_flags &= ~_O_BINARY;
|
||||
break;
|
||||
case 'D':
|
||||
*open_flags |= MSVCRT__O_TEMPORARY;
|
||||
*open_flags |= _O_TEMPORARY;
|
||||
break;
|
||||
case 'T':
|
||||
*open_flags |= MSVCRT__O_SHORT_LIVED;
|
||||
*open_flags |= _O_SHORT_LIVED;
|
||||
break;
|
||||
case 'c':
|
||||
*stream_flags |= MSVCRT__IOCOMMIT;
|
||||
|
@ -1598,7 +1601,7 @@ static int msvcrt_get_flags(const wchar_t* mode, int *open_flags, int* stream_fl
|
|||
*stream_flags &= ~MSVCRT__IOCOMMIT;
|
||||
break;
|
||||
case 'N':
|
||||
*open_flags |= MSVCRT__O_NOINHERIT;
|
||||
*open_flags |= _O_NOINHERIT;
|
||||
break;
|
||||
case '+':
|
||||
case ' ':
|
||||
|
@ -1629,17 +1632,17 @@ static int msvcrt_get_flags(const wchar_t* mode, int *open_flags, int* stream_fl
|
|||
|
||||
if(!_wcsnicmp(L"utf-8", mode, 5))
|
||||
{
|
||||
*open_flags |= MSVCRT__O_U8TEXT;
|
||||
*open_flags |= _O_U8TEXT;
|
||||
mode += 5;
|
||||
}
|
||||
else if(!_wcsnicmp(L"utf-16le", mode, 8))
|
||||
{
|
||||
*open_flags |= MSVCRT__O_U16TEXT;
|
||||
*open_flags |= _O_U16TEXT;
|
||||
mode += 8;
|
||||
}
|
||||
else if(!_wcsnicmp(L"unicode", mode, 7))
|
||||
{
|
||||
*open_flags |= MSVCRT__O_WTEXT;
|
||||
*open_flags |= _O_WTEXT;
|
||||
mode += 7;
|
||||
}
|
||||
else
|
||||
|
@ -1774,13 +1777,13 @@ int CDECL _fstat64(int fd, struct _stat64* buf)
|
|||
if (type == FILE_TYPE_PIPE)
|
||||
{
|
||||
buf->st_dev = buf->st_rdev = fd;
|
||||
buf->st_mode = MSVCRT__S_IFIFO;
|
||||
buf->st_mode = _S_IFIFO;
|
||||
buf->st_nlink = 1;
|
||||
}
|
||||
else if (type == FILE_TYPE_CHAR)
|
||||
{
|
||||
buf->st_dev = buf->st_rdev = fd;
|
||||
buf->st_mode = MSVCRT__S_IFCHR;
|
||||
buf->st_mode = _S_IFCHR;
|
||||
buf->st_nlink = 1;
|
||||
}
|
||||
else /* FILE_TYPE_DISK etc. */
|
||||
|
@ -1792,7 +1795,7 @@ int CDECL _fstat64(int fd, struct _stat64* buf)
|
|||
release_ioinfo(info);
|
||||
return -1;
|
||||
}
|
||||
buf->st_mode = MSVCRT__S_IFREG | 0444;
|
||||
buf->st_mode = _S_IFREG | 0444;
|
||||
if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
|
||||
buf->st_mode |= 0222;
|
||||
buf->st_size = ((__int64)hfi.nFileSizeHigh << 32) + hfi.nFileSizeLow;
|
||||
|
@ -2090,28 +2093,23 @@ static unsigned split_oflags(unsigned oflags)
|
|||
int wxflags = 0;
|
||||
unsigned unsupp; /* until we support everything */
|
||||
|
||||
if (oflags & MSVCRT__O_APPEND) wxflags |= WX_APPEND;
|
||||
if (oflags & MSVCRT__O_BINARY) {/* Nothing to do */}
|
||||
else if (oflags & MSVCRT__O_TEXT) wxflags |= WX_TEXT;
|
||||
else if (oflags & MSVCRT__O_WTEXT) wxflags |= WX_TEXT;
|
||||
else if (oflags & MSVCRT__O_U16TEXT) wxflags |= WX_TEXT;
|
||||
else if (oflags & MSVCRT__O_U8TEXT) wxflags |= WX_TEXT;
|
||||
if (oflags & _O_APPEND) wxflags |= WX_APPEND;
|
||||
if (oflags & _O_BINARY) {/* Nothing to do */}
|
||||
else if (oflags & _O_TEXT) wxflags |= WX_TEXT;
|
||||
else if (oflags & _O_WTEXT) wxflags |= WX_TEXT;
|
||||
else if (oflags & _O_U16TEXT) wxflags |= WX_TEXT;
|
||||
else if (oflags & _O_U8TEXT) wxflags |= WX_TEXT;
|
||||
else
|
||||
{
|
||||
int fmode;
|
||||
_get_fmode(&fmode);
|
||||
if (!(fmode & MSVCRT__O_BINARY)) wxflags |= WX_TEXT; /* default to TEXT*/
|
||||
if (!(fmode & _O_BINARY)) wxflags |= WX_TEXT; /* default to TEXT*/
|
||||
}
|
||||
if (oflags & MSVCRT__O_NOINHERIT) wxflags |= WX_DONTINHERIT;
|
||||
if (oflags & _O_NOINHERIT) wxflags |= WX_DONTINHERIT;
|
||||
|
||||
if ((unsupp = oflags & ~(
|
||||
MSVCRT__O_BINARY|MSVCRT__O_TEXT|MSVCRT__O_APPEND|
|
||||
MSVCRT__O_TRUNC|MSVCRT__O_EXCL|MSVCRT__O_CREAT|
|
||||
MSVCRT__O_RDWR|MSVCRT__O_WRONLY|MSVCRT__O_TEMPORARY|
|
||||
MSVCRT__O_NOINHERIT|
|
||||
MSVCRT__O_SEQUENTIAL|MSVCRT__O_RANDOM|MSVCRT__O_SHORT_LIVED|
|
||||
MSVCRT__O_WTEXT|MSVCRT__O_U16TEXT|MSVCRT__O_U8TEXT
|
||||
)))
|
||||
if ((unsupp = oflags & ~(_O_BINARY | _O_TEXT | _O_APPEND | _O_TRUNC | _O_EXCL | _O_CREAT |
|
||||
_O_RDWR | _O_WRONLY | _O_TEMPORARY | _O_NOINHERIT | _O_SEQUENTIAL |
|
||||
_O_RANDOM | _O_SHORT_LIVED | _O_WTEXT | _O_U16TEXT | _O_U8TEXT)))
|
||||
ERR(":unsupported oflags 0x%04x\n",unsupp);
|
||||
|
||||
return wxflags;
|
||||
|
@ -2133,7 +2131,7 @@ int CDECL _pipe(int *pfds, unsigned int psize, int textmode)
|
|||
}
|
||||
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.bInheritHandle = !(textmode & MSVCRT__O_NOINHERIT);
|
||||
sa.bInheritHandle = !(textmode & _O_NOINHERIT);
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
if (CreatePipe(&readHandle, &writeHandle, &sa, psize))
|
||||
{
|
||||
|
@ -2179,11 +2177,11 @@ static int check_bom(HANDLE h, int oflags, BOOL seek)
|
|||
return oflags;
|
||||
|
||||
if (r==sizeof(utf8_bom) && !memcmp(bom, utf8_bom, sizeof(utf8_bom))) {
|
||||
oflags = (oflags & ~(MSVCRT__O_WTEXT | MSVCRT__O_U16TEXT)) | MSVCRT__O_U8TEXT;
|
||||
oflags = (oflags & ~(_O_WTEXT | _O_U16TEXT)) | _O_U8TEXT;
|
||||
}else if (r>=sizeof(utf16_bom) && !memcmp(bom, utf16_bom, sizeof(utf16_bom))) {
|
||||
if (seek && r>2)
|
||||
SetFilePointer(h, 2, NULL, FILE_BEGIN);
|
||||
oflags = (oflags & ~(MSVCRT__O_WTEXT | MSVCRT__O_U8TEXT)) | MSVCRT__O_U16TEXT;
|
||||
oflags = (oflags & ~(_O_WTEXT | _O_U8TEXT)) | _O_U16TEXT;
|
||||
}else if (seek) {
|
||||
SetFilePointer(h, 0, NULL, FILE_BEGIN);
|
||||
}
|
||||
|
@ -2210,28 +2208,28 @@ int CDECL _wsopen_dispatch( const wchar_t* path, int oflags, int shflags, int pm
|
|||
|
||||
*fd = -1;
|
||||
wxflag = split_oflags(oflags);
|
||||
switch (oflags & (MSVCRT__O_RDONLY | MSVCRT__O_WRONLY | MSVCRT__O_RDWR))
|
||||
switch (oflags & (_O_RDONLY | _O_WRONLY | _O_RDWR))
|
||||
{
|
||||
case MSVCRT__O_RDONLY: access |= GENERIC_READ; break;
|
||||
case MSVCRT__O_WRONLY: access |= GENERIC_WRITE; break;
|
||||
case MSVCRT__O_RDWR: access |= GENERIC_WRITE | GENERIC_READ; break;
|
||||
case _O_RDONLY: access |= GENERIC_READ; break;
|
||||
case _O_WRONLY: access |= GENERIC_WRITE; break;
|
||||
case _O_RDWR: access |= GENERIC_WRITE | GENERIC_READ; break;
|
||||
}
|
||||
|
||||
if (oflags & MSVCRT__O_CREAT)
|
||||
if (oflags & _O_CREAT)
|
||||
{
|
||||
if (secure && !MSVCRT_CHECK_PMT(!(pmode & ~(MSVCRT__S_IREAD | MSVCRT__S_IWRITE))))
|
||||
if (secure && !MSVCRT_CHECK_PMT(!(pmode & ~(_S_IREAD | _S_IWRITE))))
|
||||
return EINVAL;
|
||||
|
||||
if (oflags & MSVCRT__O_EXCL)
|
||||
if (oflags & _O_EXCL)
|
||||
creation = CREATE_NEW;
|
||||
else if (oflags & MSVCRT__O_TRUNC)
|
||||
else if (oflags & _O_TRUNC)
|
||||
creation = CREATE_ALWAYS;
|
||||
else
|
||||
creation = OPEN_ALWAYS;
|
||||
}
|
||||
else /* no MSVCRT__O_CREAT */
|
||||
else /* no _O_CREAT */
|
||||
{
|
||||
if (oflags & MSVCRT__O_TRUNC)
|
||||
if (oflags & _O_TRUNC)
|
||||
creation = TRUNCATE_EXISTING;
|
||||
else
|
||||
creation = OPEN_EXISTING;
|
||||
|
@ -2239,16 +2237,16 @@ int CDECL _wsopen_dispatch( const wchar_t* path, int oflags, int shflags, int pm
|
|||
|
||||
switch( shflags )
|
||||
{
|
||||
case MSVCRT__SH_DENYRW:
|
||||
case _SH_DENYRW:
|
||||
sharing = 0L;
|
||||
break;
|
||||
case MSVCRT__SH_DENYWR:
|
||||
case _SH_DENYWR:
|
||||
sharing = FILE_SHARE_READ;
|
||||
break;
|
||||
case MSVCRT__SH_DENYRD:
|
||||
case _SH_DENYRD:
|
||||
sharing = FILE_SHARE_WRITE;
|
||||
break;
|
||||
case MSVCRT__SH_DENYNO:
|
||||
case _SH_DENYNO:
|
||||
sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||
break;
|
||||
default:
|
||||
|
@ -2256,12 +2254,12 @@ int CDECL _wsopen_dispatch( const wchar_t* path, int oflags, int shflags, int pm
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
if (!(pmode & ~MSVCRT_umask & MSVCRT__S_IWRITE))
|
||||
if (!(pmode & ~MSVCRT_umask & _S_IWRITE))
|
||||
attrib = FILE_ATTRIBUTE_READONLY;
|
||||
else
|
||||
attrib = FILE_ATTRIBUTE_NORMAL;
|
||||
|
||||
if (oflags & MSVCRT__O_TEMPORARY)
|
||||
if (oflags & _O_TEMPORARY)
|
||||
{
|
||||
attrib |= FILE_FLAG_DELETE_ON_CLOSE;
|
||||
access |= DELETE;
|
||||
|
@ -2270,9 +2268,9 @@ int CDECL _wsopen_dispatch( const wchar_t* path, int oflags, int shflags, int pm
|
|||
|
||||
sa.nLength = sizeof( SECURITY_ATTRIBUTES );
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = !(oflags & MSVCRT__O_NOINHERIT);
|
||||
sa.bInheritHandle = !(oflags & _O_NOINHERIT);
|
||||
|
||||
if ((oflags&(MSVCRT__O_WTEXT|MSVCRT__O_U16TEXT|MSVCRT__O_U8TEXT))
|
||||
if ((oflags & (_O_WTEXT | _O_U16TEXT | _O_U8TEXT))
|
||||
&& (creation==OPEN_ALWAYS || creation==OPEN_EXISTING)
|
||||
&& !(access&GENERIC_READ))
|
||||
{
|
||||
|
@ -2292,7 +2290,7 @@ int CDECL _wsopen_dispatch( const wchar_t* path, int oflags, int shflags, int pm
|
|||
return *_errno();
|
||||
}
|
||||
|
||||
if (oflags & (MSVCRT__O_WTEXT|MSVCRT__O_U16TEXT|MSVCRT__O_U8TEXT))
|
||||
if (oflags & (_O_WTEXT | _O_U16TEXT | _O_U8TEXT))
|
||||
{
|
||||
LARGE_INTEGER size = {{0}};
|
||||
|
||||
|
@ -2303,7 +2301,7 @@ int CDECL _wsopen_dispatch( const wchar_t* path, int oflags, int shflags, int pm
|
|||
|| creation==CREATE_ALWAYS || creation==TRUNCATE_EXISTING
|
||||
|| ((creation==OPEN_EXISTING || creation==OPEN_ALWAYS) && !size.QuadPart)))
|
||||
{
|
||||
if (oflags & MSVCRT__O_U8TEXT)
|
||||
if (oflags & _O_U8TEXT)
|
||||
{
|
||||
DWORD written = 0, tmp;
|
||||
|
||||
|
@ -2347,11 +2345,11 @@ int CDECL _wsopen_dispatch( const wchar_t* path, int oflags, int shflags, int pm
|
|||
if (*fd == -1)
|
||||
return *_errno();
|
||||
|
||||
if (oflags & MSVCRT__O_WTEXT)
|
||||
if (oflags & _O_WTEXT)
|
||||
get_ioinfo_nolock(*fd)->exflag |= EF_UTF16|EF_UNK_UNICODE;
|
||||
else if (oflags & MSVCRT__O_U16TEXT)
|
||||
else if (oflags & _O_U16TEXT)
|
||||
get_ioinfo_nolock(*fd)->exflag |= EF_UTF16;
|
||||
else if (oflags & MSVCRT__O_U8TEXT)
|
||||
else if (oflags & _O_U8TEXT)
|
||||
get_ioinfo_nolock(*fd)->exflag |= EF_UTF8;
|
||||
|
||||
TRACE(":fd (%d) handle (%p)\n", *fd, hand);
|
||||
|
@ -2375,7 +2373,7 @@ int WINAPIV _wsopen( const wchar_t *path, int oflags, int shflags, ... )
|
|||
int pmode;
|
||||
int fd;
|
||||
|
||||
if (oflags & MSVCRT__O_CREAT)
|
||||
if (oflags & _O_CREAT)
|
||||
{
|
||||
__ms_va_list ap;
|
||||
|
||||
|
@ -2426,7 +2424,7 @@ int WINAPIV _sopen( const char *path, int oflags, int shflags, ... )
|
|||
int pmode;
|
||||
int fd;
|
||||
|
||||
if (oflags & MSVCRT__O_CREAT)
|
||||
if (oflags & _O_CREAT)
|
||||
{
|
||||
__ms_va_list ap;
|
||||
|
||||
|
@ -2447,16 +2445,16 @@ int WINAPIV _open( const char *path, int flags, ... )
|
|||
{
|
||||
__ms_va_list ap;
|
||||
|
||||
if (flags & MSVCRT__O_CREAT)
|
||||
if (flags & _O_CREAT)
|
||||
{
|
||||
int pmode;
|
||||
__ms_va_start(ap, flags);
|
||||
pmode = va_arg(ap, int);
|
||||
__ms_va_end(ap);
|
||||
return _sopen( path, flags, MSVCRT__SH_DENYNO, pmode );
|
||||
return _sopen( path, flags, _SH_DENYNO, pmode );
|
||||
}
|
||||
else
|
||||
return _sopen( path, flags, MSVCRT__SH_DENYNO);
|
||||
return _sopen( path, flags, _SH_DENYNO);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -2466,16 +2464,16 @@ int WINAPIV _wopen(const wchar_t *path,int flags,...)
|
|||
{
|
||||
__ms_va_list ap;
|
||||
|
||||
if (flags & MSVCRT__O_CREAT)
|
||||
if (flags & _O_CREAT)
|
||||
{
|
||||
int pmode;
|
||||
__ms_va_start(ap, flags);
|
||||
pmode = va_arg(ap, int);
|
||||
__ms_va_end(ap);
|
||||
return _wsopen( path, flags, MSVCRT__SH_DENYNO, pmode );
|
||||
return _wsopen( path, flags, _SH_DENYNO, pmode );
|
||||
}
|
||||
else
|
||||
return _wsopen( path, flags, MSVCRT__SH_DENYNO);
|
||||
return _wsopen( path, flags, _SH_DENYNO);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -2483,7 +2481,7 @@ int WINAPIV _wopen(const wchar_t *path,int flags,...)
|
|||
*/
|
||||
int CDECL _creat(const char *path, int pmode)
|
||||
{
|
||||
int flags = MSVCRT__O_CREAT | MSVCRT__O_TRUNC | MSVCRT__O_RDWR;
|
||||
int flags = _O_CREAT | _O_TRUNC | _O_RDWR;
|
||||
return _open(path, flags, pmode);
|
||||
}
|
||||
|
||||
|
@ -2492,7 +2490,7 @@ int CDECL _creat(const char *path, int pmode)
|
|||
*/
|
||||
int CDECL _wcreat(const wchar_t *path, int pmode)
|
||||
{
|
||||
int flags = MSVCRT__O_CREAT | MSVCRT__O_TRUNC | MSVCRT__O_RDWR;
|
||||
int flags = _O_CREAT | _O_TRUNC | _O_RDWR;
|
||||
return _wopen(path, flags, pmode);
|
||||
}
|
||||
|
||||
|
@ -2504,14 +2502,14 @@ int CDECL _open_osfhandle(intptr_t handle, int oflags)
|
|||
DWORD flags;
|
||||
int fd;
|
||||
|
||||
/* MSVCRT__O_RDONLY (0) always matches, so set the read flag
|
||||
/* _O_RDONLY (0) always matches, so set the read flag
|
||||
* MFC's CStdioFile clears O_RDONLY (0)! if it wants to write to the
|
||||
* file, so set the write flag. It also only sets MSVCRT__O_TEXT if it wants
|
||||
* text - it never sets MSVCRT__O_BINARY.
|
||||
* file, so set the write flag. It also only sets _O_TEXT if it wants
|
||||
* text - it never sets _O_BINARY.
|
||||
*/
|
||||
/* don't let split_oflags() decide the mode if no mode is passed */
|
||||
if (!(oflags & (MSVCRT__O_BINARY | MSVCRT__O_TEXT)))
|
||||
oflags |= MSVCRT__O_BINARY;
|
||||
if (!(oflags & (_O_BINARY | _O_TEXT)))
|
||||
oflags |= _O_BINARY;
|
||||
|
||||
flags = GetFileType((HANDLE)handle);
|
||||
if (flags==FILE_TYPE_UNKNOWN && GetLastError()!=NO_ERROR)
|
||||
|
@ -2931,12 +2929,12 @@ int CDECL _read(int fd, void *buf, unsigned int count)
|
|||
int CDECL _setmode(int fd,int mode)
|
||||
{
|
||||
ioinfo *info = get_ioinfo(fd);
|
||||
int ret = info->wxflag & WX_TEXT ? MSVCRT__O_TEXT : MSVCRT__O_BINARY;
|
||||
if(ret==MSVCRT__O_TEXT && (info->exflag & (EF_UTF8|EF_UTF16)))
|
||||
ret = MSVCRT__O_WTEXT;
|
||||
int ret = info->wxflag & WX_TEXT ? _O_TEXT : _O_BINARY;
|
||||
if(ret==_O_TEXT && (info->exflag & (EF_UTF8|EF_UTF16)))
|
||||
ret = _O_WTEXT;
|
||||
|
||||
if(mode!=MSVCRT__O_TEXT && mode!=MSVCRT__O_BINARY && mode!=MSVCRT__O_WTEXT
|
||||
&& mode!=MSVCRT__O_U16TEXT && mode!=MSVCRT__O_U8TEXT) {
|
||||
if(mode!=_O_TEXT && mode!=_O_BINARY && mode!=_O_WTEXT
|
||||
&& mode!=_O_U16TEXT && mode!=_O_U8TEXT) {
|
||||
*_errno() = EINVAL;
|
||||
release_ioinfo(info);
|
||||
return -1;
|
||||
|
@ -2947,7 +2945,7 @@ int CDECL _setmode(int fd,int mode)
|
|||
return EOF;
|
||||
}
|
||||
|
||||
if(mode == MSVCRT__O_BINARY) {
|
||||
if(mode == _O_BINARY) {
|
||||
info->wxflag &= ~WX_TEXT;
|
||||
info->exflag &= ~(EF_UTF8|EF_UTF16);
|
||||
release_ioinfo(info);
|
||||
|
@ -2955,9 +2953,9 @@ int CDECL _setmode(int fd,int mode)
|
|||
}
|
||||
|
||||
info->wxflag |= WX_TEXT;
|
||||
if(mode == MSVCRT__O_TEXT)
|
||||
if(mode == _O_TEXT)
|
||||
info->exflag &= ~(EF_UTF8|EF_UTF16);
|
||||
else if(mode == MSVCRT__O_U8TEXT)
|
||||
else if(mode == _O_U8TEXT)
|
||||
info->exflag = (info->exflag & ~EF_UTF16) | EF_UTF8;
|
||||
else
|
||||
info->exflag = (info->exflag & ~EF_UTF8) | EF_UTF16;
|
||||
|
@ -3017,10 +3015,10 @@ int CDECL _stat64(const char* path, struct _stat64 * buf)
|
|||
|
||||
/* Dir, or regular file? */
|
||||
if (hfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
mode |= (MSVCRT__S_IFDIR | ALL_S_IEXEC);
|
||||
mode |= (_S_IFDIR | ALL_S_IEXEC);
|
||||
else
|
||||
{
|
||||
mode |= MSVCRT__S_IFREG;
|
||||
mode |= _S_IFREG;
|
||||
/* executable? */
|
||||
if (plen > 6 && path[plen-4] == '.') /* shortest exe: "\x.exe" */
|
||||
{
|
||||
|
@ -3169,10 +3167,10 @@ int CDECL _wstat64(const wchar_t* path, struct _stat64 * buf)
|
|||
|
||||
/* Dir, or regular file? */
|
||||
if (hfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
mode |= (MSVCRT__S_IFDIR | ALL_S_IEXEC);
|
||||
mode |= (_S_IFDIR | ALL_S_IEXEC);
|
||||
else
|
||||
{
|
||||
mode |= MSVCRT__S_IFREG;
|
||||
mode |= _S_IFREG;
|
||||
/* executable? */
|
||||
if (plen > 6 && path[plen-4] == '.') /* shortest exe: "\x.exe" */
|
||||
{
|
||||
|
@ -3346,7 +3344,7 @@ int CDECL _umask(int umask)
|
|||
*/
|
||||
int CDECL _utime64(const char* path, struct __utimbuf64 *t)
|
||||
{
|
||||
int fd = _open(path, MSVCRT__O_WRONLY | MSVCRT__O_BINARY);
|
||||
int fd = _open(path, _O_WRONLY | _O_BINARY);
|
||||
|
||||
if (fd > 0)
|
||||
{
|
||||
|
@ -3378,7 +3376,7 @@ int CDECL _utime32(const char* path, struct __utimbuf32 *t)
|
|||
*/
|
||||
int CDECL _wutime64(const wchar_t* path, struct __utimbuf64 *t)
|
||||
{
|
||||
int fd = _wopen(path, MSVCRT__O_WRONLY | MSVCRT__O_BINARY);
|
||||
int fd = _wopen(path, _O_WRONLY | _O_BINARY);
|
||||
|
||||
if (fd > 0)
|
||||
{
|
||||
|
@ -4105,7 +4103,7 @@ FILE * CDECL _wfsopen(const wchar_t *path, const wchar_t *mode, int share)
|
|||
return NULL;
|
||||
|
||||
LOCK_FILES();
|
||||
fd = _wsopen(path, open_flags, share, MSVCRT__S_IREAD | MSVCRT__S_IWRITE);
|
||||
fd = _wsopen(path, open_flags, share, _S_IREAD | _S_IWRITE);
|
||||
if (fd < 0)
|
||||
file = NULL;
|
||||
else if ((file = msvcrt_alloc_fp()) && msvcrt_init_fp(file, fd, stream_flags)
|
||||
|
@ -4157,7 +4155,7 @@ FILE * CDECL _fsopen(const char *path, const char *mode, int share)
|
|||
*/
|
||||
FILE * CDECL fopen(const char *path, const char *mode)
|
||||
{
|
||||
return _fsopen( path, mode, MSVCRT__SH_DENYNO );
|
||||
return _fsopen( path, mode, _SH_DENYNO );
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -4182,7 +4180,7 @@ int CDECL fopen_s(FILE** pFile,
|
|||
*/
|
||||
FILE * CDECL _wfopen(const wchar_t *path, const wchar_t *mode)
|
||||
{
|
||||
return _wfsopen( path, mode, MSVCRT__SH_DENYNO );
|
||||
return _wfsopen( path, mode, _SH_DENYNO );
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -4437,7 +4435,7 @@ FILE* CDECL _wfreopen(const wchar_t *path, const wchar_t *mode, FILE* file)
|
|||
fclose(file);
|
||||
if (msvcrt_get_flags(mode, &open_flags, &stream_flags) == -1)
|
||||
file = NULL;
|
||||
else if((fd = _wopen(path, open_flags, MSVCRT__S_IREAD | MSVCRT__S_IWRITE)) < 0)
|
||||
else if((fd = _wopen(path, open_flags, _S_IREAD | _S_IWRITE)) < 0)
|
||||
file = NULL;
|
||||
else if(msvcrt_init_fp(file, fd, stream_flags) == -1)
|
||||
{
|
||||
|
@ -5068,8 +5066,8 @@ FILE* CDECL tmpfile(void)
|
|||
FILE* file = NULL;
|
||||
|
||||
LOCK_FILES();
|
||||
fd = _open(filename, MSVCRT__O_CREAT | MSVCRT__O_BINARY | MSVCRT__O_RDWR | MSVCRT__O_TEMPORARY,
|
||||
MSVCRT__S_IREAD | MSVCRT__S_IWRITE);
|
||||
fd = _open(filename, _O_CREAT | _O_BINARY | _O_RDWR | _O_TEMPORARY,
|
||||
_S_IREAD | _S_IWRITE);
|
||||
if (fd != -1 && (file = msvcrt_alloc_fp()))
|
||||
{
|
||||
if (msvcrt_init_fp(file, fd, _IORW) == -1)
|
||||
|
|
|
@ -847,7 +847,7 @@ int CDECL strncpy_s(char *dest, size_t numberOfElements,
|
|||
if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return EINVAL;
|
||||
|
||||
if(count!=MSVCRT__TRUNCATE && count<numberOfElements)
|
||||
if(count!=_TRUNCATE && count<numberOfElements)
|
||||
end = count;
|
||||
else
|
||||
end = numberOfElements-1;
|
||||
|
@ -855,7 +855,7 @@ int CDECL strncpy_s(char *dest, size_t numberOfElements,
|
|||
for(i=0; i<end && src[i]; i++)
|
||||
dest[i] = src[i];
|
||||
|
||||
if(!src[i] || end==count || count==MSVCRT__TRUNCATE) {
|
||||
if(!src[i] || end==count || count==_TRUNCATE) {
|
||||
dest[i] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2597,7 +2597,7 @@ int CDECL _mbstowcs_s_l(size_t *ret, wchar_t *wcstr,
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
if(count==MSVCRT__TRUNCATE || size<count)
|
||||
if(count==_TRUNCATE || size<count)
|
||||
conv = size;
|
||||
else
|
||||
conv = count;
|
||||
|
@ -2605,7 +2605,7 @@ int CDECL _mbstowcs_s_l(size_t *ret, wchar_t *wcstr,
|
|||
conv = _mbstowcs_l(wcstr, mbstr, conv, locale);
|
||||
if(conv<size)
|
||||
wcstr[conv++] = '\0';
|
||||
else if(conv==size && count==MSVCRT__TRUNCATE && wcstr[conv-1]!='\0') {
|
||||
else if(conv==size && count==_TRUNCATE && wcstr[conv-1]!='\0') {
|
||||
wcstr[conv-1] = '\0';
|
||||
err = STRUNCATE;
|
||||
}else if(conv==size && wcstr[conv-1]!='\0') {
|
||||
|
|
|
@ -59,7 +59,7 @@ int CDECL rand(void)
|
|||
/* this is the algorithm used by MSVC, according to
|
||||
* http://en.wikipedia.org/wiki/List_of_pseudorandom_number_generators */
|
||||
data->random_seed = data->random_seed * 214013 + 2531011;
|
||||
return (data->random_seed >> 16) & MSVCRT_RAND_MAX;
|
||||
return (data->random_seed >> 16) & RAND_MAX;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -406,7 +406,7 @@ unsigned int CDECL _set_output_format(unsigned int new_output_format)
|
|||
{
|
||||
unsigned int ret = output_format;
|
||||
|
||||
if(!MSVCRT_CHECK_PMT(new_output_format==0 || new_output_format==MSVCRT__TWO_DIGIT_EXPONENT))
|
||||
if(!MSVCRT_CHECK_PMT(new_output_format==0 || new_output_format==_TWO_DIGIT_EXPONENT))
|
||||
return ret;
|
||||
|
||||
output_format = new_output_format;
|
||||
|
|
|
@ -283,91 +283,19 @@ extern unsigned msvcrt_create_io_inherit_block(WORD*, BYTE**) DECLSPEC_HIDDEN;
|
|||
|
||||
extern FILE MSVCRT__iob[];
|
||||
|
||||
#define MSVCRT_RAND_MAX 0x7fff
|
||||
|
||||
#define MSVCRT_NO_CONSOLE_FD (-2)
|
||||
#define MSVCRT_NO_CONSOLE ((HANDLE)MSVCRT_NO_CONSOLE_FD)
|
||||
|
||||
#define MSVCRT_DRIVE_MAX 3
|
||||
#define MSVCRT_FNAME_MAX 256
|
||||
#define MSVCRT_DIR_MAX 256
|
||||
#define MSVCRT_EXT_MAX 256
|
||||
#define MSVCRT_PATH_MAX 260
|
||||
#define MSVCRT_stdin (MSVCRT__iob+STDIN_FILENO)
|
||||
#define MSVCRT_stdout (MSVCRT__iob+STDOUT_FILENO)
|
||||
#define MSVCRT_stderr (MSVCRT__iob+STDERR_FILENO)
|
||||
|
||||
#define MSVCRT__P_WAIT 0
|
||||
#define MSVCRT__P_NOWAIT 1
|
||||
#define MSVCRT__P_OVERLAY 2
|
||||
#define MSVCRT__P_NOWAITO 3
|
||||
#define MSVCRT__P_DETACH 4
|
||||
|
||||
#define MSVCRT__OUT_TO_DEFAULT 0
|
||||
#define MSVCRT__OUT_TO_STDERR 1
|
||||
#define MSVCRT__OUT_TO_MSGBOX 2
|
||||
#define MSVCRT__REPORT_ERRMODE 3
|
||||
|
||||
/* internal file._flag flags */
|
||||
#define MSVCRT__USERBUF 0x0100
|
||||
#define MSVCRT__IOCOMMIT 0x4000
|
||||
|
||||
#define MSVCRT__S_IEXEC 0x0040
|
||||
#define MSVCRT__S_IWRITE 0x0080
|
||||
#define MSVCRT__S_IREAD 0x0100
|
||||
#define MSVCRT__S_IFIFO 0x1000
|
||||
#define MSVCRT__S_IFCHR 0x2000
|
||||
#define MSVCRT__S_IFDIR 0x4000
|
||||
#define MSVCRT__S_IFREG 0x8000
|
||||
#define MSVCRT__S_IFMT 0xF000
|
||||
|
||||
#define MSVCRT__LK_UNLCK 0
|
||||
#define MSVCRT__LK_LOCK 1
|
||||
#define MSVCRT__LK_NBLCK 2
|
||||
#define MSVCRT__LK_RLCK 3
|
||||
#define MSVCRT__LK_NBRLCK 4
|
||||
|
||||
#define MSVCRT__SH_COMPAT 0x00 /* Compatibility */
|
||||
#define MSVCRT__SH_DENYRW 0x10 /* Deny read/write */
|
||||
#define MSVCRT__SH_DENYWR 0x20 /* Deny write */
|
||||
#define MSVCRT__SH_DENYRD 0x30 /* Deny read */
|
||||
#define MSVCRT__SH_DENYNO 0x40 /* Deny nothing */
|
||||
|
||||
#define MSVCRT__O_RDONLY 0
|
||||
#define MSVCRT__O_WRONLY 1
|
||||
#define MSVCRT__O_RDWR 2
|
||||
#define MSVCRT__O_ACCMODE (MSVCRT__O_RDONLY|MSVCRT__O_WRONLY|MSVCRT__O_RDWR)
|
||||
#define MSVCRT__O_APPEND 0x0008
|
||||
#define MSVCRT__O_RANDOM 0x0010
|
||||
#define MSVCRT__O_SEQUENTIAL 0x0020
|
||||
#define MSVCRT__O_TEMPORARY 0x0040
|
||||
#define MSVCRT__O_NOINHERIT 0x0080
|
||||
#define MSVCRT__O_CREAT 0x0100
|
||||
#define MSVCRT__O_TRUNC 0x0200
|
||||
#define MSVCRT__O_EXCL 0x0400
|
||||
#define MSVCRT__O_SHORT_LIVED 0x1000
|
||||
#define MSVCRT__O_TEXT 0x4000
|
||||
#define MSVCRT__O_BINARY 0x8000
|
||||
#define MSVCRT__O_RAW MSVCRT__O_BINARY
|
||||
#define MSVCRT__O_WTEXT 0x10000
|
||||
#define MSVCRT__O_U16TEXT 0x20000
|
||||
#define MSVCRT__O_U8TEXT 0x40000
|
||||
|
||||
#define MSVCRT_CLOCKS_PER_SEC 1000
|
||||
|
||||
#define MSVCRT__TRUNCATE ((size_t)-1)
|
||||
|
||||
#define _MAX__TIME64_T (((__time64_t)0x00000007 << 32) | 0x93406FFF)
|
||||
|
||||
/* _set_abort_behavior codes */
|
||||
#define MSVCRT__WRITE_ABORT_MSG 1
|
||||
#define MSVCRT__CALL_REPORTFAULT 2
|
||||
|
||||
/* _get_output_format return code */
|
||||
#define MSVCRT__TWO_DIGIT_EXPONENT 0x1
|
||||
|
||||
#define MSVCRT__NLSCMPERROR ((unsigned int)0x7fffffff)
|
||||
|
||||
int __cdecl MSVCRT_iswdigit(wint_t);
|
||||
|
||||
int __cdecl MSVCRT__fgetc_nolock(FILE*);
|
||||
|
|
|
@ -966,7 +966,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
|
|||
BOOL standard_rounding = options & _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING;
|
||||
#else
|
||||
BOOL legacy_wide = TRUE, legacy_msvcrt_compat = TRUE;
|
||||
BOOL three_digit_exp = _get_output_format() != MSVCRT__TWO_DIGIT_EXPONENT;
|
||||
BOOL three_digit_exp = _get_output_format() != _TWO_DIGIT_EXPONENT;
|
||||
BOOL standard_rounding = FALSE;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
* -No check for maximum path/argument/environment size is done
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <process.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -139,7 +140,7 @@ static intptr_t msvcrt_spawn(int flags, const wchar_t* exe, wchar_t* cmdline,
|
|||
|
||||
TRACE("%x %s %s %s %d\n", flags, debugstr_w(exe), debugstr_w(cmdline), debugstr_w(env), use_path);
|
||||
|
||||
if ((unsigned)flags > MSVCRT__P_DETACH)
|
||||
if ((unsigned)flags > _P_DETACH)
|
||||
{
|
||||
*_errno() = EINVAL;
|
||||
return -1;
|
||||
|
@ -150,7 +151,7 @@ static intptr_t msvcrt_spawn(int flags, const wchar_t* exe, wchar_t* cmdline,
|
|||
memset(&si, 0, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
msvcrt_create_io_inherit_block(&si.cbReserved2, &si.lpReserved2);
|
||||
if (flags == MSVCRT__P_DETACH) create_flags |= DETACHED_PROCESS;
|
||||
if (flags == _P_DETACH) create_flags |= DETACHED_PROCESS;
|
||||
if (!CreateProcessW(fullname, cmdline, NULL, NULL, TRUE,
|
||||
create_flags, env, NULL, &si, &pi))
|
||||
{
|
||||
|
@ -162,21 +163,21 @@ static intptr_t msvcrt_spawn(int flags, const wchar_t* exe, wchar_t* cmdline,
|
|||
free(si.lpReserved2);
|
||||
switch(flags)
|
||||
{
|
||||
case MSVCRT__P_WAIT:
|
||||
case _P_WAIT:
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
GetExitCodeProcess(pi.hProcess,&pi.dwProcessId);
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
return pi.dwProcessId;
|
||||
case MSVCRT__P_DETACH:
|
||||
case _P_DETACH:
|
||||
CloseHandle(pi.hProcess);
|
||||
pi.hProcess = 0;
|
||||
/* fall through */
|
||||
case MSVCRT__P_NOWAIT:
|
||||
case MSVCRT__P_NOWAITO:
|
||||
case _P_NOWAIT:
|
||||
case _P_NOWAITO:
|
||||
CloseHandle(pi.hThread);
|
||||
return (intptr_t)pi.hProcess;
|
||||
case MSVCRT__P_OVERLAY:
|
||||
case _P_OVERLAY:
|
||||
_exit(0);
|
||||
}
|
||||
return -1; /* can't reach here */
|
||||
|
@ -398,7 +399,7 @@ intptr_t WINAPIV _wexecl(const wchar_t* name, const wchar_t* arg0, ...)
|
|||
args = msvcrt_valisttos(arg0, ap, ' ');
|
||||
__ms_va_end(ap);
|
||||
|
||||
ret = msvcrt_spawn(MSVCRT__P_OVERLAY, name, args, NULL, 0);
|
||||
ret = msvcrt_spawn(_P_OVERLAY, name, args, NULL, 0);
|
||||
|
||||
free(args);
|
||||
return ret;
|
||||
|
@ -422,7 +423,7 @@ intptr_t WINAPIV _execl(const char* name, const char* arg0, ...)
|
|||
args = msvcrt_valisttos_aw(arg0, ap, ' ');
|
||||
__ms_va_end(ap);
|
||||
|
||||
ret = msvcrt_spawn(MSVCRT__P_OVERLAY, nameW, args, NULL, 0);
|
||||
ret = msvcrt_spawn(_P_OVERLAY, nameW, args, NULL, 0);
|
||||
|
||||
free(nameW);
|
||||
free(args);
|
||||
|
@ -451,7 +452,7 @@ intptr_t WINAPIV _wexecle(const wchar_t* name, const wchar_t* arg0, ...)
|
|||
if (envp) envs = msvcrt_argvtos(envp, 0);
|
||||
__ms_va_end(ap);
|
||||
|
||||
ret = msvcrt_spawn(MSVCRT__P_OVERLAY, name, args, envs, 0);
|
||||
ret = msvcrt_spawn(_P_OVERLAY, name, args, envs, 0);
|
||||
|
||||
free(args);
|
||||
free(envs);
|
||||
|
@ -480,7 +481,7 @@ intptr_t WINAPIV _execle(const char* name, const char* arg0, ...)
|
|||
if (envp) envs = msvcrt_argvtos_aw(envp, 0);
|
||||
__ms_va_end(ap);
|
||||
|
||||
ret = msvcrt_spawn(MSVCRT__P_OVERLAY, nameW, args, envs, 0);
|
||||
ret = msvcrt_spawn(_P_OVERLAY, nameW, args, envs, 0);
|
||||
|
||||
free(nameW);
|
||||
free(args);
|
||||
|
@ -503,7 +504,7 @@ intptr_t WINAPIV _wexeclp(const wchar_t* name, const wchar_t* arg0, ...)
|
|||
args = msvcrt_valisttos(arg0, ap, ' ');
|
||||
__ms_va_end(ap);
|
||||
|
||||
ret = msvcrt_spawn(MSVCRT__P_OVERLAY, name, args, NULL, 1);
|
||||
ret = msvcrt_spawn(_P_OVERLAY, name, args, NULL, 1);
|
||||
|
||||
free(args);
|
||||
return ret;
|
||||
|
@ -527,7 +528,7 @@ intptr_t WINAPIV _execlp(const char* name, const char* arg0, ...)
|
|||
args = msvcrt_valisttos_aw(arg0, ap, ' ');
|
||||
__ms_va_end(ap);
|
||||
|
||||
ret = msvcrt_spawn(MSVCRT__P_OVERLAY, nameW, args, NULL, 1);
|
||||
ret = msvcrt_spawn(_P_OVERLAY, nameW, args, NULL, 1);
|
||||
|
||||
free(nameW);
|
||||
free(args);
|
||||
|
@ -556,7 +557,7 @@ intptr_t WINAPIV _wexeclpe(const wchar_t* name, const wchar_t* arg0, ...)
|
|||
if (envp) envs = msvcrt_argvtos(envp, 0);
|
||||
__ms_va_end(ap);
|
||||
|
||||
ret = msvcrt_spawn(MSVCRT__P_OVERLAY, name, args, envs, 1);
|
||||
ret = msvcrt_spawn(_P_OVERLAY, name, args, envs, 1);
|
||||
|
||||
free(args);
|
||||
free(envs);
|
||||
|
@ -585,7 +586,7 @@ intptr_t WINAPIV _execlpe(const char* name, const char* arg0, ...)
|
|||
if (envp) envs = msvcrt_argvtos_aw(envp, 0);
|
||||
__ms_va_end(ap);
|
||||
|
||||
ret = msvcrt_spawn(MSVCRT__P_OVERLAY, nameW, args, envs, 1);
|
||||
ret = msvcrt_spawn(_P_OVERLAY, nameW, args, envs, 1);
|
||||
|
||||
free(nameW);
|
||||
free(args);
|
||||
|
@ -600,7 +601,7 @@ intptr_t WINAPIV _execlpe(const char* name, const char* arg0, ...)
|
|||
*/
|
||||
intptr_t CDECL _wexecv(const wchar_t* name, const wchar_t* const* argv)
|
||||
{
|
||||
return _wspawnve(MSVCRT__P_OVERLAY, name, argv, NULL);
|
||||
return _wspawnve(_P_OVERLAY, name, argv, NULL);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -611,7 +612,7 @@ intptr_t CDECL _wexecv(const wchar_t* name, const wchar_t* const* argv)
|
|||
*/
|
||||
intptr_t CDECL _execv(const char* name, const char* const* argv)
|
||||
{
|
||||
return _spawnve(MSVCRT__P_OVERLAY, name, argv, NULL);
|
||||
return _spawnve(_P_OVERLAY, name, argv, NULL);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -621,7 +622,7 @@ intptr_t CDECL _execv(const char* name, const char* const* argv)
|
|||
*/
|
||||
intptr_t CDECL _wexecve(const wchar_t* name, const wchar_t* const* argv, const wchar_t* const* envv)
|
||||
{
|
||||
return _wspawnve(MSVCRT__P_OVERLAY, name, argv, envv);
|
||||
return _wspawnve(_P_OVERLAY, name, argv, envv);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -632,7 +633,7 @@ intptr_t CDECL _wexecve(const wchar_t* name, const wchar_t* const* argv, const w
|
|||
*/
|
||||
intptr_t CDECL _execve(const char* name, const char* const* argv, const char* const* envv)
|
||||
{
|
||||
return _spawnve(MSVCRT__P_OVERLAY, name, argv, envv);
|
||||
return _spawnve(_P_OVERLAY, name, argv, envv);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -642,7 +643,7 @@ intptr_t CDECL _execve(const char* name, const char* const* argv, const char* co
|
|||
*/
|
||||
intptr_t CDECL _wexecvpe(const wchar_t* name, const wchar_t* const* argv, const wchar_t* const* envv)
|
||||
{
|
||||
return _wspawnvpe(MSVCRT__P_OVERLAY, name, argv, envv);
|
||||
return _wspawnvpe(_P_OVERLAY, name, argv, envv);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -653,7 +654,7 @@ intptr_t CDECL _wexecvpe(const wchar_t* name, const wchar_t* const* argv, const
|
|||
*/
|
||||
intptr_t CDECL _execvpe(const char* name, const char* const* argv, const char* const* envv)
|
||||
{
|
||||
return _spawnvpe(MSVCRT__P_OVERLAY, name, argv, envv);
|
||||
return _spawnvpe(_P_OVERLAY, name, argv, envv);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -1054,7 +1055,7 @@ FILE* CDECL _wpopen(const wchar_t* command, const wchar_t* mode)
|
|||
return NULL;
|
||||
|
||||
_get_fmode(&fmode);
|
||||
textmode = fmode & (MSVCRT__O_BINARY | MSVCRT__O_TEXT);
|
||||
textmode = fmode & (_O_BINARY | _O_TEXT);
|
||||
for (p = mode; *p; p++)
|
||||
{
|
||||
switch (*p)
|
||||
|
@ -1065,13 +1066,13 @@ FILE* CDECL _wpopen(const wchar_t* command, const wchar_t* mode)
|
|||
break;
|
||||
case 'B':
|
||||
case 'b':
|
||||
textmode |= MSVCRT__O_BINARY;
|
||||
textmode &= ~MSVCRT__O_TEXT;
|
||||
textmode |= _O_BINARY;
|
||||
textmode &= ~_O_TEXT;
|
||||
break;
|
||||
case 'T':
|
||||
case 't':
|
||||
textmode |= MSVCRT__O_TEXT;
|
||||
textmode &= ~MSVCRT__O_BINARY;
|
||||
textmode |= _O_TEXT;
|
||||
textmode &= ~_O_BINARY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1120,7 +1121,7 @@ FILE* CDECL _wpopen(const wchar_t* command, const wchar_t* mode)
|
|||
wcscat(fullcmd, L" /c ");
|
||||
wcscat(fullcmd, command);
|
||||
|
||||
if ((container->proc = (HANDLE)msvcrt_spawn(MSVCRT__P_NOWAIT, comspec, fullcmd, NULL, 1))
|
||||
if ((container->proc = (HANDLE)msvcrt_spawn(_P_NOWAIT, comspec, fullcmd, NULL, 1))
|
||||
== INVALID_HANDLE_VALUE)
|
||||
{
|
||||
_close(fds[fdToOpen]);
|
||||
|
@ -1252,7 +1253,7 @@ int CDECL _wsystem(const wchar_t* cmd)
|
|||
wcscat(fullcmd, L" /c ");
|
||||
wcscat(fullcmd, cmd);
|
||||
|
||||
res = msvcrt_spawn(MSVCRT__P_WAIT, comspec, fullcmd, NULL, 1);
|
||||
res = msvcrt_spawn(_P_WAIT, comspec, fullcmd, NULL, 1);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, comspec);
|
||||
HeapFree(GetProcessHeap(), 0, fullcmd);
|
||||
|
|
|
@ -1350,7 +1350,7 @@ int CDECL strncat_s( char* dst, size_t elem, const char* src, size_t count )
|
|||
{
|
||||
for(j = 0; (j + i) < elem; j++)
|
||||
{
|
||||
if(count == MSVCRT__TRUNCATE && j + i == elem - 1)
|
||||
if(count == _TRUNCATE && j + i == elem - 1)
|
||||
{
|
||||
dst[j + i] = '\0';
|
||||
return STRUNCATE;
|
||||
|
@ -2656,7 +2656,7 @@ int __cdecl _strnicmp_l(const char *s1, const char *s2,
|
|||
int c1, c2;
|
||||
|
||||
if(s1==NULL || s2==NULL)
|
||||
return MSVCRT__NLSCMPERROR;
|
||||
return _NLSCMPERROR;
|
||||
|
||||
if(!count)
|
||||
return 0;
|
||||
|
@ -2766,7 +2766,7 @@ int __cdecl _memicmp_l(const void *v1, const void *v2, size_t len, _locale_t loc
|
|||
{
|
||||
if (len)
|
||||
MSVCRT_INVALID_PMT(NULL, EINVAL);
|
||||
return len ? MSVCRT__NLSCMPERROR : 0;
|
||||
return len ? _NLSCMPERROR : 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -666,7 +666,7 @@ clock_t CDECL clock(void)
|
|||
LARGE_INTEGER systime;
|
||||
|
||||
NtQuerySystemTime(&systime);
|
||||
return (systime.QuadPart - init_time) / (TICKSPERSEC / MSVCRT_CLOCKS_PER_SEC);
|
||||
return (systime.QuadPart - init_time) / (TICKSPERSEC / CLOCKS_PER_SEC);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -1381,7 +1381,7 @@ static size_t strftime_impl(STRFTIME_CHAR *str, size_t max,
|
|||
#else
|
||||
if(_mbstowcs_s_l(&tmp, str+ret, max-ret,
|
||||
mstm->tm_isdst ? tzname_dst : tzname_std,
|
||||
MSVCRT__TRUNCATE, loc) == STRUNCATE)
|
||||
_TRUNCATE, loc) == STRUNCATE)
|
||||
ret = max;
|
||||
#endif
|
||||
ret += tmp-1;
|
||||
|
|
|
@ -124,7 +124,7 @@ INT CDECL _wcsicmp_l(const wchar_t *str1, const wchar_t *str2, _locale_t locale)
|
|||
wchar_t c1, c2;
|
||||
|
||||
if(!MSVCRT_CHECK_PMT(str1 != NULL) || !MSVCRT_CHECK_PMT(str2 != NULL))
|
||||
return MSVCRT__NLSCMPERROR;
|
||||
return _NLSCMPERROR;
|
||||
|
||||
if(!locale)
|
||||
locale = get_current_locale_noalloc(&tmp);
|
||||
|
@ -170,7 +170,7 @@ INT CDECL _wcsnicmp_l(const wchar_t *str1, const wchar_t *str2,
|
|||
return 0;
|
||||
|
||||
if(!MSVCRT_CHECK_PMT(str1 != NULL) || !MSVCRT_CHECK_PMT(str2 != NULL))
|
||||
return MSVCRT__NLSCMPERROR;
|
||||
return _NLSCMPERROR;
|
||||
|
||||
if(!locale)
|
||||
locale = get_current_locale_noalloc(&tmp);
|
||||
|
@ -703,7 +703,7 @@ static int wcsrtombs_s_l(size_t *ret, char *mbstr, size_t size,
|
|||
if (!MSVCRT_CHECK_PMT(wcstr != NULL)) return EINVAL;
|
||||
if (!MSVCRT_CHECK_PMT(*wcstr != NULL)) return EINVAL;
|
||||
|
||||
if(count==MSVCRT__TRUNCATE || size<count)
|
||||
if(count==_TRUNCATE || size<count)
|
||||
conv = size;
|
||||
else
|
||||
conv = count;
|
||||
|
@ -717,9 +717,9 @@ static int wcsrtombs_s_l(size_t *ret, char *mbstr, size_t size,
|
|||
err = *_errno();
|
||||
}else if(conv < size)
|
||||
mbstr[conv++] = '\0';
|
||||
else if(conv==size && (count==MSVCRT__TRUNCATE || mbstr[conv-1]=='\0')) {
|
||||
else if(conv==size && (count==_TRUNCATE || mbstr[conv-1]=='\0')) {
|
||||
mbstr[conv-1] = '\0';
|
||||
if(count==MSVCRT__TRUNCATE)
|
||||
if(count==_TRUNCATE)
|
||||
err = STRUNCATE;
|
||||
}else {
|
||||
MSVCRT_INVALID_PMT("mbstr[size] is too small", ERANGE);
|
||||
|
@ -969,7 +969,7 @@ static int CDECL vsnprintf_s_l_opt( char *str, size_t sizeOfBuffer,
|
|||
puts_clbk_str_a(&ctx, 1, &nullbyte);
|
||||
|
||||
if(ret<0 || ret==len) {
|
||||
if(count!=MSVCRT__TRUNCATE && count>sizeOfBuffer) {
|
||||
if(count!=_TRUNCATE && count>sizeOfBuffer) {
|
||||
MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", ERANGE);
|
||||
memset(str, 0, sizeOfBuffer);
|
||||
} else
|
||||
|
@ -999,7 +999,7 @@ static int vsnwprintf_s_l_opt( wchar_t *str, size_t sizeOfBuffer,
|
|||
puts_clbk_str_w(&ctx, 1, L"");
|
||||
|
||||
if(ret<0 || ret==len) {
|
||||
if(count!=MSVCRT__TRUNCATE && count>sizeOfBuffer) {
|
||||
if(count!=_TRUNCATE && count>sizeOfBuffer) {
|
||||
MSVCRT_INVALID_PMT("str[sizeOfBuffer] is too small", ERANGE);
|
||||
memset(str, 0, sizeOfBuffer*sizeof(wchar_t));
|
||||
} else
|
||||
|
@ -2348,7 +2348,7 @@ INT CDECL wcsncpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc,
|
|||
size_t count )
|
||||
{
|
||||
WCHAR *p = wcDest;
|
||||
BOOL truncate = (count == MSVCRT__TRUNCATE);
|
||||
BOOL truncate = (count == _TRUNCATE);
|
||||
|
||||
if(!wcDest && !numElement && !count)
|
||||
return 0;
|
||||
|
@ -2447,7 +2447,7 @@ INT CDECL wcsncat_s(wchar_t *dst, size_t elem,
|
|||
return EINVAL;
|
||||
}
|
||||
|
||||
if (count == MSVCRT__TRUNCATE)
|
||||
if (count == _TRUNCATE)
|
||||
{
|
||||
srclen = wcslen(src);
|
||||
if (srclen >= (elem - dststart))
|
||||
|
|
Loading…
Reference in New Issue