ReactOS 0.4.16-dev-2104-gb84fa49
corecrt_wstdio.h File Reference
#include <corecrt.h>
#include <corecrt_stdio_config.h>
#include <stdarg.h>
#include <pshpack8.h>
#include <poppack.h>
Include dependency graph for corecrt_wstdio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _iobuf
 

Macros

#define _FILE_DEFINED
 
#define WEOF   (wint_t)(0xFFFF)
 
#define stdin   (__acrt_iob_func(0))
 
#define stdout   (__acrt_iob_func(1))
 
#define stderr   (__acrt_iob_func(2))
 

Typedefs

typedef struct _iobuf FILE
 

Functions

_ACRTIMP FILE *__cdecl __acrt_iob_func (unsigned index)
 
_ACRTIMP wint_t __cdecl _fgetwc_nolock (FILE *)
 
_ACRTIMP wint_t __cdecl _fgetwchar (void)
 
_ACRTIMP wint_t __cdecl _fputwc_nolock (wint_t, FILE *)
 
_ACRTIMP wint_t __cdecl _fputwchar (wint_t)
 
_ACRTIMP wint_t __cdecl _getwc_nolock (FILE *)
 
_ACRTIMP wchar_t *__cdecl _getws (wchar_t *)
 
_ACRTIMP wint_t __cdecl _putwc_nolock (wint_t, FILE *)
 
_ACRTIMP int __cdecl _putws (const wchar_t *)
 
_ACRTIMP wint_t __cdecl _ungetwc_nolock (wint_t, FILE *)
 
_ACRTIMP FILE *__cdecl _wfdopen (int, const wchar_t *)
 
_ACRTIMP FILE *__cdecl _wfopen (const wchar_t *, const wchar_t *)
 
_ACRTIMP errno_t __cdecl _wfopen_s (FILE **, const wchar_t *, const wchar_t *)
 
_ACRTIMP FILE *__cdecl _wfreopen (const wchar_t *, const wchar_t *, FILE *)
 
_ACRTIMP FILE *__cdecl _wfsopen (const wchar_t *, const wchar_t *, int)
 
_ACRTIMP void __cdecl _wperror (const wchar_t *)
 
_ACRTIMP FILE *__cdecl _wpopen (const wchar_t *, const wchar_t *)
 
_ACRTIMP int __cdecl _wremove (const wchar_t *)
 
_ACRTIMP wchar_t *__cdecl _wtempnam (const wchar_t *, const wchar_t *)
 
_ACRTIMP wchar_t *__cdecl _wtmpnam (wchar_t *)
 
_ACRTIMP wint_t __cdecl fgetwc (FILE *)
 
_ACRTIMP wchar_t *__cdecl fgetws (wchar_t *, int, FILE *)
 
_ACRTIMP wint_t __cdecl fputwc (wint_t, FILE *)
 
_ACRTIMP int __cdecl fputws (const wchar_t *, FILE *)
 
_ACRTIMP wint_t __cdecl getwc (FILE *)
 
_ACRTIMP wint_t __cdecl getwchar (void)
 
_ACRTIMP wchar_t *__cdecl getws (wchar_t *)
 
_ACRTIMP wint_t __cdecl putwc (wint_t, FILE *)
 
_ACRTIMP wint_t __cdecl putwchar (wint_t)
 
_ACRTIMP int __cdecl putws (const wchar_t *)
 
_ACRTIMP wint_t __cdecl ungetwc (wint_t, FILE *)
 
_ACRTIMP int __cdecl _scwprintf (const wchar_t *,...)
 
_ACRTIMP int __cdecl _snwprintf (wchar_t *, size_t, const wchar_t *,...)
 
_ACRTIMP int __cdecl _snwprintf_s (wchar_t *, size_t, size_t, const wchar_t *,...)
 
_ACRTIMP int __cdecl _vscwprintf (const wchar_t *, va_list)
 
_ACRTIMP int __cdecl _vscwprintf_p_l (const wchar_t *, _locale_t, va_list)
 
_ACRTIMP int __cdecl _vsnwprintf (wchar_t *, size_t, const wchar_t *, va_list)
 
_ACRTIMP int __cdecl _vsnwprintf_s (wchar_t *, size_t, size_t, const wchar_t *, va_list)
 
_ACRTIMP int __cdecl _vswprintf_p_l (wchar_t *, size_t, const wchar_t *, _locale_t, va_list)
 
_ACRTIMP int __cdecl fwprintf (FILE *, const wchar_t *,...)
 
_ACRTIMP int __cdecl fwprintf_s (FILE *, const wchar_t *,...)
 
_ACRTIMP int __cdecl swprintf_s (wchar_t *, size_t, const wchar_t *,...)
 
_ACRTIMP int __cdecl vfwprintf (FILE *, const wchar_t *, va_list)
 
_ACRTIMP int __cdecl vfwprintf_s (FILE *, const wchar_t *, va_list)
 
_ACRTIMP int __cdecl vswprintf_s (wchar_t *, size_t, const wchar_t *, va_list)
 
_ACRTIMP int __cdecl vwprintf (const wchar_t *, va_list)
 
_ACRTIMP int __cdecl vwprintf_s (const wchar_t *, va_list)
 
_ACRTIMP int __cdecl wprintf (const wchar_t *,...)
 
_ACRTIMP int __cdecl wprintf_s (const wchar_t *,...)
 
static int __cdecl vswprintf (wchar_t *buffer, size_t size, const wchar_t *format, va_list args)
 
static int __cdecl swprintf (wchar_t *buffer, size_t size, const wchar_t *format,...)
 
_ACRTIMP int __cdecl fwscanf (FILE *, const wchar_t *,...)
 
