ReactOS 0.4.15-dev-8339-g4028de8
strerror.c File Reference
#include <precomp.h>
Include dependency graph for strerror.c:

Go to the source code of this file.

Functions

char *CDECL strerror (int err)
 
int CDECL strerror_s (char *buffer, size_t numberOfElements, int errnum)
 
char *CDECL _strerror (const char *str)
 
void CDECL perror (const char *str)
 
int CDECL _wcserror_s (wchar_t *buffer, size_t nc, int err)
 
wchar_t *CDECL _wcserror (int err)
 
int CDECL __wcserror_s (wchar_t *buffer, size_t nc, const wchar_t *str)
 
wchar_t *CDECL __wcserror (const wchar_t *str)
 

Variables

char __syserr00 [] = "No Error"
 
char __syserr01 [] = "Operation not permitted (EPERM)"
 
char __syserr02 [] = "No such file or directory (ENOENT)"
 
char __syserr03 [] = "No such process (ESRCH)"
 
char __syserr04 [] = "Interrupted system call (EINTR)"
 
char __syserr05 [] = "Input or output error (EIO)"
 
char __syserr06 [] = "No such device or address (ENXIO)"
 
char __syserr07 [] = "Argument list too long (E2BIG)"
 
char __syserr08 [] = "Unable to execute file (ENOEXEC)"
 
char __syserr09 [] = "Bad file descriptor (EBADF)"
 
char __syserr10 [] = "No child processes (ECHILD)"
 
char __syserr11 [] = "Resource temporarily unavailable (EAGAIN)"
 
char __syserr12 [] = "Not enough memory (ENOMEM)"
 
char __syserr13 [] = "Permission denied (EACCES)"
 
char __syserr14 [] = "Bad address (EFAULT)"
 
char __syserr15 [] = "Unknown Error: 15"
 
char __syserr16 [] = "Resource busy (EBUSY)"
 
char __syserr17 [] = "File exists (EEXIST)"
 
char __syserr18 [] = "Improper link (EXDEV)"
 
char __syserr19 [] = "No such device (ENODEV)"
 
char __syserr20 [] = "Not a directory (ENOTDIR)"
 
char __syserr21 [] = "Is a directory (EISDIR)"
 
char __syserr22 [] = "Invalid argument (EINVAL)"
 
char __syserr23 [] = "Too many open files in system (ENFILE)"
 
char __syserr24 [] = "Too many open files (EMFILE)"
 
char __syserr25 [] = "Inappropriate I/O control operation (ENOTTY)"
 
char __syserr26 [] = "Unknown error: 26"
 
char __syserr27 [] = "File too large (EFBIG)"
 
char __syserr28 [] = "No space left on drive (ENOSPC)"
 
char __syserr29 [] = "Invalid seek (ESPIPE)"
 
char __syserr30 [] = "Read-only file system (EROFS)"
 
char __syserr31 [] = "Too many links (EMLINK)"
 
char __syserr32 [] = "Broken pipe (EPIPE)"
 
char __syserr33 [] = "Input to function out of range (EDOM)"
 
char __syserr34 [] = "Output of function out of range (ERANGE)"
 
char __syserr35 [] = "Unknown error: 35"
 
char __syserr36 [] = "Resource deadlock avoided (EDEADLK)"
 
char __syserr37 [] = "Unknown error: 37"
 
char __syserr38 [] = "File name too long (ENAMETOOLONG)"
 
char __syserr39 [] = "No locks available (ENOLCK)"
 
char __syserr40 [] = "Function not implemented (ENOSYS)"
 
char __syserr41 [] = "Directory not empty (ENOTEMPTY)"
 
char __syserr42 [] = "Illegal byte sequence (EILSEQ)"
 
char __syserr43 [] = "Unknown/generic error"
 
char_sys_errlist []
 
int _sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]) - 1
 

Function Documentation

◆ __wcserror()

wchar_t *CDECL __wcserror ( const wchar_t str)

Definition at line 227 of file strerror.c.

228{
230 int err;
231
232 if (!data->wcserror_buffer)
233 if (!(data->wcserror_buffer = malloc(256 * sizeof(wchar_t)))) return NULL;
234
235 err = __wcserror_s(data->wcserror_buffer, 256, str);
236 if (err) FIXME("bad wcserror call (%d)\n", err);
237
238 return data->wcserror_buffer;
239}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
thread_data_t * msvcrt_get_thread_data(void)
Definition: tls.c:31
#define err(...)
const WCHAR * str
int CDECL __wcserror_s(wchar_t *buffer, size_t nc, const wchar_t *str)
Definition: strerror.c:194

