]> git.cworth.org Git - tar/blob - gnu/strerror.c
26ef483e4b3288fc09a9422eca81529ecaf6cd73
[tar] / gnu / strerror.c
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-2010 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 *
43 rpl_strerror (int n)
44 {
45   char const *msg = NULL;
46   /* These error messages are taken from glibc/sysdeps/gnu/errlist.c.  */
47   switch (n)
48     {
49 # if GNULIB_defined_ETXTBSY
50     case ETXTBSY:
51       msg = "Text file busy";
52       break;
53 # endif
54
55 # if GNULIB_defined_ESOCK /* native Windows platforms */
56     /* EWOULDBLOCK is the same as EAGAIN.  */
57     case EINPROGRESS:
58       msg = "Operation now in progress";
59       break;
60     case EALREADY:
61       msg = "Operation already in progress";
62       break;
63     case ENOTSOCK:
64       msg = "Socket operation on non-socket";
65       break;
66     case EDESTADDRREQ:
67       msg = "Destination address required";
68       break;
69     case EMSGSIZE:
70       msg = "Message too long";
71       break;
72     case EPROTOTYPE:
73       msg = "Protocol wrong type for socket";
74       break;
75     case ENOPROTOOPT:
76       msg = "Protocol not available";
77       break;
78     case EPROTONOSUPPORT:
79       msg = "Protocol not supported";
80       break;
81     case ESOCKTNOSUPPORT:
82       msg = "Socket type not supported";
83       break;
84     case EOPNOTSUPP:
85       msg = "Operation not supported";
86       break;
87     case EPFNOSUPPORT:
88       msg = "Protocol family not supported";
89       break;
90     case EAFNOSUPPORT:
91       msg = "Address family not supported by protocol";
92       break;
93     case EADDRINUSE:
94       msg = "Address already in use";
95       break;
96     case EADDRNOTAVAIL:
97       msg = "Cannot assign requested address";
98       break;
99     case ENETDOWN:
100       msg = "Network is down";
101       break;
102     case ENETUNREACH:
103       msg = "Network is unreachable";
104       break;
105     case ENETRESET:
106       msg = "Network dropped connection on reset";
107       break;
108     case ECONNABORTED:
109       msg = "Software caused connection abort";
110       break;
111     case ECONNRESET:
112       msg = "Connection reset by peer";
113       break;
114     case ENOBUFS:
115       msg = "No buffer space available";
116       break;
117     case EISCONN:
118       msg = "Transport endpoint is already connected";
119       break;
120     case ENOTCONN:
121       msg = "Transport endpoint is not connected";
122       break;
123     case ESHUTDOWN:
124       msg = "Cannot send after transport endpoint shutdown";
125       break;
126     case ETOOMANYREFS:
127       msg = "Too many references: cannot splice";
128       break;
129     case ETIMEDOUT:
130       msg = "Connection timed out";
131       break;
132     case ECONNREFUSED:
133       msg = "Connection refused";
134       break;
135     case ELOOP:
136       msg = "Too many levels of symbolic links";
137       break;
138     case EHOSTDOWN:
139       msg = "Host is down";
140       break;
141     case EHOSTUNREACH:
142       msg = "No route to host";
143       break;
144     case EPROCLIM:
145       msg = "Too many processes";
146       break;
147     case EUSERS:
148       msg = "Too many users";
149       break;
150     case EDQUOT:
151       msg = "Disk quota exceeded";
152       break;
153     case ESTALE:
154       msg = "Stale NFS file handle";
155       break;
156     case EREMOTE:
157       msg = "Object is remote";
158       break;
159 #  if HAVE_WINSOCK2_H
160     /* WSA_INVALID_HANDLE maps to EBADF */
161     /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
162     /* WSA_INVALID_PARAMETER maps to EINVAL */
163     case WSA_OPERATION_ABORTED:
164       msg = "Overlapped operation aborted";
165       break;
166     case WSA_IO_INCOMPLETE:
167       msg = "Overlapped I/O event object not in signaled state";
168       break;
169     case WSA_IO_PENDING:
170       msg = "Overlapped operations will complete later";
171       break;
172     /* WSAEINTR maps to EINTR */
173     /* WSAEBADF maps to EBADF */
174     /* WSAEACCES maps to EACCES */
175     /* WSAEFAULT maps to EFAULT */
176     /* WSAEINVAL maps to EINVAL */
177     /* WSAEMFILE maps to EMFILE */
178     /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
179     /* WSAEINPROGRESS is EINPROGRESS */
180     /* WSAEALREADY is EALREADY */
181     /* WSAENOTSOCK is ENOTSOCK */
182     /* WSAEDESTADDRREQ is EDESTADDRREQ */
183     /* WSAEMSGSIZE is EMSGSIZE */
184     /* WSAEPROTOTYPE is EPROTOTYPE */
185     /* WSAENOPROTOOPT is ENOPROTOOPT */
186     /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
187     /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
188     /* WSAEOPNOTSUPP is EOPNOTSUPP */
189     /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
190     /* WSAEAFNOSUPPORT is EAFNOSUPPORT */
191     /* WSAEADDRINUSE is EADDRINUSE */
192     /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
193     /* WSAENETDOWN is ENETDOWN */
194     /* WSAENETUNREACH is ENETUNREACH */
195     /* WSAENETRESET is ENETRESET */
196     /* WSAECONNABORTED is ECONNABORTED */
197     /* WSAECONNRESET is ECONNRESET */
198     /* WSAENOBUFS is ENOBUFS */
199     /* WSAEISCONN is EISCONN */
200     /* WSAENOTCONN is ENOTCONN */
201     /* WSAESHUTDOWN is ESHUTDOWN */
202     /* WSAETOOMANYREFS is ETOOMANYREFS */
203     /* WSAETIMEDOUT is ETIMEDOUT */
204     /* WSAECONNREFUSED is ECONNREFUSED */
205     /* WSAELOOP is ELOOP */
206     /* WSAENAMETOOLONG maps to ENAMETOOLONG */
207     /* WSAEHOSTDOWN is EHOSTDOWN */
208     /* WSAEHOSTUNREACH is EHOSTUNREACH */
209     /* WSAENOTEMPTY maps to ENOTEMPTY */
210     /* WSAEPROCLIM is EPROCLIM */
211     /* WSAEUSERS is EUSERS */
212     /* WSAEDQUOT is EDQUOT */
213     /* WSAESTALE is ESTALE */
214     /* WSAEREMOTE is EREMOTE */
215     case WSASYSNOTREADY:
216       msg = "Network subsystem is unavailable";
217       break;
218     case WSAVERNOTSUPPORTED:
219       msg = "Winsock.dll version out of range";
220       break;
221     case WSANOTINITIALISED:
222       msg = "Successful WSAStartup not yet performed";
223       break;
224     case WSAEDISCON:
225       msg = "Graceful shutdown in progress";
226       break;
227     case WSAENOMORE: case WSA_E_NO_MORE:
228       msg = "No more results";
229       break;
230     case WSAECANCELLED: case WSA_E_CANCELLED:
231       msg = "Call was canceled";
232       break;
233     case WSAEINVALIDPROCTABLE:
234       msg = "Procedure call table is invalid";
235       break;
236     case WSAEINVALIDPROVIDER:
237       msg = "Service provider is invalid";
238       break;
239     case WSAEPROVIDERFAILEDINIT:
240       msg = "Service provider failed to initialize";
241       break;
242     case WSASYSCALLFAILURE:
243       msg = "System call failure";
244       break;
245     case WSASERVICE_NOT_FOUND:
246       msg = "Service not found";
247       break;
248     case WSATYPE_NOT_FOUND:
249       msg = "Class type not found";
250       break;
251     case WSAEREFUSED:
252       msg = "Database query was refused";
253       break;
254     case WSAHOST_NOT_FOUND:
255       msg = "Host not found";
256       break;
257     case WSATRY_AGAIN:
258       msg = "Nonauthoritative host not found";
259       break;
260     case WSANO_RECOVERY:
261       msg = "Nonrecoverable error";
262       break;
263     case WSANO_DATA:
264       msg = "Valid name, no data record of requested type";
265       break;
266     /* WSA_QOS_* omitted */
267 #  endif
268 # endif
269
270 # if GNULIB_defined_ENOMSG
271     case ENOMSG:
272       msg = "No message of desired type";
273       break;
274 # endif
275
276 # if GNULIB_defined_EIDRM
277     case EIDRM:
278       msg = "Identifier removed";
279       break;
280 # endif
281
282 # if GNULIB_defined_ENOLINK
283     case ENOLINK:
284       msg = "Link has been severed";
285       break;
286 # endif
287
288 # if GNULIB_defined_EPROTO
289     case EPROTO:
290       msg = "Protocol error";
291       break;
292 # endif
293
294 # if GNULIB_defined_EMULTIHOP
295     case EMULTIHOP:
296       msg = "Multihop attempted";
297       break;
298 # endif
299
300 # if GNULIB_defined_EBADMSG
301     case EBADMSG:
302       msg = "Bad message";
303       break;
304 # endif
305
306 # if GNULIB_defined_EOVERFLOW
307     case EOVERFLOW:
308       msg = "Value too large for defined data type";
309       break;
310 # endif
311
312 # if GNULIB_defined_ENOTSUP
313     case ENOTSUP:
314       msg = "Not supported";
315       break;
316 # endif
317
318 # if GNULIB_defined_ESTALE
319     case ESTALE:
320       msg = "Stale NFS file handle";
321       break;
322 # endif
323
324 # if GNULIB_defined_ECANCELED
325     case ECANCELED:
326       msg = "Operation canceled";
327       break;
328 # endif
329     }
330
331   if (msg)
332     return (char *) msg;
333
334   {
335     char *result = strerror (n);
336
337     if (result == NULL || result[0] == '\0')
338       {
339         static char const fmt[] = "Unknown error (%d)";
340         static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)];
341         sprintf (msg_buf, fmt, n);
342         return msg_buf;
343       }
344
345     return result;
346   }
347 }
348
349 #endif