msvcrt: Added unicode modes support _setmode function.

This commit is contained in:
Piotr Caban 2013-01-10 11:44:48 +01:00 committed by Alexandre Julliard
parent eeb7d0a649
commit a0ef884542
1 changed files with 24 additions and 7 deletions

View File

@ -2232,14 +2232,31 @@ int CDECL MSVCRT__read(int fd, void *buf, unsigned int count)
*/
int CDECL MSVCRT__setmode(int fd,int mode)
{
int ret = msvcrt_get_ioinfo(fd)->wxflag & WX_TEXT ? MSVCRT__O_TEXT : MSVCRT__O_BINARY;
if (mode & (~(MSVCRT__O_TEXT|MSVCRT__O_BINARY)))
FIXME("fd (%d) mode (0x%08x) unknown\n",fd,mode);
if ((mode & MSVCRT__O_TEXT) == MSVCRT__O_TEXT)
int ret = msvcrt_get_ioinfo(fd)->wxflag & WX_TEXT ? MSVCRT__O_TEXT : MSVCRT__O_BINARY;
if(ret==MSVCRT__O_TEXT && (msvcrt_get_ioinfo(fd)->exflag & (EF_UTF8|EF_UTF16)))
ret = MSVCRT__O_WTEXT;
if(mode!=MSVCRT__O_TEXT && mode!=MSVCRT__O_BINARY && mode!=MSVCRT__O_WTEXT
&& mode!=MSVCRT__O_U16TEXT && mode!=MSVCRT__O_U8TEXT) {
*MSVCRT__errno() = MSVCRT_EINVAL;
return -1;
}
if(mode == MSVCRT__O_BINARY) {
msvcrt_get_ioinfo(fd)->wxflag &= ~WX_TEXT;
msvcrt_get_ioinfo(fd)->exflag &= ~(EF_UTF8|EF_UTF16);
return ret;
}
msvcrt_get_ioinfo(fd)->wxflag |= WX_TEXT;
else
msvcrt_get_ioinfo(fd)->wxflag &= ~WX_TEXT;
return ret;
if(mode == MSVCRT__O_TEXT)
msvcrt_get_ioinfo(fd)->exflag &= ~(EF_UTF8|EF_UTF16);
else if(mode == MSVCRT__O_U8TEXT)
msvcrt_get_ioinfo(fd)->exflag = (msvcrt_get_ioinfo(fd)->exflag & ~EF_UTF16) | EF_UTF8;
else
msvcrt_get_ioinfo(fd)->exflag = (msvcrt_get_ioinfo(fd)->exflag & ~EF_UTF8) | EF_UTF16;
return ret;
}
/*********************************************************************