ReactOS 0.4.16-dev-1019-g2c2cdfd
_file.cpp File Reference
Include dependency graph for _file.cpp:

Go to the source code of this file.

Functions

FILE *__cdecl __acrt_iob_func (unsigned const id)
 
 _CRT_LINKER_FORCE_INCLUDE (__acrt_stdio_initializer)
 
 _CRT_LINKER_FORCE_INCLUDE (__acrt_stdio_terminator)
 
int __cdecl __acrt_initialize_stdio ()
 
void __cdecl __acrt_uninitialize_stdio ()
 
void __cdecl _lock_file (FILE *const stream)
 
void __cdecl _unlock_file (FILE *const stream)
 
errno_t __cdecl _get_stream_buffer_pointers (FILE *const public_stream, char ***const base, char ***const ptr, int **const count)
 

Variables

__crt_stdio_stream_data _iob [_IOB_ENTRIES]
 
__crt_stdio_stream_data ** __piob
 
int _nstream
 
int _cflush = 0
 

Function Documentation

◆ __acrt_initialize_stdio()

int __cdecl __acrt_initialize_stdio ( )

Definition at line 59 of file _file.cpp.

60{
61 #ifndef CRTDLL
62 // If the user has not supplied a definition of _nstream, set it to _NSTREAM_.
63 // If the user has supplied a value that is too small, set _nstream to the
64 // minimum acceptable value (_IOB_ENTRIES):
65 if (_nstream == 0)
66 {
68 }
69 else if (_nstream < _IOB_ENTRIES)
70 {
72 }
73 #endif
74
75 // Allocate the __piob array. Try for _nstream entries first. If this
76 // fails, then reset _nstream to _IOB_ENTRIES an try again. If it still
77 // fails, bail out and cause CRT initialization to fail:
78 __piob = _calloc_crt_t(__crt_stdio_stream_data*, _nstream).detach();
79 if (!__piob)
80 {
82
83 __piob = _calloc_crt_t(__crt_stdio_stream_data*, _nstream).detach();
84 if (!__piob)
85 {
86 return -1;
87 }
88 }
89
90 // Initialize the first _IOB_ENTRIES to point to the corresponding entries
91 // in _iob[]:
92 for (int i = 0; i != _IOB_ENTRIES; ++i)
93 {
95 __piob[i] = &_iob[i];
96
97 // For stdin, stdout, and stderr, we use _NO_CONSOLE_FILENO to allow
98 // callers to distinguish between failure to open a file (-1) and a
99 // program run without a console.
100 intptr_t const os_handle = _osfhnd(i);
101 bool const has_no_console =
102 os_handle == reinterpret_cast<intptr_t>(INVALID_HANDLE_VALUE) ||
103 os_handle == _NO_CONSOLE_FILENO ||
104 os_handle == 0;
105
106 if (has_no_console)
107 {
109 }
110 }
111
112 return 0;
113}
__crt_stdio_stream_data _iob[_IOB_ENTRIES]
Definition: _file.cpp:14
int _nstream
Definition: _file.cpp:38
__crt_stdio_stream_data ** __piob
Definition: _file.cpp:30
#define _CORECRT_SPINCOUNT
BOOL WINAPI __acrt_InitializeCriticalSectionEx(_Out_ LPCRITICAL_SECTION critical_section, _In_ DWORD spin_count, _In_ DWORD flags)
#define _osfhnd(i)
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
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
#define _IOB_ENTRIES
Definition: stdio.h:23
#define _NSTREAM_
Definition: stdio.h:22
#define _NO_CONSOLE_FILENO
Definition: internal.h:92
void _lock(int locknum)
Definition: lock.c:97
int intptr_t
Definition: vcruntime.h:134

◆ __acrt_iob_func()

FILE *__cdecl __acrt_iob_func ( unsigned const  id)

Definition at line 22 of file _file.cpp.

23{
24 return &_iob[id]._public_file;
25}
GLuint id
Definition: glext.h:5910

◆ __acrt_uninitialize_stdio()

void __cdecl __acrt_uninitialize_stdio ( )

Definition at line 120 of file _file.cpp.

121{
122 _flushall();
123 _fcloseall();
124
125 for (int i = 0; i != _IOB_ENTRIES; ++i)
126 {
129 }
130
132 __piob = nullptr;
133}
void __cdecl __acrt_stdio_free_buffer_nolock(FILE *const public_stream)
Definition: _freebuf.cpp:15
_Check_return_opt_ _CRTIMP int __cdecl _fcloseall(void)
Definition: file.c:1081
_Check_return_opt_ _CRTIMP int __cdecl _flushall(void)
Definition: file.c:893
#define _free_crt
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

◆ _CRT_LINKER_FORCE_INCLUDE() [1/2]

_CRT_LINKER_FORCE_INCLUDE ( __acrt_stdio_initializer  )

◆ _CRT_LINKER_FORCE_INCLUDE() [2/2]

_CRT_LINKER_FORCE_INCLUDE ( __acrt_stdio_terminator  )

◆ _get_stream_buffer_pointers()

errno_t __cdecl _get_stream_buffer_pointers ( FILE *const  public_stream,
char ***const  base,
char ***const  ptr,
int **const  count 
)

Definition at line 153 of file _file.cpp.

159{
160 _VALIDATE_RETURN_ERRCODE(public_stream != nullptr, EINVAL);
161
162 __crt_stdio_stream const stream(public_stream);
163 if (base)
164 {
165 *base = &stream->_base;
166 }
167
168 if (ptr)
169 {
170 *ptr = &stream->_ptr;
171 }
172
173 if (count)
174 {
175 *count = &stream->_cnt;
176 }
177
178 return 0;
179}
#define EINVAL
Definition: acclib.h:90
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
static PVOID ptr
Definition: dispmode.c:27
Definition: parse.h:23

Referenced by test_iobuf_layout().

◆ _lock_file()

void __cdecl _lock_file ( FILE *const  stream)

Definition at line 138 of file _file.cpp.

139{
141}
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

◆ _unlock_file()

void __cdecl _unlock_file ( FILE *const  stream)

Definition at line 146 of file _file.cpp.

147{
149}
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Variable Documentation

◆ __piob

Definition at line 30 of file _file.cpp.

Referenced by __acrt_initialize_stdio(), and __acrt_uninitialize_stdio().

◆ _cflush

◆ _iob

Initial value:
=
{
{ nullptr, nullptr, 0, _IOALLOCATED | _IOREAD, 0, 0, 0},
{ nullptr, nullptr, 0, _IOALLOCATED | _IOWRITE, 1, 0, 0},
{ nullptr, nullptr, 0, _IOALLOCATED | _IOWRITE, 2, 0, 0},
}
#define _IOREAD
Definition: stdio.h:124

Definition at line 14 of file _file.cpp.

Referenced by __acrt_initialize_stdio(), and __acrt_iob_func().

◆ _nstream

int _nstream

Definition at line 38 of file _file.cpp.

Referenced by __acrt_initialize_stdio().