◆ __wcserror_s()

int CDECL __wcserror_s ( wchar_t buffer,
size_t  nc,
const wchar_t str 
)

Definition at line 194 of file strerror.c.

195{
196 int err;
197 static const WCHAR colonW[] = {':', ' ', '\0'};
198 static const WCHAR nlW[] = {'\n', '\0'};
199 size_t len;
200
201 err = *_errno();
202 if (err < 0 || err > _sys_nerr) err = _sys_nerr;
203
204 len = MultiByteToWideChar(CP_ACP, 0, _sys_errlist[err], -1, NULL, 0) + 1 /* \n */;
205 if (str && *str) len += lstrlenW(str) + 2 /* ': ' */;
206 if (len > nc)
207 {
208 MSVCRT_INVALID_PMT("buffer[nc] is too small", ERANGE);
209 return ERANGE;
210 }
211 if (str && *str)
212 {
214 lstrcatW(buffer, colonW);
215 }
216 else buffer[0] = '\0';
219 lstrcatW(buffer, nlW);
220
221 return 0;
222}
#define ERANGE
Definition: acclib.h:92
#define CP_ACP
Definition: compat.h:109
#define lstrcpyW
Definition: compat.h:749
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
#define MSVCRT_INVALID_PMT(x)
Definition: mbstowcs_s.c:25
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:17
int _sys_nerr
Definition: strerror.c:80
char * _sys_errlist[]
Definition: strerror.c:68
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by __wcserror().

◆ _strerror()

char *CDECL _strerror ( const char str)

Definition at line 127 of file strerror.c.

128{
130 int err;
131
132 if (!data->strerror_buffer)
133 if (!(data->strerror_buffer = malloc(256))) return NULL;
134
135 err = data->thread_errno;
136 if (err < 0 || err > _sys_nerr) err = _sys_nerr;
137
138 if (str && *str)
139 sprintf( data->strerror_buffer, "%s: %s\n", str, _sys_errlist[err] );
140 else
141 sprintf( data->strerror_buffer, "%s\n", _sys_errlist[err] );
142
143 return data->strerror_buffer;
144}
#define sprintf(buf, format,...)
Definition: sprintf.c:55

◆ _wcserror()

wchar_t *CDECL _wcserror ( int  err)

Definition at line 181 of file strerror.c.

182{
184
185 if (!data->wcserror_buffer)
186 if (!(data->wcserror_buffer = malloc(256 * sizeof(wchar_t)))) return NULL;
187 _wcserror_s(data->wcserror_buffer, 256, err);
188 return data->wcserror_buffer;
189}
int CDECL _wcserror_s(wchar_t *buffer, size_t nc, int err)
Definition: strerror.c:166

◆ _wcserror_s()

int CDECL _wcserror_s ( wchar_t buffer,
size_t  nc,
int  err 
)

Definition at line 166 of file strerror.c.

167{
168 if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(nc > 0))
169 {
171 return EINVAL;
172 }
173 if (err < 0 || err > _sys_nerr) err = _sys_nerr;
175 return 0;
176}
#define EINVAL
Definition: acclib.h:90
#define MSVCRT_CHECK_PMT(x)
Definition: mbstowcs_s.c:26
errno_t __cdecl _set_errno(_In_ int _Value)

Referenced by _wcserror().

◆ perror()

void CDECL perror ( const char str)

Definition at line 149 of file strerror.c.

150{
151 int err = *_errno();
152 if (err < 0 || err > _sys_nerr) err = _sys_nerr;
153
154 if (str && *str)
155 {
156 _write( 2, str, strlen(str) );
157 _write( 2, ": ", 2 );
158 }
160 _write( 2, "\n", 1 );
161}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
_CRTIMP int __cdecl _write(_In_ int _FileHandle, _In_reads_bytes_(_MaxCharCount) const void *_Buf, _In_ unsigned int _MaxCharCount)

◆ strerror()

◆ strerror_s()

int CDECL strerror_s ( char buffer,
size_t  numberOfElements,
int  errnum 
)

Definition at line 100 of file strerror.c.

