documentation update
[gnutls.git] / gl / strerror-override.c
blob9ca6523490f7ba395f163dcac2c6c02466a15ab2
1 /* strerror-override.c --- POSIX compatible system error routine
3 Copyright (C) 2010-2012 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* Written by Bruno Haible <bruno@clisp.org>, 2010. */
20 #include <config.h>
22 #include "strerror-override.h"
24 #include <errno.h>
26 #if GNULIB_defined_EWINSOCK /* native Windows platforms */
27 # if HAVE_WINSOCK2_H
28 # include <winsock2.h>
29 # endif
30 #endif
32 /* If ERRNUM maps to an errno value defined by gnulib, return a string
33 describing the error. Otherwise return NULL. */
34 const char *
35 strerror_override (int errnum)
37 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
38 switch (errnum)
40 #if REPLACE_STRERROR_0
41 case 0:
42 return "Success";
43 #endif
45 #if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
46 case EINPROGRESS:
47 return "Operation now in progress";
48 case EALREADY:
49 return "Operation already in progress";
50 case ENOTSOCK:
51 return "Socket operation on non-socket";
52 case EDESTADDRREQ:
53 return "Destination address required";
54 case EMSGSIZE:
55 return "Message too long";
56 case EPROTOTYPE:
57 return "Protocol wrong type for socket";
58 case ENOPROTOOPT:
59 return "Protocol not available";
60 case EPROTONOSUPPORT:
61 return "Protocol not supported";
62 case EOPNOTSUPP:
63 return "Operation not supported";
64 case EAFNOSUPPORT:
65 return "Address family not supported by protocol";
66 case EADDRINUSE:
67 return "Address already in use";
68 case EADDRNOTAVAIL:
69 return "Cannot assign requested address";
70 case ENETDOWN:
71 return "Network is down";
72 case ENETUNREACH:
73 return "Network is unreachable";
74 case ECONNRESET:
75 return "Connection reset by peer";
76 case ENOBUFS:
77 return "No buffer space available";
78 case EISCONN:
79 return "Transport endpoint is already connected";
80 case ENOTCONN:
81 return "Transport endpoint is not connected";
82 case ETIMEDOUT:
83 return "Connection timed out";
84 case ECONNREFUSED:
85 return "Connection refused";
86 case ELOOP:
87 return "Too many levels of symbolic links";
88 case EHOSTUNREACH:
89 return "No route to host";
90 case EWOULDBLOCK:
91 return "Operation would block";
92 case ETXTBSY:
93 return "Text file busy";
94 case ENODATA:
95 return "No data available";
96 case ENOSR:
97 return "Out of streams resources";
98 case ENOSTR:
99 return "Device not a stream";
100 case ENOTRECOVERABLE:
101 return "State not recoverable";
102 case EOWNERDEAD:
103 return "Owner died";
104 case ETIME:
105 return "Timer expired";
106 case EOTHER:
107 return "Other error";
108 #endif
109 #if GNULIB_defined_EWINSOCK /* native Windows platforms */
110 case ESOCKTNOSUPPORT:
111 return "Socket type not supported";
112 case EPFNOSUPPORT:
113 return "Protocol family not supported";
114 case ESHUTDOWN:
115 return "Cannot send after transport endpoint shutdown";
116 case ETOOMANYREFS:
117 return "Too many references: cannot splice";
118 case EHOSTDOWN:
119 return "Host is down";
120 case EPROCLIM:
121 return "Too many processes";
122 case EUSERS:
123 return "Too many users";
124 case EDQUOT:
125 return "Disk quota exceeded";
126 case ESTALE:
127 return "Stale NFS file handle";
128 case EREMOTE:
129 return "Object is remote";
130 # if HAVE_WINSOCK2_H
131 /* WSA_INVALID_HANDLE maps to EBADF */
132 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
133 /* WSA_INVALID_PARAMETER maps to EINVAL */
134 case WSA_OPERATION_ABORTED:
135 return "Overlapped operation aborted";
136 case WSA_IO_INCOMPLETE:
137 return "Overlapped I/O event object not in signaled state";
138 case WSA_IO_PENDING:
139 return "Overlapped operations will complete later";
140 /* WSAEINTR maps to EINTR */
141 /* WSAEBADF maps to EBADF */
142 /* WSAEACCES maps to EACCES */
143 /* WSAEFAULT maps to EFAULT */
144 /* WSAEINVAL maps to EINVAL */
145 /* WSAEMFILE maps to EMFILE */
146 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
147 /* WSAEINPROGRESS maps to EINPROGRESS */
148 /* WSAEALREADY maps to EALREADY */
149 /* WSAENOTSOCK maps to ENOTSOCK */
150 /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
151 /* WSAEMSGSIZE maps to EMSGSIZE */
152 /* WSAEPROTOTYPE maps to EPROTOTYPE */
153 /* WSAENOPROTOOPT maps to ENOPROTOOPT */
154 /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
155 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
156 /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
157 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
158 /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
159 /* WSAEADDRINUSE maps to EADDRINUSE */
160 /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
161 /* WSAENETDOWN maps to ENETDOWN */
162 /* WSAENETUNREACH maps to ENETUNREACH */
163 /* WSAENETRESET maps to ENETRESET */
164 /* WSAECONNABORTED maps to ECONNABORTED */
165 /* WSAECONNRESET maps to ECONNRESET */
166 /* WSAENOBUFS maps to ENOBUFS */
167 /* WSAEISCONN maps to EISCONN */
168 /* WSAENOTCONN maps to ENOTCONN */
169 /* WSAESHUTDOWN is ESHUTDOWN */
170 /* WSAETOOMANYREFS is ETOOMANYREFS */
171 /* WSAETIMEDOUT maps to ETIMEDOUT */
172 /* WSAECONNREFUSED maps to ECONNREFUSED */
173 /* WSAELOOP maps to ELOOP */
174 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
175 /* WSAEHOSTDOWN is EHOSTDOWN */
176 /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
177 /* WSAENOTEMPTY maps to ENOTEMPTY */
178 /* WSAEPROCLIM is EPROCLIM */
179 /* WSAEUSERS is EUSERS */
180 /* WSAEDQUOT is EDQUOT */
181 /* WSAESTALE is ESTALE */
182 /* WSAEREMOTE is EREMOTE */
183 case WSASYSNOTREADY:
184 return "Network subsystem is unavailable";
185 case WSAVERNOTSUPPORTED:
186 return "Winsock.dll version out of range";
187 case WSANOTINITIALISED:
188 return "Successful WSAStartup not yet performed";
189 case WSAEDISCON:
190 return "Graceful shutdown in progress";
191 case WSAENOMORE: case WSA_E_NO_MORE:
192 return "No more results";
193 case WSAECANCELLED: case WSA_E_CANCELLED:
194 return "Call was canceled";
195 case WSAEINVALIDPROCTABLE:
196 return "Procedure call table is invalid";
197 case WSAEINVALIDPROVIDER:
198 return "Service provider is invalid";
199 case WSAEPROVIDERFAILEDINIT:
200 return "Service provider failed to initialize";
201 case WSASYSCALLFAILURE:
202 return "System call failure";
203 case WSASERVICE_NOT_FOUND:
204 return "Service not found";
205 case WSATYPE_NOT_FOUND:
206 return "Class type not found";
207 case WSAEREFUSED:
208 return "Database query was refused";
209 case WSAHOST_NOT_FOUND:
210 return "Host not found";
211 case WSATRY_AGAIN:
212 return "Nonauthoritative host not found";
213 case WSANO_RECOVERY:
214 return "Nonrecoverable error";
215 case WSANO_DATA:
216 return "Valid name, no data record of requested type";
217 /* WSA_QOS_* omitted */
218 # endif
219 #endif
221 #if GNULIB_defined_ENOMSG
222 case ENOMSG:
223 return "No message of desired type";
224 #endif
226 #if GNULIB_defined_EIDRM
227 case EIDRM:
228 return "Identifier removed";
229 #endif
231 #if GNULIB_defined_ENOLINK
232 case ENOLINK:
233 return "Link has been severed";
234 #endif
236 #if GNULIB_defined_EPROTO
237 case EPROTO:
238 return "Protocol error";
239 #endif
241 #if GNULIB_defined_EMULTIHOP
242 case EMULTIHOP:
243 return "Multihop attempted";
244 #endif
246 #if GNULIB_defined_EBADMSG
247 case EBADMSG:
248 return "Bad message";
249 #endif
251 #if GNULIB_defined_EOVERFLOW
252 case EOVERFLOW:
253 return "Value too large for defined data type";
254 #endif
256 #if GNULIB_defined_ENOTSUP
257 case ENOTSUP:
258 return "Not supported";
259 #endif
261 #if GNULIB_defined_ENETRESET
262 case ENETRESET:
263 return "Network dropped connection on reset";
264 #endif
266 #if GNULIB_defined_ECONNABORTED
267 case ECONNABORTED:
268 return "Software caused connection abort";
269 #endif
271 #if GNULIB_defined_ESTALE
272 case ESTALE:
273 return "Stale NFS file handle";
274 #endif
276 #if GNULIB_defined_EDQUOT
277 case EDQUOT:
278 return "Disk quota exceeded";
279 #endif
281 #if GNULIB_defined_ECANCELED
282 case ECANCELED:
283 return "Operation canceled";
284 #endif
286 default:
287 return NULL;