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