~ubuntu-branches/ubuntu/vivid/gzip/vivid

« back to all changes in this revision

Viewing changes to lib/strerror-override.c

  • Committer: Steve Langasek
  • Date: 2012-06-29 02:07:40 UTC
  • mfrom: (4.1.9 sid)
  • Revision ID: steve.langasek@canonical.com-20120629020740-qqikrblzana08v2y
Merge version 1.5-1.1 from Debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* strerror-override.c --- POSIX compatible system error routine
 
2
 
 
3
   Copyright (C) 2010-2012 Free Software Foundation, Inc.
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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/>.  */
 
17
 
 
18
/* Written by Bruno Haible <bruno@clisp.org>, 2010.  */
 
19
 
 
20
#include <config.h>
 
21
 
 
22
#include "strerror-override.h"
 
23
 
 
24
#include <errno.h>
 
25
 
 
26
#if GNULIB_defined_EWINSOCK /* native Windows platforms */
 
27
# if HAVE_WINSOCK2_H
 
28
#  include <winsock2.h>
 
29
# endif
 
30
#endif
 
31
 
 
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)
 
36
{
 
37
  /* These error messages are taken from glibc/sysdeps/gnu/errlist.c.  */
 
38
  switch (errnum)
 
39
    {
 
40
#if REPLACE_STRERROR_0
 
41
    case 0:
 
42
      return "Success";
 
43
#endif
 
44
 
 
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
#endif
 
93
#if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
 
94
    case ETXTBSY:
 
95
      return "Text file busy";
 
96
    case ENODATA:
 
97
      return "No data available";
 
98
    case ENOSR:
 
99
      return "Out of streams resources";
 
100
    case ENOSTR:
 
101
      return "Device not a stream";
 
102
    case ETIME:
 
103
      return "Timer expired";
 
104
    case EOTHER:
 
105
      return "Other error";
 
106
#endif
 
107
#if GNULIB_defined_EWINSOCK /* native Windows platforms */
 
108
    case ESOCKTNOSUPPORT:
 
109
      return "Socket type not supported";
 
110
    case EPFNOSUPPORT:
 
111
      return "Protocol family not supported";
 
112
    case ESHUTDOWN:
 
113
      return "Cannot send after transport endpoint shutdown";
 
114
    case ETOOMANYREFS:
 
115
      return "Too many references: cannot splice";
 
116
    case EHOSTDOWN:
 
117
      return "Host is down";
 
118
    case EPROCLIM:
 
119
      return "Too many processes";
 
120
    case EUSERS:
 
121
      return "Too many users";
 
122
    case EDQUOT:
 
123
      return "Disk quota exceeded";
 
124
    case ESTALE:
 
125
      return "Stale NFS file handle";
 
126
    case EREMOTE:
 
127
      return "Object is remote";
 
128
# if HAVE_WINSOCK2_H
 
129
      /* WSA_INVALID_HANDLE maps to EBADF */
 
130
      /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
 
131
      /* WSA_INVALID_PARAMETER maps to EINVAL */
 
132
    case WSA_OPERATION_ABORTED:
 
133
      return "Overlapped operation aborted";
 
134
    case WSA_IO_INCOMPLETE:
 
135
      return "Overlapped I/O event object not in signaled state";
 
136
    case WSA_IO_PENDING:
 
137
      return "Overlapped operations will complete later";
 
138
      /* WSAEINTR maps to EINTR */
 
139
      /* WSAEBADF maps to EBADF */
 
140
      /* WSAEACCES maps to EACCES */
 
141
      /* WSAEFAULT maps to EFAULT */
 
142
      /* WSAEINVAL maps to EINVAL */
 
143
      /* WSAEMFILE maps to EMFILE */
 
144
      /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
 
145
      /* WSAEINPROGRESS maps to EINPROGRESS */
 
146
      /* WSAEALREADY maps to EALREADY */
 
147
      /* WSAENOTSOCK maps to ENOTSOCK */
 
148
      /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
 
149
      /* WSAEMSGSIZE maps to EMSGSIZE */
 
150
      /* WSAEPROTOTYPE maps to EPROTOTYPE */
 
151
      /* WSAENOPROTOOPT maps to ENOPROTOOPT */
 
152
      /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
 
153
      /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
 
154
      /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
 
155
      /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
 
156
      /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
 
157
      /* WSAEADDRINUSE maps to EADDRINUSE */
 
158
      /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
 
159
      /* WSAENETDOWN maps to ENETDOWN */
 
160
      /* WSAENETUNREACH maps to ENETUNREACH */
 
161
      /* WSAENETRESET maps to ENETRESET */
 
162
      /* WSAECONNABORTED maps to ECONNABORTED */
 
163
      /* WSAECONNRESET maps to ECONNRESET */
 
164
      /* WSAENOBUFS maps to ENOBUFS */
 
165
      /* WSAEISCONN maps to EISCONN */
 
166
      /* WSAENOTCONN maps to ENOTCONN */
 
167
      /* WSAESHUTDOWN is ESHUTDOWN */
 
168
      /* WSAETOOMANYREFS is ETOOMANYREFS */
 
169
      /* WSAETIMEDOUT maps to ETIMEDOUT */
 
170
      /* WSAECONNREFUSED maps to ECONNREFUSED */
 
171
      /* WSAELOOP maps to ELOOP */
 
172
      /* WSAENAMETOOLONG maps to ENAMETOOLONG */
 
173
      /* WSAEHOSTDOWN is EHOSTDOWN */
 
174
      /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
 
175
      /* WSAENOTEMPTY maps to ENOTEMPTY */
 
176
      /* WSAEPROCLIM is EPROCLIM */
 
177
      /* WSAEUSERS is EUSERS */
 
178
      /* WSAEDQUOT is EDQUOT */
 
179
      /* WSAESTALE is ESTALE */
 
180
      /* WSAEREMOTE is EREMOTE */
 
181
    case WSASYSNOTREADY:
 
182
      return "Network subsystem is unavailable";
 
183
    case WSAVERNOTSUPPORTED:
 
184
      return "Winsock.dll version out of range";
 
185
    case WSANOTINITIALISED:
 
186
      return "Successful WSAStartup not yet performed";
 
187
    case WSAEDISCON:
 
188
      return "Graceful shutdown in progress";
 
189
    case WSAENOMORE: case WSA_E_NO_MORE:
 
190
      return "No more results";
 
191
    case WSAECANCELLED: case WSA_E_CANCELLED:
 
192
      return "Call was canceled";
 
193
    case WSAEINVALIDPROCTABLE:
 
194
      return "Procedure call table is invalid";
 
195
    case WSAEINVALIDPROVIDER:
 
196
      return "Service provider is invalid";
 
197
    case WSAEPROVIDERFAILEDINIT:
 
198
      return "Service provider failed to initialize";
 
199
    case WSASYSCALLFAILURE:
 
200
      return "System call failure";
 
201
    case WSASERVICE_NOT_FOUND:
 
202
      return "Service not found";
 
203
    case WSATYPE_NOT_FOUND:
 
204
      return "Class type not found";
 
205
    case WSAEREFUSED:
 
206
      return "Database query was refused";
 
207
    case WSAHOST_NOT_FOUND:
 
208
      return "Host not found";
 
209
    case WSATRY_AGAIN:
 
210
      return "Nonauthoritative host not found";
 
211
    case WSANO_RECOVERY:
 
212
      return "Nonrecoverable error";
 
213
    case WSANO_DATA:
 
214
      return "Valid name, no data record of requested type";
 
215
      /* WSA_QOS_* omitted */
 
216
# endif
 
217
#endif
 
218
 
 
219
#if GNULIB_defined_ENOMSG
 
220
    case ENOMSG:
 
221
      return "No message of desired type";
 
222
#endif
 
223
 
 
224
#if GNULIB_defined_EIDRM
 
225
    case EIDRM:
 
226
      return "Identifier removed";
 
227
#endif
 
228
 
 
229
#if GNULIB_defined_ENOLINK
 
230
    case ENOLINK:
 
231
      return "Link has been severed";
 
232
#endif
 
233
 
 
234
#if GNULIB_defined_EPROTO
 
235
    case EPROTO:
 
236
      return "Protocol error";
 
237
#endif
 
238
 
 
239
#if GNULIB_defined_EMULTIHOP
 
240
    case EMULTIHOP:
 
241
      return "Multihop attempted";
 
242
#endif
 
243
 
 
244
#if GNULIB_defined_EBADMSG
 
245
    case EBADMSG:
 
246
      return "Bad message";
 
247
#endif
 
248
 
 
249
#if GNULIB_defined_EOVERFLOW
 
250
    case EOVERFLOW:
 
251
      return "Value too large for defined data type";
 
252
#endif
 
253
 
 
254
#if GNULIB_defined_ENOTSUP
 
255
    case ENOTSUP:
 
256
      return "Not supported";
 
257
#endif
 
258
 
 
259
#if GNULIB_defined_ENETRESET
 
260
    case ENETRESET:
 
261
      return "Network dropped connection on reset";
 
262
#endif
 
263
 
 
264
#if GNULIB_defined_ECONNABORTED
 
265
    case ECONNABORTED:
 
266
      return "Software caused connection abort";
 
267
#endif
 
268
 
 
269
#if GNULIB_defined_ESTALE
 
270
    case ESTALE:
 
271
      return "Stale NFS file handle";
 
272
#endif
 
273
 
 
274
#if GNULIB_defined_EDQUOT
 
275
    case EDQUOT:
 
276
      return "Disk quota exceeded";
 
277
#endif
 
278
 
 
279
#if GNULIB_defined_ECANCELED
 
280
    case ECANCELED:
 
281
      return "Operation canceled";
 
282
#endif
 
283
 
 
284
#if GNULIB_defined_EOWNERDEAD
 
285
    case EOWNERDEAD:
 
286
      return "Owner died";
 
287
#endif
 
288
 
 
289
#if GNULIB_defined_ENOTRECOVERABLE
 
290
    case ENOTRECOVERABLE:
 
291
      return "State not recoverable";
 
292
#endif
 
293
 
 
294
    default:
 
295
      return NULL;
 
296
    }
 
297
}