_ACRTIMP int __cdecl fwscanf_s (FILE *, const wchar_t *,...)
 
_ACRTIMP int __cdecl swscanf (const wchar_t *, const wchar_t *,...)
 
_ACRTIMP int __cdecl swscanf_s (const wchar_t *, const wchar_t *,...)
 
_ACRTIMP int __cdecl wscanf (const wchar_t *,...)
 
_ACRTIMP int __cdecl wscanf_s (const wchar_t *,...)
 

Macro Definition Documentation

◆ _FILE_DEFINED

#define _FILE_DEFINED

This file has no copyright assigned and is placed in the Public Domain. This file is part of the Wine project. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 24 of file corecrt_wstdio.h.

◆ stderr

#define stderr   (__acrt_iob_func(2))

Definition at line 52 of file corecrt_wstdio.h.

◆ stdin

#define stdin   (__acrt_iob_func(0))

Definition at line 50 of file corecrt_wstdio.h.

◆ stdout

#define stdout   (__acrt_iob_func(1))

Definition at line 51 of file corecrt_wstdio.h.

◆ WEOF

#define WEOF   (wint_t)(0xFFFF)

Definition at line 45 of file corecrt_wstdio.h.

Typedef Documentation

◆ FILE

typedef struct _iobuf FILE

Function Documentation

◆ __acrt_iob_func()

_ACRTIMP FILE *__cdecl __acrt_iob_func ( unsigned  index)

Definition at line 35 of file iob.c.

36{
37 return __iob_func() + idx;
38}
unsigned int idx
Definition: utils.c:41
FILE *__cdecl __iob_func(void)
Definition: file.c:972

◆ _fgetwc_nolock()

_ACRTIMP wint_t __cdecl _fgetwc_nolock ( FILE file)

Definition at line 3949 of file file.c.

3950{
3951 wint_t ret;
3952 int ch;
3953
3955 || !(get_ioinfo_nolock(file->_file)->wxflag & WX_TEXT)) {
3956 char *p;
3957
3958 for(p=(char*)&ret; (wint_t*)p<&ret+1; p++) {
3960 if(ch == EOF) {
3961 ret = WEOF;
3962 break;
3963 }
3964 *p = (char)ch;
3965 }
3966 }else {
3967 char mbs[MB_LEN_MAX];
3968 int len = 0;
3969
3971 if(ch != EOF) {
3972 mbs[0] = (char)ch;
3973 if(isleadbyte((unsigned char)mbs[0])) {
3975 if(ch != EOF) {
3976 mbs[1] = (char)ch;
3977 len = 2;
3978 }
3979 }else {
3980 len = 1;
3981 }
3982 }
3983
3984 if(!len || mbtowc(&ret, mbs, len)==-1)
3985 ret = WEOF;
3986 }
3987
3988 return ret;
3989}
unsigned char ch[4][2]
Definition: console.c:118
static enum textmode ioinfo_get_textmode(ioinfo *info)
Definition: file.c:211
static ioinfo * get_ioinfo_nolock(int fd)
Definition: file.c:394
@ TEXTMODE_ANSI
Definition: file.c:96
#define WX_TEXT
Definition: file.c:87
unsigned short wint_t
Definition: corecrt.h:243
#define WEOF
#define MB_LEN_MAX
Definition: limits.h:7
#define EOF
Definition: stdio.h:33
unsigned char
Definition: typeof.h:29
return ret
Definition: mutex.c:146
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
#define _fgetc_nolock(_stream)
Definition: stdio.h:1142
#define isleadbyte(_c)
Definition: wchar.h:598
#define mbtowc(wp, cp, len)
Definition: wchar.h:155
Definition: fci.c:127
unsigned char wxflag
Definition: file.c:130
char mbs[5]

Referenced by _getwc_nolock(), _getws(), fgetwc(), and fgetws().

◆ _fgetwchar()

_ACRTIMP wint_t __cdecl _fgetwchar ( void  )

Definition at line 4027 of file file.c.

4028{
4029 return fgetwc(stdin);
4030}
wint_t CDECL fgetwc(FILE *file)
Definition: file.c:3935
#define stdin

◆ _fputwc_nolock()

_ACRTIMP wint_t __cdecl _fputwc_nolock ( wint_t  wc,
FILE file 
)

Definition at line 4217 of file file.c.

4218{
4219 wchar_t mwc=wc;
4220 ioinfo *fdinfo;
4221 wint_t ret;
4222
4223 fdinfo = get_ioinfo_nolock(file->_file);
4224
4225 if((fdinfo->wxflag&WX_TEXT) && ioinfo_get_textmode(fdinfo) == TEXTMODE_ANSI) {
4226 char buf[MB_LEN_MAX];
4227 int char_len;
4228
4229 char_len = wctomb(buf, mwc);
4230 if(char_len!=-1 && _fwrite_nolock(buf, char_len, 1, file)==1)
4231 ret = wc;
4232 else
4233 ret = WEOF;
4234 }else if(_fwrite_nolock(&mwc, sizeof(mwc), 1, file) == 1) {
4235 ret = wc;
4236 }else {
4237 ret = WEOF;
4238 }
4239
4240 return ret;
4241}
size_t CDECL _fwrite_nolock(const void *ptr, size_t size, size_t nmemb, FILE *file)
Definition: file.c:4143
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define wctomb
Definition: wctomb.c:31
Definition: file.c:128

Referenced by _putwc_nolock(), _putws(), fputwc(), fputws(), and puts_clbk_file_w().

◆ _fputwchar()

_ACRTIMP wint_t __cdecl _fputwchar ( wint_t  wc)

Definition at line 4246 of file file.c.