101{
102 char *ptr;
103
104 if (!buffer || !numberOfElements)
105 {
106 *_errno() = EINVAL;
107 return EINVAL;
108 }
109
110 if (errnum < 0 || errnum > _sys_nerr)
111 errnum = _sys_nerr;
112
113 ptr = _sys_errlist[errnum];
114 while (*ptr && numberOfElements > 1)
115 {
116 *buffer++ = *ptr++;
118 }
119
120 *buffer = '\0';
121 return 0;
122}
static PVOID ptr
Definition: dispmode.c:27
static size_t numberOfElements
Definition: string.c:87

Variable Documentation

◆ __syserr00

char __syserr00[] = "No Error"

Definition at line 23 of file strerror.c.

◆ __syserr01

char __syserr01[] = "Operation not permitted (EPERM)"

Definition at line 24 of file strerror.c.

◆ __syserr02

char __syserr02[] = "No such file or directory (ENOENT)"

Definition at line 25 of file strerror.c.

◆ __syserr03

char __syserr03[] = "No such process (ESRCH)"

Definition at line 26 of file strerror.c.

◆ __syserr04

char __syserr04[] = "Interrupted system call (EINTR)"

Definition at line 27 of file strerror.c.

◆ __syserr05

char __syserr05[] = "Input or output error (EIO)"

Definition at line 28 of file strerror.c.

◆ __syserr06

char __syserr06[] = "No such device or address (ENXIO)"

Definition at line 29 of file strerror.c.

◆ __syserr07

char __syserr07[] = "Argument list too long (E2BIG)"

Definition at line 30 of file strerror.c.

◆ __syserr08

char __syserr08[] = "Unable to execute file (ENOEXEC)"

Definition at line 31 of file strerror.c.

◆ __syserr09

char __syserr09[] = "Bad file descriptor (EBADF)"

Definition at line 32 of file strerror.c.

◆ __syserr10

char __syserr10[] = "No child processes (ECHILD)"

Definition at line 33 of file strerror.c.

◆ __syserr11

char __syserr11[] = "Resource temporarily unavailable (EAGAIN)"

Definition at line 34 of file strerror.c.

◆ __syserr12

char __syserr12[] = "Not enough memory (ENOMEM)"

Definition at line 35 of file strerror.c.

◆ __syserr13

char __syserr13[] = "Permission denied (EACCES)"

Definition at line 36 of file strerror.c.

◆ __syserr14

char __syserr14[] = "Bad address (EFAULT)"

Definition at line 37 of file strerror.c.

◆ __syserr15

char __syserr15[] = "Unknown Error: 15"

Definition at line 38 of file strerror.c.

◆ __syserr16

char __syserr16[] = "Resource busy (EBUSY)"

Definition at line 39 of file strerror.c.

◆ __syserr17

char __syserr17[] = "File exists (EEXIST)"

Definition at line 40 of file strerror.c.

◆ __syserr18

char __syserr18[] = "Improper link (EXDEV)"

Definition at line 41 of file strerror.c.

◆ __syserr19

char __syserr19[] = "No such device (ENODEV)"

Definition at line 42 of file strerror.c.

◆ __syserr20

char __syserr20[] = "Not a directory (ENOTDIR)"

Definition at line 43 of file strerror.c.

◆ __syserr21

char __syserr21[] = "Is a directory (EISDIR)"

Definition at line 44 of file strerror.c.

◆ __syserr22

char __syserr22[] = "Invalid argument (EINVAL)"

Definition at line 45 of file strerror.c.

◆ __syserr23

char __syserr23[] = "Too many open files in system (ENFILE)"

Definition at line 46 of file strerror.c.

◆ __syserr24

char __syserr24[] = "Too many open files (EMFILE)"

Definition at line 47 of file strerror.c.

◆ __syserr25

char __syserr25[] = "Inappropriate I/O control operation (ENOTTY)"

Definition at line 48 of file strerror.c.

◆ __syserr26

char __syserr26[] = "Unknown error: 26"

Definition at line 49 of file strerror.c.

◆ __syserr27

char __syserr27[] = "File too large (EFBIG)"

Definition at line 50 of file strerror.c.

◆ __syserr28

char __syserr28[] = "No space left on drive (ENOSPC)"

Definition at line 51 of file strerror.c.

◆ __syserr29

char __syserr29[] = "Invalid seek (ESPIPE)"

Definition at line 52 of file strerror.c.

◆ __syserr30

char __syserr30[] = "Read-only file system (EROFS)"

