2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 C99 function strerror().
8 #include "__stdc_intbase.h"
10 #include <proto/dos.h>
11 #include <clib/macros.h>
15 static const char * _errstrings
[];
17 /*****************************************************************************
28 Returns a readable string for an error number in errno.
31 n - The contents of errno or a #define from errno.h
34 A string describing the error.
47 ******************************************************************************/
49 /*****************************************************************************
54 char * __stdc_strerror (
60 Returns a readable string for an error number in errno.
63 n - The contents of errno or a #define from errno.h
66 A string describing the error.
69 This functions only handles the error codes needed by C99 and the ones
70 used in stdc.library. This function is aliased as strerror() in
72 Other libraries may override this function by providing this function
73 also in their libxxx.a file. They can internally call __stdc_strerror
74 to get the strings for the errors handled by this function.
85 ******************************************************************************/
89 struct StdCIntBase
*StdCBase
=
90 (struct StdCIntBase
*)__aros_getbase_StdCBase();
92 if (StdCBase
->fault_buf
== NULL
)
93 /* This is not freed anywhere, will be cleaned when
96 StdCBase
->fault_buf
= malloc(100);
98 Fault(n
- MAX_ERRNO
, NULL
, StdCBase
->fault_buf
, 100);
100 return StdCBase
->fault_buf
;
106 s
= (char *)_errstrings
[MIN(n
, __STDC_ELAST
+1)];
109 s
= (char *)"Errno out of range";
116 static const char * _errstrings
[__STDC_ELAST
+2] =
120 /* ENOENT */ "No such file or directory",
122 /* EINTR */ "Interrupted system call",
126 /* ENOEXEC */ "Exec format error",
130 /* ENOMEM */ "Out of memory",
131 /* EACCES */ "Permission denied",
134 /* EBUSY */ "Device or resource busy",
135 /* EEXIST */ "File exists",
136 /* EXDEV */ "Cross-device link",
138 /* ENOTDIR */ "Not a directory",
140 /* EINVAL */ "Invalid argument",
151 /* EDOM */ "Numerical argument out of domain",
152 /* ERANGE */ "Math result not representable",
173 /* ENOBUFS */ "No buffer space available",
203 /* EILSEQ */ "Illegal byte sequence",