4247{
4248 return fputwc(wc, stdout);
4249}
wint_t CDECL fputwc(wint_t wc, FILE *file)
Definition: file.c:4203
#define stdout

Referenced by fputwchar(), and putwchar().

◆ _getwc_nolock()

_ACRTIMP wint_t __cdecl _getwc_nolock ( FILE stream)

Definition at line 91 of file fgetwc.cpp.

92{
93 return _fgetwc_nolock(stream);
94}
wint_t __cdecl _fgetwc_nolock(FILE *const public_stream)
Definition: fgetwc.cpp:14
Definition: parse.h:23

◆ _getws()

_ACRTIMP wchar_t *__cdecl _getws ( wchar_t buf)

Definition at line 4879 of file file.c.

4880{
4881 wint_t cc;
4882 wchar_t* ws = buf;
4883
4885 for (cc = _fgetwc_nolock(stdin); cc != WEOF && cc != '\n';
4887 {
4888 if (cc != '\r')
4889 *buf++ = (wchar_t)cc;
4890 }
4892
4893 if ((cc == WEOF) && (ws == buf))
4894 {
4895 TRACE(":nothing read\n");
4896 return NULL;
4897 }
4898 *buf = '\0';
4899
4900 TRACE("got %s\n", debugstr_w(ws));
4901 return ws;
4902}
#define NULL
Definition: types.h:112
wint_t CDECL _fgetwc_nolock(FILE *file)
Definition: file.c:3949
void CDECL _lock_file(FILE *file)
Definition: file.c:1487
void CDECL _unlock_file(FILE *file)
Definition: file.c:1499
uint32_t cc
Definition: isohybrid.c:75
#define debugstr_w
Definition: kernel32.h:32
#define wchar_t
Definition: wchar.h:102
const char * ws
Definition: skip_ws.cpp:7
#define TRACE(s)
Definition: solgame.cpp:4

◆ _putwc_nolock()

_ACRTIMP wint_t __cdecl _putwc_nolock ( wint_t  c,
FILE stream 
)

Definition at line 89 of file fputwc.cpp.

90{
91 return _fputwc_nolock(c, stream);
92}
wint_t __cdecl _fputwc_nolock(wchar_t const c, FILE *const public_stream)
Definition: fputwc.cpp:83
const GLubyte * c
Definition: glext.h:8905

◆ _putws()

_ACRTIMP int __cdecl _putws ( const wchar_t s)

Definition at line 4942 of file file.c.

4943{
4944 int ret;
4945
4947 ret = fputws(s, stdout);
4948 if(ret >= 0)
4949 ret = _fputwc_nolock('\n', stdout);
4951 return ret >= 0 ? 0 : WEOF;
4952}
wint_t CDECL _fputwc_nolock(wint_t wc, FILE *file)
Definition: file.c:4217
int CDECL fputws(const wchar_t *s, FILE *file)
Definition: file.c:4783
GLdouble s
Definition: gl.h:2039

Referenced by Wait().

◆ _scwprintf()

_ACRTIMP int __cdecl _scwprintf ( const wchar_t format,
  ... 
)

Definition at line 1673 of file wcs.c.

1674{
1675 va_list ap;
1676 int r;
1677
1678 va_start( ap, format );
1680 va_end( ap );
1681 return r;
1682}
#define INT_MAX
Definition: limits.h:26
#define va_end(v)
Definition: stdarg.h:28
#define va_start(v, l)
Definition: stdarg.h:26
char * va_list
Definition: vadefs.h:50
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define _vsnwprintf
Definition: _vsnwprintf.c:28
Definition: format.c:58
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36

Referenced by BuildUserModeWindowStationName(), and IntResolveDesktop().

◆ _snwprintf()

◆ _snwprintf_s()

_ACRTIMP int __cdecl _snwprintf_s ( wchar_t str,
size_t  len,
size_t  count,
const wchar_t format,
  ... 
)

Definition at line 1520 of file wcs.c.

1522{
1523 int retval;
1527 va_end(valist);
1528 return retval;
1529}
int CDECL _vsnwprintf_s_l(wchar_t *str, size_t sizeOfBuffer, size_t count, const wchar_t *format, _locale_t locale, va_list valist)
Definition: wcs.c:1473
GLuint GLuint GLsizei count
Definition: gl.h:1545

Referenced by _VCrtDbgReportW(), and common_message_window().

◆ _ungetwc_nolock()

_ACRTIMP wint_t __cdecl _ungetwc_nolock ( wint_t  wc,
FILE file 
)

Definition at line 5799 of file file.c.

5800{
5801 wchar_t mwc = wc;
5802
5803 if(!MSVCRT_CHECK_PMT(file != NULL)) return WEOF;
5804 if (wc == WEOF)
5805 return WEOF;
5806
5808 || !(get_ioinfo_nolock(file->_file)->wxflag & WX_TEXT)) {
5809 unsigned char * pp = (unsigned char *)&mwc;
5810 int i;
5811
5812 for(i=sizeof(wchar_t)-1;i>=0;i--) {
5813 if(pp[i] != _ungetc_nolock(pp[i],file))
5814 return WEOF;
5815 }
5816 }else {
5817 char mbs[MB_LEN_MAX];
5818 int len;
5819
5820 len = wctomb(mbs, mwc);
5821 if(len == -1)
5822 return WEOF;
5823
5824 for(len--; len>=0; len--) {
5825 if(mbs[len] != _ungetc_nolock(mbs[len], file))
5826 return WEOF;
5827 }
5828 }
5829
5830 return mwc;
5831}
int CDECL _ungetc_nolock(int c, FILE *file)
Definition: file.c:5748
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by ungetwc().

