ReactOS  0.4.14-dev-552-g2fad488
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_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 226 of file strerror.c.

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

◆ __wcserror_s()

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

Definition at line 193 of file strerror.c.

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

Referenced by __wcserror().

◆ _strerror()

char* CDECL _strerror ( const char str)

Definition at line 126 of file strerror.c.

127 {
129  int err;
130 
131  if (!data->strerror_buffer)
132  if (!(data->strerror_buffer = malloc(256))) return NULL;
133 
134  err = data->thread_errno;
135  if (err < 0 || err > _sys_nerr) err = _sys_nerr;
136 
137  if (str && *str)
138  sprintf( data->strerror_buffer, "%s: %s\n", str, _sys_errlist[err] );
139  else
140  sprintf( data->strerror_buffer, "%s\n", _sys_errlist[err] );
141 
142  return data->strerror_buffer;
143 }
#define sprintf(buf, format,...)
Definition: sprintf.c:55
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
int _sys_nerr
Definition: strerror.c:79
char * _sys_errlist[]
Definition: strerror.c:67
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define err(...)
thread_data_t * msvcrt_get_thread_data(void)
Definition: tls.c:31
#define malloc
Definition: debug_ros.c:4

◆ _wcserror()

wchar_t* CDECL _wcserror ( int  err)

Definition at line 180 of file strerror.c.

181 {
183 
184  if (!data->wcserror_buffer)
185  if (!(data->wcserror_buffer = malloc(256 * sizeof(wchar_t)))) return NULL;
186  _wcserror_s(data->wcserror_buffer, 256, err);
187  return data->wcserror_buffer;
188 }
int CDECL _wcserror_s(wchar_t *buffer, size_t nc, int err)
Definition: strerror.c:165
smooth NULL
Definition: ftsmooth.c:416
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define err(...)
thread_data_t * msvcrt_get_thread_data(void)
Definition: tls.c:31
#define malloc
Definition: debug_ros.c:4

◆ _wcserror_s()

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

Definition at line 165 of file strerror.c.

166 {
167  if (!MSVCRT_CHECK_PMT(buffer != NULL) || !MSVCRT_CHECK_PMT(nc > 0))
168  {
170  return EINVAL;
171  }
172  if (err < 0 || err > _sys_nerr) err = _sys_nerr;
174  return 0;
175 }
errno_t __cdecl _set_errno(_In_ int _Value)
#define CP_ACP
Definition: compat.h:99
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
int _sys_nerr
Definition: strerror.c:79
char * _sys_errlist[]
Definition: strerror.c:67
#define MSVCRT_CHECK_PMT(x)
Definition: mbstowcs_s.c:26
#define err(...)
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by _wcserror().

◆ perror()

void CDECL perror ( const char str)

Definition at line 148 of file strerror.c.

149 {
150  int err = *_errno();
151  if (err < 0 || err > _sys_nerr) err = _sys_nerr;
152 
153  if (str && *str)
154  {
155  _write( 2, str, strlen(str) );
156  _write( 2, ": ", 2 );
157  }
159  _write( 2, "\n", 1 );
160 }
_CRTIMP int __cdecl _write(_In_ int _FileHandle, _In_reads_bytes_(_MaxCharCount) const void *_Buf, _In_ unsigned int _MaxCharCount)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
const WCHAR * str
int _sys_nerr
Definition: strerror.c:79
char * _sys_errlist[]
Definition: strerror.c:67
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:19
#define err(...)

◆ strerror()

char* CDECL strerror ( int  err)

Definition at line 84 of file strerror.c.

85 {
87 
88  if (!data->strerror_buffer)
89  if (!(data->strerror_buffer = malloc(256))) return NULL;
90 
91  if (err < 0 || err > _sys_nerr) err = _sys_nerr;
92  strcpy( data->strerror_buffer, _sys_errlist[err] );
93  return data->strerror_buffer;
94 }
smooth NULL
Definition: ftsmooth.c:416
int _sys_nerr
Definition: strerror.c:79
char * _sys_errlist[]
Definition: strerror.c:67
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define err(...)
thread_data_t * msvcrt_get_thread_data(void)
Definition: tls.c:31
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define malloc
Definition: debug_ros.c:4

Referenced by _lzx_get_bytes(), aargh(), adns__must_gettimeofday(), adns__query_send(), adns__querysend_tcp(), adns__tcp_tryconnect(), adns_processreadable(), adns_processwriteable(), adns_wait(), adnsfail(), chmc_init(), chmc_section_create(), clnt_spcreateerror(), clnt_sperror(), errmsgstr(), Error(), fd_event(), fileClient(), fs_flush(), get_ImageBase(), gl_file(), CStringTest::import_checks(), logMess(), main(), make_directory_records(), mpg123_open(), netconn_create(), netconn_set_timeout(), open_stream(), pdie(), process_directory(), processRequest(), proclog(), rdp2vnc_connect(), readconfig(), SError(), ServeOneClient(), Server(), set_LogFile(), sock_recv(), sock_send(), sysfail(), system_icmp(), test_file_inherit_child(), test_file_inherit_child_no(), TIFFOpen(), TRIO_ARGS1(), ui_select(), verr(), vwarn(), write_dlldata(), and write_dlldata_list().

◆ strerror_s()

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

Definition at line 99 of file strerror.c.

100 {
101  char *ptr;
102 
103  if (!buffer || !numberOfElements)
104  {
105  *_errno() = EINVAL;
106  return EINVAL;
107  }
108 
109  if (errnum < 0 || errnum > _sys_nerr)
110  errnum = _sys_nerr;
111 
112  ptr = _sys_errlist[errnum];
113  while (*ptr && numberOfElements > 1)
114  {
115  *buffer++ = *ptr++;
117  }
118 
119  *buffer = '\0';
120  return 0;
121 }
Definition: arc.h:39
GLuint buffer
Definition: glext.h:5915
static size_t numberOfElements
Definition: string.c:87
static PVOID ptr
Definition: dispmode.c:27
int _sys_nerr
Definition: strerror.c:79
char * _sys_errlist[]
Definition: strerror.c:67
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:19

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.

◆ _sys_errlist

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

Definition at line 67 of file strerror.c.

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

◆ _sys_nerr

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

Definition at line 79 of file strerror.c.

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