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