◆ _vscwprintf()

_ACRTIMP int __cdecl _vscwprintf ( const wchar_t format,
va_list  args 
)

Definition at line 1782 of file wcs.c.

1783{
1784 return _vsnwprintf( NULL, INT_MAX, format, args );
1785}
Definition: match.c:390

Referenced by _scwprintf(), BestFit_Write(), call_varargs(), DisplayMessage(), DisplayMessageV(), and InfoMessageBox().

◆ _vscwprintf_p_l()

_ACRTIMP int __cdecl _vscwprintf_p_l ( const wchar_t format,
_locale_t  locale,
va_list  args 
)

Definition at line 1798 of file wcs.c.

1799{
1801}
Definition: _locale.h:75
static int vswprintf_p_l_opt(wchar_t *buffer, size_t length, const wchar_t *format, DWORD options, _locale_t locale, va_list args)
Definition: wcs.c:1410

◆ _vsnwprintf()

_ACRTIMP int __cdecl _vsnwprintf ( wchar_t str,
size_t  len,
const wchar_t format,
va_list  valist 
)

Definition at line 1365 of file wcs.c.

1367{
1368 struct _str_ctx_w ctx = {len, str};
1369 int ret;
1370
1371 ret = pf_printf_w(puts_clbk_str_w, &ctx, format, NULL, 0,
1373 puts_clbk_str_w(&ctx, 1, L"");
1374 return ret;
1375}
int pf_printf_w(puts_clbk_w, void *, const wchar_t *, _locale_t, DWORD, args_clbk, void *, va_list *)
printf_arg arg_clbk_valist(void *ctx, int arg_pos, int type, va_list *valist)
Definition: wcs.c:847
#define L(x)
Definition: resources.c:13

◆ _vsnwprintf_s()

_ACRTIMP int __cdecl _vsnwprintf_s ( wchar_t str,
size_t  sizeOfBuffer,
size_t  count,
const wchar_t format,
va_list  valist 
)

Definition at line 1483 of file wcs.c.

1485{
1487 format, NULL, valist);
1488}
static size_t sizeOfBuffer
Definition: printf.c:48

Referenced by swprintf_s(), and vswprintf_s().

◆ _vswprintf_p_l()

_ACRTIMP int __cdecl _vswprintf_p_l ( wchar_t buffer,
size_t  length,
const wchar_t format,
_locale_t  locale,
va_list  args 
)

Definition at line 1439 of file wcs.c.

1441{
1443}
GLuint buffer
Definition: glext.h:5915
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

◆ _wfdopen()

_ACRTIMP FILE *__cdecl _wfdopen ( int  fd,
const wchar_t mode 
)

Definition at line 1863 of file file.c.

1864{
1865 int open_flags, stream_flags;
1866 FILE* file;
1867
1868 if (msvcrt_get_flags(mode, &open_flags, &stream_flags) == -1) return NULL;
1869
1870 LOCK_FILES();
1871 if (!(file = msvcrt_alloc_fp()))
1872 file = NULL;
1873 else if (msvcrt_init_fp(file, fd, stream_flags) == -1)
1874 {
1875 file->_flag = 0;
1876 file = NULL;
1877 }
1878 else TRACE(":fd (%d) mode (%s) FILE* (%p)\n", fd, debugstr_w(mode), file);
1879 UNLOCK_FILES();
1880
1881 return file;
1882}
static FILE * msvcrt_alloc_fp(void)
Definition: file.c:615
#define LOCK_FILES()
Definition: file.c:306
static int msvcrt_get_flags(const wchar_t *mode, int *open_flags, int *stream_flags)
Definition: file.c:1722
#define UNLOCK_FILES()
Definition: file.c:307
static int msvcrt_init_fp(FILE *file, int fd, unsigned stream_flags)
Definition: file.c:649
GLenum mode
Definition: glext.h:6217
static int fd
Definition: io.c:51

Referenced by _fdopen(), and _wpopen().

◆ _wfopen()

◆ _wfopen_s()

_ACRTIMP errno_t __cdecl _wfopen_s ( FILE **  pFile,
const wchar_t filename,
const wchar_t mode 
)

Definition at line 4343 of file file.c.

4345{
4346 if (!MSVCRT_CHECK_PMT(pFile != NULL)) return EINVAL;
4347 if (!MSVCRT_CHECK_PMT(filename != NULL)) return EINVAL;
4348 if (!MSVCRT_CHECK_PMT(mode != NULL)) return EINVAL;
4349
4351
4352 if(!*pFile)
4353 return *_errno();
4354 return 0;
4355}
int *CDECL _errno(void)
Definition: errno.c:215
FILE *CDECL _wfopen(const wchar_t *path, const wchar_t *mode)
Definition: file.c:4335
#define EINVAL
Definition: errno.h:44
MdFileObject pFile
const char * filename
Definition: ioapi.h:137

◆ _wfreopen()

_ACRTIMP FILE *__cdecl _wfreopen ( const wchar_t path,
const wchar_t mode,
FILE file 
)

Definition at line 4578 of file file.c.

4579{
4580 int open_flags, stream_flags, fd;
4581
4582 TRACE(":path (%s) mode (%s) file (%p) fd (%d)\n", debugstr_w(path), debugstr_w(mode), file, file ? file->_file : -1);
4583
4584 LOCK_FILES();
4585 if (file)
4586 {
4587 fclose(file);
4588 if (msvcrt_get_flags(mode, &open_flags, &stream_flags) == -1)
4589 file = NULL;
4590 else if((fd = _wopen(path, open_flags, _S_IREAD | _S_IWRITE)) < 0)
4591 file = NULL;
4592 else if(msvcrt_init_fp(file, fd, stream_flags) == -1)
4593 {
4594 file->_flag = 0;
4595 file = NULL;
4596 }
4597 }
4598 UNLOCK_FILES();
4599 return file;
4600}
#define _S_IWRITE
Definition: stat.h:85
#define _S_IREAD
Definition: stat.h:84
int WINAPIV _wopen(const wchar_t *path, int flags,...)
Definition: file.c:2674
int CDECL fclose(FILE *file)
Definition: file.c:3757

