Changeset 1964 for cpio/vendor/current/gnu/strerror.c
- Timestamp:
- Feb 3, 2017, 2:02:34 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified cpio/vendor/current/gnu/strerror.c ¶
r118 r1964 1 /* -*- buffer-read-only: t -*- vi: set ro: */2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */3 1 /* strerror.c --- POSIX compatible system error routine 4 2 5 Copyright (C) 2007-201 0Free Software Foundation, Inc.3 Copyright (C) 2007-2015 Free Software Foundation, Inc. 6 4 7 5 This program is free software: you can redistribute it and/or modify … … 20 18 #include <config.h> 21 19 20 /* Specification. */ 22 21 #include <string.h> 23 22 24 #if REPLACE_STRERROR 23 #include <errno.h> 24 #include <stdio.h> 25 #include <stdlib.h> 26 #include <string.h> 25 27 26 # include <errno.h> 27 # include <stdio.h> 28 #include "intprops.h" 29 #include "strerror-override.h" 30 #include "verify.h" 28 31 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 32 /* Use the system functions, not the gnulib overrides in this file. */ 33 #undef sprintf 41 34 42 35 char * 43 rpl_strerror (int n) 36 strerror (int n) 37 #undef strerror 44 38 { 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 39 static char buf[STACKBUF_LEN]; 40 size_t len; 54 41 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 42 /* Cast away const, due to the historical signature of strerror; 43 callers should not be modifying the string. */ 44 const char *msg = strerror_override (n); 331 45 if (msg) 332 46 return (char *) msg; 333 47 334 { 335 char *result = strerror (n); 48 msg = strerror (n); 336 49 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 } 50 /* Our strerror_r implementation might use the system's strerror 51 buffer, so all other clients of strerror have to see the error 52 copied into a buffer that we manage. This is not thread-safe, 53 even if the system strerror is, but portable programs shouldn't 54 be using strerror if they care about thread-safety. */ 55 if (!msg || !*msg) 56 { 57 static char const fmt[] = "Unknown error %d"; 58 verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n)); 59 sprintf (buf, fmt, n); 60 errno = EINVAL; 61 return buf; 62 } 344 63 345 return result; 346 } 64 /* Fix STACKBUF_LEN if this ever aborts. */ 65 len = strlen (msg); 66 if (sizeof buf <= len) 67 abort (); 68 69 return memcpy (buf, msg, len + 1); 347 70 } 348 349 #endif
Note:
See TracChangeset
for help on using the changeset viewer.