bump version
[AROS.git] / compiler / posixc / strerror.c
blobcf0e4b9f0aeeabc445a68a30d82af12328f7151f
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 C99 function strerror().
6 */
8 #include <clib/macros.h>
9 #include <errno.h>
11 static const char * _errstrings[];
13 /*****************************************************************************
15 NAME */
16 #include <string.h>
18 char * __posixc_strerror (
20 /* SYNOPSIS */
21 int n)
23 /* FUNCTION
24 Returns a readable string for an error number in errno.
26 INPUTS
27 n - The contents of errno or a #define from errno.h
29 RESULT
30 A string describing the error.
32 NOTES
33 This function is used to override the strerror() function of
34 stdc.library to handle the extra errnos from posixc.library.
35 It is aliased as strerror() in libposixc.a
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 stdc.library/__stdc_strerror(), stdc.library/strerror()
44 INTERNALS
46 ******************************************************************************/
48 char *s;
50 s = (char *)_errstrings[MIN(n, __POSIXC_ELAST+1)];
52 return (s != NULL ? s : __stdc_strerror(n));
53 } /* strerror */
56 /* Only POSIX.1-2008 specific codes are here
57 C99 codes will be handled by calling __stdc_strerror()
59 static const char * _errstrings[__POSIXC_ELAST+2] =
61 /* 0 */ "No error",
62 /* EPERM */ "Operation not permitted",
63 /* C99 */ NULL,
64 /* ESRCH */ "No such process",
65 /* C99 */ NULL,
66 /* EIO */ "I/O error",
67 /* ENXIO */ "No such device or address",
68 /* E2BIG */ "Arg list too long",
69 /* C99 */ NULL,
70 /* EBADF */ "Bad file number",
71 /* ECHILD */ "No child processes",
72 /* EDEADLK */ "Resource deadlock would occur",
73 /* C99 */ NULL,
74 /* C99 */ NULL,
75 /* EFAULT */ "Bad address",
76 /* NA */ NULL,
77 /* C99 */ NULL,
78 /* C99 */ NULL,
79 /* C99 */ NULL,
80 /* ENODEV */ "No such device",
81 /* C99 */ NULL,
82 /* EISDIR */ "Is a directory",
83 /* C99 */ NULL,
84 /* ENFILE */ "File table overflow",
85 /* EMFILE */ "Too many open files",
86 /* ENOTTY */ "Not a typewriter",
87 /* ETXTBSY */ "Text file busy",
88 /* EFBIG */ "File too large",
89 /* ENOSPC */ "No space left on device",
90 /* ESPIPE */ "Illegal seek",
91 /* EROFS */ "Read-only file system",
92 /* EMLINK */ "Too many links",
93 /* EPIPE */ "Broken pipe",
94 /* C99 */ NULL,
95 /* C99 */ NULL,
96 /* EAGAIN */ "Try again",
97 /* EINPROGRESS */ "Operation now in progress",
98 /* EALREADY */ "Operation already in progress",
99 /* ENOTSOCK */ "Socket operation on non-socket",
100 /* EDESTADDRREQ */ "Destination address required",
101 /* EMSGSIZE */ "Message too long",
102 /* EPROTOTYPE */ "Protocol wrong type for socket",
103 /* ENOPROTOOPT */ "Protocol not available",
104 /* EPROTONOSUPPORT */ "Protocol not supported",
105 /* ESOCKTNOSUPPORT */ "Socket type not supported",
106 /* EOPNOTSUPP */ "Operation not supported on transport endpoint",
107 /* EPFNOSUPPORT */ "Protocol family not supported",
108 /* EAFNOSUPPORT */ "Address family not supported by protocol",
109 /* EADDRINUSE */ "Address already in use",
110 /* EADDRNOTAVAIL */ "Cannot assign requested address",
111 /* ENETDOWN */ "Network is down",
112 /* ENETUNREACH */ "Network is unreachable",
113 /* ENETRESET */ "Network dropped connection because of reset",
114 /* ECONNABORTED */ "Software caused connection abort",
115 /* ECONNRESET */ "Connection reset by peer",
116 /* C99 */ NULL,
117 /* EISCONN */ "Transport endpoint is already connected",
118 /* ENOTCONN */ "Transport endpoint is not connected",
119 /* ESHUTDOWN */ "Cannot send after transport endpoint shutdown",
120 /* NA */ NULL,
121 /* ETIMEDOUT */ "Connection timed out",
122 /* ECONNREFUSED */ "Connection refused",
123 /* ELOOP */ "Too many symbolic links encountered",
124 /* ENAMETOOLONG */ "File name too long",
125 /* EHOSTDOWN */ "Host is down",
126 /* EHOSTUNREACH */ "No route to host",
127 /* ENOTEMPTY */ "Directory not empty",
128 /* NA */ NULL,
129 /* NA */ NULL,
130 /* EDQUOT */ "Quota exceeded",
131 /* ESTALE */ "Stale NFS file handle",
132 /* NA */ NULL,
133 /* NA */ NULL,
134 /* NA */ NULL,
135 /* NA */ NULL,
136 /* NA */ NULL,
137 /* NA */ NULL,
138 /* ENOLCK */ "No record locks available",
139 /* ENOSYS */ "Function not implemented",
140 /* NA */ NULL,
141 /* NA */ NULL,
142 /* NA */ NULL,
143 /* EIDRM */ "Identifier removed",
144 /* ENOMSG */ "No message of desired type",
145 /* EOVERFLOW */ "Value too large for defined data type",
146 /* C99 */ NULL,
147 /* ENOTSUP */ "Not supported",
148 /* ECANCELED */ "Operation canceled",
149 /* EBADMSG */ "Bad or Corrupt message",
150 /* ENODATA */ "No message available",
151 /* ENOSR */ "No STREAM resources",
152 /* ENOSTR */ "Not a STREAM",
153 /* ETIME */ "STREAM ioctl timeout",
154 /* NA */ NULL,
155 /* EMULTIHOP */ "Multihop attempted",
156 /* ENOLINK */ "Link has been severed",
157 /* EPROTO */ "Protocol error",
158 /* Too high */ NULL