Referenced by _wfreopen_s(), DllMain(), and freopen().

◆ _wfsopen()

_ACRTIMP FILE *__cdecl _wfsopen ( const wchar_t path,
const wchar_t mode,
int  share 
)

Definition at line 4254 of file file.c.

4255{
4256 FILE* file;
4257 int open_flags, stream_flags, fd;
4258
4259 TRACE("(%s,%s)\n", debugstr_w(path), debugstr_w(mode));
4260
4261 /* map mode string to open() flags. "man fopen" for possibilities. */
4262 if (msvcrt_get_flags(mode, &open_flags, &stream_flags) == -1)
4263 return NULL;
4264
4265 LOCK_FILES();
4266 fd = _wsopen(path, open_flags, share, _S_IREAD | _S_IWRITE);
4267 if (fd < 0)
4268 file = NULL;
4269 else if ((file = msvcrt_alloc_fp()) && msvcrt_init_fp(file, fd, stream_flags)
4270 != -1)
4271 TRACE(":fd (%d) mode (%s) FILE* (%p)\n", fd, debugstr_w(mode), file);
4272 else if (file)
4273 {
4274 file->_flag = 0;
4275 file = NULL;
4276 }
4277
4278 TRACE(":got (%p)\n",file);
4279 if (fd >= 0 && !file)
4280 _close(fd);
4281 UNLOCK_FILES();
4282 return file;
4283}
int CDECL _close(int fd)
Definition: file.c:1219
int WINAPIV _wsopen(const wchar_t *path, int oflags, int shflags,...)
Definition: file.c:2583

Referenced by _fsopen(), _wfopen(), LoadIniFile(), test_fopen(), and WriteIniFile().

◆ _wperror()

_ACRTIMP void __cdecl _wperror ( const wchar_t str)

Definition at line 354 of file errno.c.

355{
356 size_t size;
357 char *buffer = NULL;
358
359 if (str && *str)
360 {
361 size = wcstombs(NULL, str, 0);
362 if (size == -1) return;
363 size++;
364 buffer = malloc(size);
365 if (!buffer) return;
366 if (wcstombs(buffer, str, size) == -1)
367 {
368 free(buffer);
369 return;
370 }
371 }
372 perror(buffer);
373 free(buffer);
374}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
void CDECL perror(const char *str)
Definition: errno.c:337
GLsizeiptr size
Definition: glext.h:5919
wcstombs
Definition: stdlib.h:1013

◆ _wpopen()

_ACRTIMP FILE *__cdecl _wpopen ( const wchar_t command,
const wchar_t mode 
)

Definition at line 1044 of file process.c.