Definition at line 53 of file strerror.c.

◆ __syserr31

char __syserr31[] = "Too many links (EMLINK)"

Definition at line 54 of file strerror.c.

◆ __syserr32

char __syserr32[] = "Broken pipe (EPIPE)"

Definition at line 55 of file strerror.c.

◆ __syserr33

char __syserr33[] = "Input to function out of range (EDOM)"

Definition at line 56 of file strerror.c.

◆ __syserr34

char __syserr34[] = "Output of function out of range (ERANGE)"

Definition at line 57 of file strerror.c.

◆ __syserr35

char __syserr35[] = "Unknown error: 35"

Definition at line 58 of file strerror.c.

◆ __syserr36

char __syserr36[] = "Resource deadlock avoided (EDEADLK)"

Definition at line 59 of file strerror.c.

◆ __syserr37

char __syserr37[] = "Unknown error: 37"

Definition at line 60 of file strerror.c.

◆ __syserr38

char __syserr38[] = "File name too long (ENAMETOOLONG)"

Definition at line 61 of file strerror.c.

◆ __syserr39

char __syserr39[] = "No locks available (ENOLCK)"

Definition at line 62 of file strerror.c.

◆ __syserr40

char __syserr40[] = "Function not implemented (ENOSYS)"

Definition at line 63 of file strerror.c.

◆ __syserr41

char __syserr41[] = "Directory not empty (ENOTEMPTY)"

Definition at line 64 of file strerror.c.

◆ __syserr42

char __syserr42[] = "Illegal byte sequence (EILSEQ)"

Definition at line 65 of file strerror.c.

◆ __syserr43

char __syserr43[] = "Unknown/generic error"

Definition at line 66 of file strerror.c.

◆ _sys_errlist

char* _sys_errlist[]
Initial value:
= {
}
char __syserr32[]
Definition: strerror.c:55
char __syserr13[]
Definition: strerror.c:36
char __syserr30[]
Definition: strerror.c:53
char __syserr10[]
Definition: strerror.c:33
char __syserr37[]
Definition: strerror.c:60
char __syserr17[]
Definition: strerror.c:40
char __syserr29[]
Definition: strerror.c:52
char __syserr36[]
Definition: strerror.c:59
char __syserr18[]
Definition: strerror.c:41
char __syserr43[]
Definition: strerror.c:66
char __syserr01[]
Definition: strerror.c:24
char __syserr24[]
Definition: strerror.c:47
char __syserr23[]
Definition: strerror.c:46
char __syserr25[]
Definition: strerror.c:48
char __syserr20[]
Definition: strerror.c:43
char __syserr04[]
Definition: strerror.c:27
char __syserr00[]
Definition: strerror.c:23
char __syserr05[]
Definition: strerror.c:28
char __syserr33[]
Definition: strerror.c:56
char __syserr09[]
Definition: strerror.c:32
char __syserr12[]
Definition: strerror.c:35
char __syserr34[]
Definition: strerror.c:57
char __syserr42[]
Definition: strerror.c:65
char __syserr40[]
Definition: strerror.c:63
char __syserr11[]
Definition: strerror.c:34
char __syserr35[]
Definition: strerror.c:58
char __syserr19[]
Definition: strerror.c:42
char __syserr22[]
Definition: strerror.c:45
char __syserr15[]
Definition: strerror.c:38
char __syserr21[]
Definition: strerror.c:44
char __syserr41[]
Definition: strerror.c:64
char __syserr16[]
Definition: strerror.c:39
char __syserr02[]
Definition: strerror.c:25
char __syserr28[]
Definition: strerror.c:51
char __syserr14[]
Definition: strerror.c:37
char __syserr26[]
Definition: strerror.c:49
char __syserr27[]
Definition: strerror.c:50
char __syserr06[]
Definition: strerror.c:29
char __syserr38[]
Definition: strerror.c:61
char __syserr31[]
Definition: strerror.c:54
char __syserr07[]
Definition: strerror.c:30
char __syserr39[]
Definition: strerror.c:62
char __syserr08[]
Definition: strerror.c:31
char __syserr03[]
Definition: strerror.c:26

Definition at line 68 of file strerror.c.

Referenced by __wcserror_s(), _strerror(), _wcserror_s(), perror(), strerror(), strerror_s(), and Test__sys_errlist().

◆ _sys_nerr

int _sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]) - 1