ReactOS 0.4.16-dev-959-g2ec3a19
strerror.cpp File Reference
#include <corecrt_internal.h>
#include <malloc.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for strerror.cpp:

Go to the source code of this file.

Functions

static _Ret_z_ charget_failure_string (char) throw ()
 
static _Ret_z_ wchar_tget_failure_string (wchar_t) throw ()
 
static char *& get_ptd_buffer (__acrt_ptd *const ptd, char) throw ()
 
static wchar_t *& get_ptd_buffer (__acrt_ptd *const ptd, wchar_t) throw ()
 
 _Success_ (return==0) static errno_t copy_string_into_buffer(_In_reads_or_z_(max_count) char const *const string
 
 _Out_writes_z_ (buffer_count) char *const buffer
 
size_t const size_t const max_count throw ()
 
template<typename Character >
static _Ret_z_ Character *__cdecl common_strerror (int const error_number)
 
char *__cdecl strerror (int const error_number)
 
wchar_t *__cdecl _wcserror (int const error_number)
 
template<typename Character >
static errno_t __cdecl common_strerror_s (_Out_writes_z_(buffer_count) Character *const buffer, size_t const buffer_count, int const error_number)
 
errno_t __cdecl strerror_s (char *const buffer, size_t const buffer_count, int const error_number)
 
errno_t __cdecl _wcserror_s (wchar_t *const buffer, size_t const buffer_count, int const error_number)
 

Variables

size_t const buffer_count
 

Function Documentation

◆ _Out_writes_z_()

_Out_writes_z_ ( buffer_count  ) const

◆ _Success_()

_Success_ ( return  = = 0) const

◆ _wcserror()

wchar_t *__cdecl _wcserror ( int const  error_number)

Definition at line 101 of file strerror.cpp.

102{
103 return common_strerror<wchar_t>(error_number);
104}

◆ _wcserror_s()

errno_t __cdecl _wcserror_s ( wchar_t *const  buffer,
size_t const  buffer_count,
int const  error_number 
)

Definition at line 139 of file strerror.cpp.

144{
145 return common_strerror_s(buffer, buffer_count, error_number);
146}
GLuint buffer
Definition: glext.h:5915
size_t const buffer_count
Definition: strerror.cpp:54
static errno_t __cdecl common_strerror_s(_Out_writes_z_(buffer_count) Character *const buffer, size_t const buffer_count, int const error_number)
Definition: strerror.cpp:112

◆ common_strerror()

template<typename Character >
static _Ret_z_ Character *__cdecl common_strerror ( int const  error_number)
static

Definition at line 79 of file strerror.cpp.

80{
82 if (!ptd)
83 return get_failure_string(Character());
84
85 Character*& buffer = get_ptd_buffer(ptd, Character());
86 if (!buffer)
87 buffer = _calloc_crt_t(Character, strerror_buffer_count).detach();
88
89 if (!buffer)
90 return get_failure_string(Character());
91
92 _ERRCHECK(copy_string_into_buffer(_get_sys_err_msg(error_number), buffer, strerror_buffer_count, strerror_buffer_count - 1));
93 return buffer;
94}
_Ret_z_ __inline char const * _get_sys_err_msg(size_t const m)
#define _ERRCHECK(e)
__acrt_ptd *__cdecl __acrt_getptd_noexit(void)
_In_ size_t const _In_ int _In_ bool const _In_ unsigned const _In_ __acrt_rounding_mode const _Inout_ __crt_cached_ptd_host & ptd
Definition: cvt.cpp:355
static _Ret_z_ char * get_failure_string(char)
Definition: strerror.cpp:22
static char *& get_ptd_buffer(__acrt_ptd *const ptd, char)
Definition: strerror.cpp:37

Referenced by __wcserror(), and _strerror().

◆ common_strerror_s()

template<typename Character >
static errno_t __cdecl common_strerror_s ( _Out_writes_z_(buffer_count) Character *const  buffer,
size_t const  buffer_count,
int const  error_number 
)
static

Definition at line 112 of file strerror.cpp.

117{
120
121 errno_t const result = _ERRCHECK_EINVAL_ERANGE(copy_string_into_buffer(
122 _get_sys_err_msg(error_number),
123 buffer,
125 _TRUNCATE));
126
127 return result == STRUNCATE ? 0 : result;
128}
#define EINVAL
Definition: acclib.h:90
#define _ERRCHECK_EINVAL_ERANGE(e)
GLuint64EXT * result
Definition: glext.h:11304
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
#define STRUNCATE
Definition: errno.h:110
int errno_t
Definition: corecrt.h:615
#define _TRUNCATE
Definition: corecrt.h:278

Referenced by _wcserror_s(), and strerror_s().

◆ get_failure_string() [1/2]

static _Ret_z_ char * get_failure_string ( char  )
throw (
)
static

Definition at line 22 of file strerror.cpp.

23{
24 return const_cast<char*>("Visual C++ CRT: Not enough memory to complete call to strerror.");
25}

Referenced by common_strerror().

◆ get_failure_string() [2/2]

static _Ret_z_ wchar_t * get_failure_string ( wchar_t  )
throw (
)
static

Definition at line 28 of file strerror.cpp.

29{
30 return const_cast<wchar_t*>(L"Visual C++ CRT: Not enough memory to complete call to strerror.");
31}
#define L(x)
Definition: ntvdm.h:50

◆ get_ptd_buffer() [1/2]

static char *& get_ptd_buffer ( __acrt_ptd *const  ptd,
char   
)
throw (
)
static

Definition at line 37 of file strerror.cpp.

38{
39 return ptd->_strerror_buffer;
40}

Referenced by common_strerror().

◆ get_ptd_buffer() [2/2]

static wchar_t *& get_ptd_buffer ( __acrt_ptd *const  ptd,
wchar_t   
)
throw (
)
static

Definition at line 42 of file strerror.cpp.

43{
44 return ptd->_wcserror_buffer;
45}

◆ strerror()

◆ strerror_s()

errno_t __cdecl strerror_s ( char *const  buffer,
size_t const  buffer_count,
int const  error_number 
)

Definition at line 130 of file strerror.cpp.

135{
136 return common_strerror_s(buffer, buffer_count, error_number);
137}

◆ throw()

Definition at line 56 of file strerror.cpp.

57{
58 return strncpy_s(buffer, buffer_count, string, max_count);
59}
Character const *const size_t const max_count
Definition: fullpath.cpp:66
strncpy_s
Definition: string.h:335

Variable Documentation

◆ buffer_count

size_t const buffer_count

Definition at line 54 of file strerror.cpp.

Referenced by _wcserror_s(), common_strerror_s(), strerror_s(), and throw().