1045{
1046 wchar_t *comspec, *fullcmd, fullname[MAX_PATH];
1047 int textmode, fds[2], fd_parent, fd_child;
1048 struct popen_handle *container;
1051 const wchar_t *p;
1052 unsigned int len;
1053 STARTUPINFOW si;
1054 FILE *ret;
1055 DWORD i;
1056 BOOL r;
1057
1058 TRACE("(command=%s, mode=%s)\n", debugstr_w(command), debugstr_w(mode));
1059
1060 if (!command || !mode)
1061 return NULL;
1062
1066 for (p = mode; *p; p++)
1067 {
1068 switch (*p)
1069 {
1070 case 'W':
1071 case 'w':
1072 read_pipe = FALSE;
1073 break;
1074 case 'B':
1075 case 'b':
1077 textmode &= ~_O_TEXT;
1078 break;
1079 case 'T':
1080 case 't':
1081 textmode |= _O_TEXT;
1082 textmode &= ~_O_BINARY;
1083 break;
1084 }
1085 }
1086 if (_pipe(fds, 0, textmode) == -1)
1087 return NULL;
1088
1089 if (read_pipe)
1090 {
1091 fd_parent = fds[0];
1092 fd_child = _dup(fds[1]);
1093 _close(fds[1]);
1094 }
1095 else
1096 {
1097 fd_parent = fds[1];
1098 fd_child = _dup(fds[0]);
1099 _close(fds[0]);
1100 }
1101 if (fd_child == -1)
1102 {
1103 _close(fd_parent);
1104 return NULL;
1105 }
1106 ret = _wfdopen(fd_parent, mode);
1107 if (!ret)
1108 {
1109 _close(fd_child);
1110 return NULL;
1111 }
1112
1114 for (i = 0; i < popen_handles_size; i++)
1115 {
1116 if (!popen_handles[i].f)
1117 break;
1118 }
1119 if (i == popen_handles_size)
1120 {
1122 container = realloc(popen_handles, i * sizeof(*container));
1123 if (!container) goto error;
1124
1127 memset(container, 0, (i - popen_handles_size) * sizeof(*container));
1129 }
1130 else container = popen_handles + i;
1131
1132 if (!(comspec = msvcrt_get_comspec())) goto error;
1133 len = wcslen(comspec) + wcslen(command) + 5;
1134
1135 if (!(fullcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(wchar_t))))
1136 {
1137 HeapFree(GetProcessHeap(), 0, comspec);
1138 goto error;
1139 }
1140
1141 wcscpy(fullcmd, comspec);
1142 wcscat(fullcmd, L" /c ");
1143 wcscat(fullcmd, command);
1145
1146 memset(&si, 0, sizeof(si));
1147 si.cb = sizeof(si);
1149 if (read_pipe)
1150 {
1152 si.hStdOutput = (HANDLE)_get_osfhandle(fd_child);
1153 }
1154 else
1155 {
1156 si.hStdInput = (HANDLE)_get_osfhandle(fd_child);
1158 }
1160 r = CreateProcessW(fullname, fullcmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
1161 HeapFree(GetProcessHeap(), 0, comspec);
1162 HeapFree(GetProcessHeap(), 0, fullcmd);
1163 if (!r)
1164 {
1166 goto error;
1167 }
1168 CloseHandle(pi.hThread);
1169 _close(fd_child);
1170 container->proc = pi.hProcess;
1171 container->f = ret;
1173 return ret;
1174
1175error:
1177 _close(fd_child);
1178 fclose(ret);
1179 return NULL;
1180}
#define realloc
Definition: debug_ros.c:6
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define _O_BINARY
Definition: cabinet.h:51
#define _O_NOINHERIT
Definition: cabinet.h:45
#define _O_TEXT
Definition: cabinet.h:50
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4600
int CDECL _get_fmode(int *mode)
Definition: data.c:287
int CDECL _pipe(int *pfds, unsigned int psize, int textmode)
Definition: file.c:2323
int CDECL _dup(int od)
Definition: file.c:1317
intptr_t CDECL _get_osfhandle(int fd)
Definition: file.c:2117
textmode
Definition: file.c:95
FILE *CDECL _wfdopen(int fd, const wchar_t *mode)
Definition: file.c:1863
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
#define STDOUT_FILENO
Definition: stdio.h:25
#define STDERR_FILENO
Definition: stdio.h:26
#define STDIN_FILENO
Definition: stdio.h:24
void CDECL _lock(int locknum)
Definition: lock.c:85
void CDECL _unlock(int locknum)
Definition: lock.c:114
#define _POPEN_LOCK
Definition: mtdll.h:40
static void msvcrt_search_executable(const wchar_t *name, wchar_t *fullname, int use_path)
Definition: process.c:42
static DWORD popen_handles_size
Definition: process.c:1032
static wchar_t * msvcrt_get_comspec(void)
Definition: process.c:346
static struct popen_handle * popen_handles
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLfloat f
Definition: glext.h:7540
#define error(str)
Definition: mkdosfs.c:1605
const char * fullname
Definition: shader.c:1766
static refpint_t pi[]
Definition: server.c:112
LONG read_pipe(HANDLE hPipe, SOCKET sock)
Definition: pipetunnel.cpp:202
wcscat
wcscpy
#define msvcrt_set_errno
Definition: heap.c:50
#define memset(x, y, z)
Definition: compat.h:39
PVOID HANDLE
Definition: typedefs.h:73
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define STARTF_USESTDHANDLES
Definition: winbase.h:476

Referenced by _popen(), and wpopen().

◆ _wremove()

_ACRTIMP int __cdecl _wremove ( const wchar_t path)

Definition at line 4965 of file file.c.

4966{
4967 return _wunlink(path);
4968}
int CDECL _wunlink(const wchar_t *path)
Definition: file.c:1099

Referenced by _wunlink(), remove(), and START_TEST().

◆ _wtempnam()

_ACRTIMP wchar_t *__cdecl _wtempnam ( const wchar_t dir,
const wchar_t prefix 
)

Definition at line 3464 of file file.c.

3465{
3466 wchar_t tmpbuf[MAX_PATH];
3467 const wchar_t *tmp_dir = _wgetenv(L"TMP");
3468
3469 if (tmp_dir) dir = tmp_dir;
3470
3471 TRACE("dir (%s) prefix (%s)\n", debugstr_w(dir), debugstr_w(prefix));
3472 /* TODO: use whole prefix */
3473 if (GetTempFileNameW(dir,prefix,0,tmpbuf))
3474 {
3475 TRACE("got name (%s)\n", debugstr_w(tmpbuf));
3476 DeleteFileW(tmpbuf);
3477 return _wcsdup(tmpbuf);
3478 }
3479 TRACE("failed (%ld)\n", GetLastError());
3480 return NULL;
3481}
unsigned int dir
Definition: maze.c:112
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
wchar_t *CDECL _wgetenv(const wchar_t *name)
Definition: environ.c:254
_ACRTIMP wchar_t *__cdecl _wcsdup(const wchar_t *) __WINE_DEALLOC(free) __WINE_MALLOC
Definition: wcs.c:81
UINT WINAPI GetTempFileNameW(IN LPCWSTR lpPathName, IN LPCWSTR lpPrefixString, IN UINT uUnique, OUT LPWSTR lpTempFileName)
Definition: filename.c:84
Character const *const prefix
Definition: tempnam.cpp:195

Referenced by _tempnam().

◆ _wtmpnam()

_ACRTIMP wchar_t *__cdecl _wtmpnam ( wchar_t s)

Definition at line 5182 of file file.c.

5183{
5184 if (!s) {
5186
5187 if(!data->wtmpnam_buffer)
5188 data->wtmpnam_buffer = malloc(sizeof(wchar_t[MAX_PATH]));
5189
5190 s = data->wtmpnam_buffer;
5191 }
5192
5193 return wtmpnam_helper(s, -1, &tmpnam_unique, TMP_MAX) ? NULL : s;
5194}
static LONG tmpnam_unique
Definition: file.c:285
static int wtmpnam_helper(wchar_t *s, size_t size, LONG *tmpnam_unique, int tmp_max)
Definition: file.c:5122
#define TMP_MAX
Definition: stdio.h:35
thread_data_t *CDECL msvcrt_get_thread_data(void)
Definition: thread.c:45
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ fgetwc()

