1 /* strerror.c --- POSIX compatible system error routine
3 Copyright (C) 2007-2008 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/>. */
27 # if GNULIB_defined_ESOCK /* native Windows platforms */
29 # include <winsock2.h>
33 # include "intprops.h"
36 # if ! HAVE_DECL_STRERROR
37 # define strerror(n) NULL
43 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
46 # if GNULIB_defined_ETXTBSY
48 return "Text file busy";
51 # if GNULIB_defined_ESOCK /* native Windows platforms */
53 return "Operation would block";
55 return "Operation now in progress";
57 return "Operation already in progress";
59 return "Socket operation on non-socket";
61 return "Destination address required";
63 return "Message too long";
65 return "Protocol wrong type for socket";
67 return "Protocol not available";
69 return "Protocol not supported";
71 return "Socket type not supported";
73 return "Operation not supported";
75 return "Protocol family not supported";
77 return "Address family not supported by protocol";
79 return "Address already in use";
81 return "Cannot assign requested address";
83 return "Network is down";
85 return "Network is unreachable";
87 return "Network dropped connection on reset";
89 return "Software caused connection abort";
91 return "Connection reset by peer";
93 return "No buffer space available";
95 return "Transport endpoint is already connected";
97 return "Transport endpoint is not connected";
99 return "Cannot send after transport endpoint shutdown";
101 return "Too many references: cannot splice";
103 return "Connection timed out";
105 return "Connection refused";
107 return "Too many levels of symbolic links";
109 return "Host is down";
111 return "No route to host";
113 return "Too many processes";
115 return "Too many users";
117 return "Disk quota exceeded";
119 return "Stale NFS file handle";
121 return "Object is remote";
123 /* WSA_INVALID_HANDLE maps to EBADF */
124 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
125 /* WSA_INVALID_PARAMETER maps to EINVAL */
126 case WSA_OPERATION_ABORTED:
127 return "Overlapped operation aborted";
128 case WSA_IO_INCOMPLETE:
129 return "Overlapped I/O event object not in signaled state";
131 return "Overlapped operations will complete later";
132 /* WSAEINTR maps to EINTR */
133 /* WSAEBADF maps to EBADF */
134 /* WSAEACCES maps to EACCES */
135 /* WSAEFAULT maps to EFAULT */
136 /* WSAEINVAL maps to EINVAL */
137 /* WSAEMFILE maos to EMFILE */
138 /* WSAEWOULDBLOCK is EWOULDBLOCK */
139 /* WSAEINPROGRESS is EINPROGRESS */
140 /* WSAEALREADY is EALREADY */
141 /* WSAENOTSOCK is ENOTSOCK */
142 /* WSAEDESTADDRREQ is EDESTADDRREQ */
143 /* WSAEMSGSIZE is EMSGSIZE */
144 /* WSAEPROTOTYPE is EPROTOTYPE */
145 /* WSAENOPROTOOPT is ENOPROTOOPT */
146 /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
147 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
148 /* WSAEOPNOTSUPP is EOPNOTSUPP */
149 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
150 /* WSAEAFNOSUPPORT is EAFNOSUPPORT */
151 /* WSAEADDRINUSE is EADDRINUSE */
152 /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
153 /* WSAENETDOWN is ENETDOWN */
154 /* WSAENETUNREACH is ENETUNREACH */
155 /* WSAENETRESET is ENETRESET */
156 /* WSAECONNABORTED is ECONNABORTED */
157 /* WSAECONNRESET is ECONNRESET */
158 /* WSAENOBUFS is ENOBUFS */
159 /* WSAEISCONN is EISCONN */
160 /* WSAENOTCONN is ENOTCONN */
161 /* WSAESHUTDOWN is ESHUTDOWN */
162 /* WSAETOOMANYREFS is ETOOMANYREFS */
163 /* WSAETIMEDOUT is ETIMEDOUT */
164 /* WSAECONNREFUSED is ECONNREFUSED */
165 /* WSAELOOP is ELOOP */
166 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
167 /* WSAEHOSTDOWN is EHOSTDOWN */
168 /* WSAEHOSTUNREACH is EHOSTUNREACH */
169 /* WSAENOTEMPTY maps to ENOTEMPTY */
170 /* WSAEPROCLIM is EPROCLIM */
171 /* WSAEUSERS is EUSERS */
172 /* WSAEDQUOT is EDQUOT */
173 /* WSAESTALE is ESTALE */
174 /* WSAEREMOTE is EREMOTE */
176 return "Network subsystem is unavailable";
177 case WSAVERNOTSUPPORTED:
178 return "Winsock.dll version out of range";
179 case WSANOTINITIALISED:
180 return "Successful WSAStartup not yet performed";
182 return "Graceful shutdown in progress";
183 case WSAENOMORE: case WSA_E_NO_MORE:
184 return "No more results";
185 case WSAECANCELLED: case WSA_E_CANCELLED:
186 return "Call was canceled";
187 case WSAEINVALIDPROCTABLE:
188 return "Procedure call table is invalid";
189 case WSAEINVALIDPROVIDER:
190 return "Service provider is invalid";
191 case WSAEPROVIDERFAILEDINIT:
192 return "Service provider failed to initialize";
193 case WSASYSCALLFAILURE:
194 return "System call failure";
195 case WSASERVICE_NOT_FOUND:
196 return "Service not found";
197 case WSATYPE_NOT_FOUND:
198 return "Class type not found";
200 return "Database query was refused";
201 case WSAHOST_NOT_FOUND:
202 return "Host not found";
204 return "Nonauthoritative host not found";
206 return "Nonrecoverable error";
208 return "Valid name, no data record of requested type";
209 /* WSA_QOS_* omitted */
213 # if GNULIB_defined_ENOMSG
215 return "No message of desired type";
218 # if GNULIB_defined_EIDRM
220 return "Identifier removed";
223 # if GNULIB_defined_ENOLINK
225 return "Link has been severed";
228 # if GNULIB_defined_EPROTO
230 return "Protocol error";
233 # if GNULIB_defined_EMULTIHOP
235 return "Multihop attempted";
238 # if GNULIB_defined_EBADMSG
240 return "Bad message";
243 # if GNULIB_defined_EOVERFLOW
245 return "Value too large for defined data type";
248 # if GNULIB_defined_ENOTSUP
250 return "Not supported";
255 return "Operation canceled";
260 char *result = strerror (n);
262 if (result == NULL || result[0] == '\0')
264 static char const fmt[] = "Unknown error (%d)";
265 static char mesg[sizeof fmt + INT_STRLEN_BOUND (n)];
266 sprintf (mesg, fmt, n);