ReactOS 0.4.16-dev-959-g2ec3a19
fdopen.cpp File Reference
Include dependency graph for fdopen.cpp:

Go to the source code of this file.

Functions

template<typename Character >
static FILE *__cdecl common_fdopen (int const fh, Character const *const mode) throw ()
 
FILE *__cdecl _fdopen (int const fh, char const *const mode)
 
FILE *__cdecl _wfdopen (int const fh, wchar_t const *const mode)
 

Function Documentation

◆ _fdopen()

FILE *__cdecl _fdopen ( int const  fh,
char const *const  mode 
)

Definition at line 63 of file fdopen.cpp.

64{
65 return common_fdopen(fh, mode);
66}
static FILE *__cdecl common_fdopen(int const fh, Character const *const mode)
Definition: fdopen.cpp:20
GLenum mode
Definition: glext.h:6217

◆ _wfdopen()

FILE *__cdecl _wfdopen ( int const  fh,
wchar_t const *const  mode 
)

Definition at line 68 of file fdopen.cpp.

69{
70 return common_fdopen(fh, mode);
71}

◆ common_fdopen()

template<typename Character >
static FILE *__cdecl common_fdopen ( int const  fh,
Character const *const  mode 
)
throw (
)
static

Definition at line 20 of file fdopen.cpp.

24{
25 _VALIDATE_RETURN(mode != nullptr, EINVAL, nullptr);
26
27 _CHECK_FH_RETURN(fh, EBADF, nullptr);
28 _VALIDATE_RETURN(fh >= 0 && (unsigned)fh < (unsigned)_nhandle, EBADF, nullptr);
29 _VALIDATE_RETURN(_osfile(fh) & FOPEN, EBADF, nullptr);
30
32 if (!parsed_mode._success)
33 return nullptr;
34
36 if (!stream.valid())
37 {
38 errno = EMFILE;
39 return nullptr;
40 }
41
42 __try
43 {
44 // Ensure that streams get flushed during pre-termination:
45 #ifndef CRTDLL
46 ++_cflush;
47 #endif
48
49 stream.set_flags(parsed_mode._stdio_mode);
50 stream->_file = fh;
51 }
53 {
54 stream.unlock();
55 }
57
58 return stream.public_stream();
59}
int _cflush
Definition: _file.cpp:53
#define EINVAL
Definition: acclib.h:90
#define EBADF
Definition: acclib.h:82
#define _CHECK_FH_RETURN(handle, errorcode, retexpr)
int _nhandle
Definition: ioinit.cpp:34
__acrt_stdio_stream_mode __cdecl __acrt_stdio_parse_mode(Character const *const mode)
__crt_stdio_stream __cdecl __acrt_stdio_allocate_stream()
Definition: stream.cpp:71
#define _VALIDATE_RETURN(expr, errorcode, retexpr)
#define EMFILE
Definition: errno.h:30
#define FOPEN
#define __try
Definition: pseh2_64.h:188
#define __endtry
Definition: pseh2_64.h:191
#define __finally
Definition: pseh2_64.h:190
#define errno
Definition: errno.h:18
#define _osfile(i)
Definition: internal.h:72
Definition: parse.h:23

Referenced by _fdopen(), and _wfdopen().