_ACRTIMP wint_t __cdecl fgetwc ( FILE file)

Definition at line 3935 of file file.c.

3936{
3937 wint_t ret;
3938
3942
3943 return ret;
3944}

Referenced by _fgetwchar(), _getws(), fgetws(), getwc(), test_fgetwc_locale(), and test_fgetwc_unicode().

◆ fgetws()

_ACRTIMP wchar_t *__cdecl fgetws ( wchar_t s,
int  size,
FILE file 
)

Definition at line 4043 of file file.c.

4044{
4045 wint_t cc = WEOF;
4046 wchar_t * buf_start = s;
4047
4048 TRACE(":file(%p) fd (%d) str (%p) len (%d)\n",
4049 file,file->_file,s,size);
4050
4052
4053 while ((size >1) && (cc = _fgetwc_nolock(file)) != WEOF && cc != '\n')
4054 {
4055 *s++ = cc;
4056 size --;
4057 }
4058 if ((cc == WEOF) && (s == buf_start)) /* If nothing read, return 0*/
4059 {
4060 TRACE(":nothing read\n");
4062 return NULL;
4063 }
4064 if ((cc != WEOF) && (size > 1))
4065 *s++ = cc;
4066 *s = 0;
4067 TRACE(":got %s\n", debugstr_w(buf_start));
4069 return buf_start;
4070}

Referenced by DosBIOSInitialize(), FindString(), InterpretInteractive(), InterpretMain(), LoadBootIni(), LoadIniFile(), LoadSystemIni(), ReadFromFile(), RunScript(), test_fgetwc(), test_file_put_get(), test_fileops(), test_fwprintf(), wmain(), and XCOPY_ProcessExcludeFile().

◆ fputwc()

_ACRTIMP wint_t __cdecl fputwc ( wint_t  wc,
FILE file 
)

Definition at line 4203 of file file.c.

4204{
4205 wint_t ret;
4206
4208 ret = _fputwc_nolock(wc, file);
4210
4211 return ret;
4212}

Referenced by _fputwchar(), _putwch(), ConWrite(), fputws(), putwc(), test_fgetwc(), test_fgetwc_unicode(), and test_fputwc().

◆ fputws()

_ACRTIMP int __cdecl fputws ( const wchar_t s,
FILE file 
)

Definition at line 4783 of file file.c.

4784{
4785 size_t i, len = wcslen(s);
4786 BOOL tmp_buf;
4787 int ret;
4788
4790 if (!(get_ioinfo_nolock(file->_file)->wxflag & WX_TEXT)) {
4791 ret = _fwrite_nolock(s,sizeof(*s),len,file) == len ? 0 : EOF;
4793 return ret;
4794 }
4795
4796 tmp_buf = add_std_buffer(file);
4797 for (i=0; i<len; i++) {
4798 if(_fputwc_nolock(s[i], file) == WEOF) {
4799 if(tmp_buf) remove_std_buffer(file);
4801 return WEOF;
4802 }
4803 }
4804
4805 if(tmp_buf) remove_std_buffer(file);
4807 return 0;
4808}
static void remove_std_buffer(FILE *file)
Definition: file.c:910
static BOOL add_std_buffer(FILE *file)
Definition: file.c:893

Referenced by _putws(), ConPuts(), ConResPuts(), test_fgetwc(), and WriteIniFile().

◆ fwprintf()

_ACRTIMP int __cdecl fwprintf ( FILE file,
const wchar_t format,
  ... 
)

Definition at line 5628 of file file.c.

5629{
5631 int res;
5634 va_end(valist);
5635 return res;
5636}
int CDECL vfwprintf(FILE *file, const wchar_t *format, va_list valist)
Definition: file.c:5365
GLuint res
Definition: glext.h:9613

Referenced by _wassert(), _wperror(), ConWrite(), CreatePerfWindows(), ProcessCommandLine(), test_fprintf(), and wWinMain().

◆ fwprintf_s()

_ACRTIMP int __cdecl fwprintf_s ( FILE file,
const wchar_t format,
  ... 
)

Definition at line 5641 of file file.c.

5642{
5644 int res;
5647 va_end(valist);
5648 return res;
5649}
int CDECL vfwprintf_s(FILE *file, const wchar_t *format, va_list valist)
Definition: file.c:5373

◆ fwscanf()

_ACRTIMP int __cdecl fwscanf ( FILE file,
const wchar_t format,
  ... 
)

Definition at line 264 of file scanf.c.

265{
267 int res;
268
270 res = vfwscanf_l(file, format, NULL, valist);
271 va_end(valist);
272 return res;
273}

◆ fwscanf_s()

_ACRTIMP int __cdecl fwscanf_s ( FILE file,
const wchar_t format,
  ... 
)

Definition at line 293 of file scanf.c.

294{
296 int res;
297
299 res = vfwscanf_s_l(file, format, NULL, valist);
300 va_end(valist);
301 return res;
302}

◆ getwc()

_ACRTIMP wint_t __cdecl getwc ( FILE file)

Definition at line 4019 of file file.c.

4020{
4021 return fgetwc(file);
4022}

◆ getwchar()

_ACRTIMP wint_t __cdecl getwchar ( void  )

Definition at line 4035 of file file.c.

4036{
4037 return _fgetwchar();
4038}
wint_t CDECL _fgetwchar(void)
Definition: file.c:4027

◆ getws()

_ACRTIMP wchar_t *__cdecl getws ( wchar_t )

◆ putwc()

_ACRTIMP wint_t __cdecl putwc ( wint_t  c,
FILE stream 
)

