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