2 Copyright © 1995-2018, The AROS Development Team. All rights reserved.
5 C99 function strerror().
8 #include <proto/exec.h>
10 #define __NOBLIBBASE__
12 #include <proto/dos.h>
14 #include <clib/macros.h>
18 #include "__stdc_intbase.h"
20 static const char * _errstrings
[];
22 /*****************************************************************************
33 Returns a readable string for an error number in errno.
36 n - The contents of errno or a #define from errno.h
39 A string describing the error.
52 ******************************************************************************/
54 /*****************************************************************************
59 char * __stdc_strerror (
65 Returns a readable string for an error number in errno.
68 n - The contents of errno or a #define from errno.h
71 A string describing the error.
74 This functions only handles the error codes needed by C99 and the ones
75 used in stdc.library. This function is aliased as strerror() in
77 Other libraries may override this function by providing this function
78 also in their libxxx.a file. They can internally call __stdc_strerror
79 to get the strings for the errors handled by this function.
90 ******************************************************************************/
94 struct StdCIntBase
*StdCBase
=
95 (struct StdCIntBase
*)__aros_getbase_StdCBase();
96 #define DOSBase StdCBase->StdCDOSBase
98 if (StdCBase
->fault_buf
== NULL
)
99 /* This is not freed anywhere, will be cleaned when
102 StdCBase
->fault_buf
= malloc(100);
104 Fault(n
- MAX_ERRNO
, NULL
, StdCBase
->fault_buf
, 100);
106 return StdCBase
->fault_buf
;
112 s
= (char *)_errstrings
[MIN(n
, __STDC_ELAST
+1)];
115 s
= (char *)"Errno out of range";
122 static const char * _errstrings
[__STDC_ELAST
+2] =
126 /* ENOENT */ "No such file or directory",
128 /* EINTR */ "Interrupted system call",
132 /* ENOEXEC */ "Exec format error",
136 /* ENOMEM */ "Out of memory",
137 /* EACCES */ "Permission denied",
140 /* EBUSY */ "Device or resource busy",
141 /* EEXIST */ "File exists",
142 /* EXDEV */ "Cross-device link",
144 /* ENOTDIR */ "Not a directory",
146 /* EINVAL */ "Invalid argument",
157 /* EDOM */ "Numerical argument out of domain",
158 /* ERANGE */ "Math result not representable",
179 /* ENOBUFS */ "No buffer space available",
209 /* EILSEQ */ "Illegal byte sequence",
213 static int __stdc_dosinit(struct StdCIntBase
*StdCBase
)
215 StdCBase
->StdCDOSBase
= (struct DosLibrary
*)OpenLibrary("dos.library", 0);
220 ADD2OPENLIB(__stdc_dosinit
, 0);