Definition at line 127 of file fputwc.cpp.

128{
129 return fputwc(c, stream);
130}
wint_t __cdecl fputwc(wchar_t const c, FILE *const stream)
Definition: fputwc.cpp:118

◆ putwchar()

_ACRTIMP wint_t __cdecl putwchar ( wint_t  c)

Definition at line 143 of file fputwc.cpp.

144{
145 return _fputwchar(c);
146}
wint_t __cdecl _fputwchar(wchar_t const c)
Definition: fputwc.cpp:135

◆ putws()

_ACRTIMP int __cdecl putws ( const wchar_t )

◆ swprintf()

static int __cdecl swprintf ( wchar_t buffer,
size_t  size,
const wchar_t format,
  ... 
)
inlinestatic

Definition at line 387 of file corecrt_wstdio.h.

388{
389 int ret;
391
394 va_end(args);
395 return ret;
396}
#define args
Definition: format.c:66

◆ swprintf_s()

_ACRTIMP int __cdecl swprintf_s ( wchar_t str,
size_t  numberOfElements,
const wchar_t format,
  ... 
)

Definition at line 1701 of file wcs.c.

1703{
1704 va_list ap;
1705 int r;
1706
1707 va_start(ap, format);
1709 va_end(ap);
1710
1711 return r;
1712}
int CDECL _vsnwprintf_s(wchar_t *str, size_t sizeOfBuffer, size_t count, const wchar_t *format, va_list valist)
Definition: wcs.c:1483
static size_t numberOfElements
Definition: string.c:98

Referenced by tirpc_report().

◆ swscanf()

◆ swscanf_s()

_ACRTIMP int __cdecl swscanf_s ( const wchar_t str,
const wchar_t format,
  ... 
)

Definition at line 467 of file scanf.c.

468{
470 int res;
471
473 res = vswscanf_s_l(str, format, NULL, valist);
474 va_end(valist);
475 return res;
476}

◆ ungetwc()

_ACRTIMP wint_t __cdecl ungetwc ( wint_t  wc,
FILE file 
)

Definition at line 5783 of file file.c.

5784{
5785 wint_t ret;
5786
5787 if(!MSVCRT_CHECK_PMT(file != NULL)) return WEOF;
5788
5790 ret = _ungetwc_nolock(wc, file);
5792
5793 return ret;
5794}
wint_t CDECL _ungetwc_nolock(wint_t wc, FILE *file)
Definition: file.c:5799

◆ vfwprintf()

_ACRTIMP int __cdecl vfwprintf ( FILE file,
const wchar_t format,
va_list  valist 
)

Definition at line 5365 of file file.c.

5366{
5367 return vfwprintf_helper(0, file, format, NULL, valist);
5368}
static int vfwprintf_helper(DWORD options, FILE *file, const wchar_t *format, _locale_t locale, va_list valist)
Definition: file.c:5296

Referenced by _vcwprintf(), ConPrintf(), ConResPrintf(), fwprintf(), and vwprintf().

◆ vfwprintf_s()

_ACRTIMP int __cdecl vfwprintf_s ( FILE file,
const wchar_t format,
va_list  valist 
)

Definition at line 5373 of file file.c.

5374{
5376}
int CDECL _vfwprintf_s_l(FILE *file, const wchar_t *format, _locale_t locale, va_list valist)
Definition: file.c:5340

Referenced by fwprintf_s(), and vwprintf_s().

◆ vswprintf()

static int __cdecl vswprintf ( wchar_t buffer,
size_t  size,
const wchar_t format,
va_list  args 
)
inlinestatic

◆ vswprintf_s()

_ACRTIMP int __cdecl vswprintf_s ( wchar_t str,
size_t  numberOfElements,
const wchar_t format,
va_list  args 
)

Definition at line 1816 of file wcs.c.

1818{
1820}

◆ vwprintf()

_ACRTIMP int __cdecl vwprintf ( const wchar_t format,
va_list  valist 
)

Definition at line 5533 of file file.c.

5534{
5535 return vfwprintf(stdout,format,valist);
5536}

Referenced by LoadAndPrintString(), and wprintf().

◆ vwprintf_s()

_ACRTIMP int __cdecl vwprintf_s ( const wchar_t format,
va_list  valist 
)

Definition at line 5541 of file file.c.

5542{
5544}

Referenced by wprintf_s().

◆ wprintf()

_ACRTIMP int __cdecl wprintf ( const wchar_t format,
  ... 
)

Definition at line 5836 of file file.c.

5837{
5839 int res;
5842 va_end(valist);
5843 return res;
5844}
int CDECL vwprintf(const wchar_t *format, va_list valist)
Definition: file.c:5533

◆ wprintf_s()

_ACRTIMP int __cdecl wprintf_s ( const wchar_t format,
  ... 
)

Definition at line 5849 of file file.c.

5850{
5852 int res;
5855 va_end(valist);
5856 return res;
5857}
int CDECL vwprintf_s(const wchar_t *format, va_list valist)
Definition: file.c:5541

◆ wscanf()

_ACRTIMP int __cdecl wscanf ( const wchar_t format,
  ... 
)

Definition at line 322 of file scanf.c.

323{
325 int res;
326
328 res = vfwscanf_l(stdin, format, NULL, valist);
329 va_end(valist);
330 return res;
331}

Referenced by wmain().

◆ wscanf_s()

_ACRTIMP int __cdecl wscanf_s ( const wchar_t format,
  ... 
)

Definition at line 351 of file scanf.c.

352{
354 int res;
355
357 res = vfwscanf_s_l(stdin, format, NULL, valist);
358 va_end(valist);
359 return res;
360}