Blame lib/strerror-override.c

Packit 709fb3
/* strerror-override.c --- POSIX compatible system error routine
Packit 709fb3
Packit 709fb3
   Copyright (C) 2010-2017 Free Software Foundation, Inc.
Packit 709fb3
Packit 709fb3
   This program is free software: you can redistribute it and/or modify
Packit 709fb3
   it under the terms of the GNU General Public License as published by
Packit 709fb3
   the Free Software Foundation; either version 3 of the License, or
Packit 709fb3
   (at your option) any later version.
Packit 709fb3
Packit 709fb3
   This program is distributed in the hope that it will be useful,
Packit 709fb3
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 709fb3
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 709fb3
   GNU General Public License for more details.
Packit 709fb3
Packit 709fb3
   You should have received a copy of the GNU General Public License
Packit 709fb3
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 709fb3
Packit 709fb3
/* Written by Bruno Haible <bruno@clisp.org>, 2010.  */
Packit 709fb3
Packit 709fb3
#include <config.h>
Packit 709fb3
Packit 709fb3
#include "strerror-override.h"
Packit 709fb3
Packit 709fb3
#include <errno.h>
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EWINSOCK /* native Windows platforms */
Packit 709fb3
# if HAVE_WINSOCK2_H
Packit 709fb3
#  include <winsock2.h>
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
/* If ERRNUM maps to an errno value defined by gnulib, return a string
Packit 709fb3
   describing the error.  Otherwise return NULL.  */
Packit 709fb3
const char *
Packit 709fb3
strerror_override (int errnum)
Packit 709fb3
{
Packit 709fb3
  /* These error messages are taken from glibc/sysdeps/gnu/errlist.c.  */
Packit 709fb3
  switch (errnum)
Packit 709fb3
    {
Packit 709fb3
#if REPLACE_STRERROR_0
Packit 709fb3
    case 0:
Packit 709fb3
      return "Success";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
Packit 709fb3
    case EINPROGRESS:
Packit 709fb3
      return "Operation now in progress";
Packit 709fb3
    case EALREADY:
Packit 709fb3
      return "Operation already in progress";
Packit 709fb3
    case ENOTSOCK:
Packit 709fb3
      return "Socket operation on non-socket";
Packit 709fb3
    case EDESTADDRREQ:
Packit 709fb3
      return "Destination address required";
Packit 709fb3
    case EMSGSIZE:
Packit 709fb3
      return "Message too long";
Packit 709fb3
    case EPROTOTYPE:
Packit 709fb3
      return "Protocol wrong type for socket";
Packit 709fb3
    case ENOPROTOOPT:
Packit 709fb3
      return "Protocol not available";
Packit 709fb3
    case EPROTONOSUPPORT:
Packit 709fb3
      return "Protocol not supported";
Packit 709fb3
    case EOPNOTSUPP:
Packit 709fb3
      return "Operation not supported";
Packit 709fb3
    case EAFNOSUPPORT:
Packit 709fb3
      return "Address family not supported by protocol";
Packit 709fb3
    case EADDRINUSE:
Packit 709fb3
      return "Address already in use";
Packit 709fb3
    case EADDRNOTAVAIL:
Packit 709fb3
      return "Cannot assign requested address";
Packit 709fb3
    case ENETDOWN:
Packit 709fb3
      return "Network is down";
Packit 709fb3
    case ENETUNREACH:
Packit 709fb3
      return "Network is unreachable";
Packit 709fb3
    case ECONNRESET:
Packit 709fb3
      return "Connection reset by peer";
Packit 709fb3
    case ENOBUFS:
Packit 709fb3
      return "No buffer space available";
Packit 709fb3
    case EISCONN:
Packit 709fb3
      return "Transport endpoint is already connected";
Packit 709fb3
    case ENOTCONN:
Packit 709fb3
      return "Transport endpoint is not connected";
Packit 709fb3
    case ETIMEDOUT:
Packit 709fb3
      return "Connection timed out";
Packit 709fb3
    case ECONNREFUSED:
Packit 709fb3
      return "Connection refused";
Packit 709fb3
    case ELOOP:
Packit 709fb3
      return "Too many levels of symbolic links";
Packit 709fb3
    case EHOSTUNREACH:
Packit 709fb3
      return "No route to host";
Packit 709fb3
    case EWOULDBLOCK:
Packit 709fb3
      return "Operation would block";
Packit 709fb3
#endif
Packit 709fb3
#if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
Packit 709fb3
    case ETXTBSY:
Packit 709fb3
      return "Text file busy";
Packit 709fb3
    case ENODATA:
Packit 709fb3
      return "No data available";
Packit 709fb3
    case ENOSR:
Packit 709fb3
      return "Out of streams resources";
Packit 709fb3
    case ENOSTR:
Packit 709fb3
      return "Device not a stream";
Packit 709fb3
    case ETIME:
Packit 709fb3
      return "Timer expired";
Packit 709fb3
    case EOTHER:
Packit 709fb3
      return "Other error";
Packit 709fb3
#endif
Packit 709fb3
#if GNULIB_defined_EWINSOCK /* native Windows platforms */
Packit 709fb3
    case ESOCKTNOSUPPORT:
Packit 709fb3
      return "Socket type not supported";
Packit 709fb3
    case EPFNOSUPPORT:
Packit 709fb3
      return "Protocol family not supported";
Packit 709fb3
    case ESHUTDOWN:
Packit 709fb3
      return "Cannot send after transport endpoint shutdown";
Packit 709fb3
    case ETOOMANYREFS:
Packit 709fb3
      return "Too many references: cannot splice";
Packit 709fb3
    case EHOSTDOWN:
Packit 709fb3
      return "Host is down";
Packit 709fb3
    case EPROCLIM:
Packit 709fb3
      return "Too many processes";
Packit 709fb3
    case EUSERS:
Packit 709fb3
      return "Too many users";
Packit 709fb3
    case EDQUOT:
Packit 709fb3
      return "Disk quota exceeded";
Packit 709fb3
    case ESTALE:
Packit 709fb3
      return "Stale NFS file handle";
Packit 709fb3
    case EREMOTE:
Packit 709fb3
      return "Object is remote";
Packit 709fb3
# if HAVE_WINSOCK2_H
Packit 709fb3
      /* WSA_INVALID_HANDLE maps to EBADF */
Packit 709fb3
      /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
Packit 709fb3
      /* WSA_INVALID_PARAMETER maps to EINVAL */
Packit 709fb3
    case WSA_OPERATION_ABORTED:
Packit 709fb3
      return "Overlapped operation aborted";
Packit 709fb3
    case WSA_IO_INCOMPLETE:
Packit 709fb3
      return "Overlapped I/O event object not in signaled state";
Packit 709fb3
    case WSA_IO_PENDING:
Packit 709fb3
      return "Overlapped operations will complete later";
Packit 709fb3
      /* WSAEINTR maps to EINTR */
Packit 709fb3
      /* WSAEBADF maps to EBADF */
Packit 709fb3
      /* WSAEACCES maps to EACCES */
Packit 709fb3
      /* WSAEFAULT maps to EFAULT */
Packit 709fb3
      /* WSAEINVAL maps to EINVAL */
Packit 709fb3
      /* WSAEMFILE maps to EMFILE */
Packit 709fb3
      /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
Packit 709fb3
      /* WSAEINPROGRESS maps to EINPROGRESS */
Packit 709fb3
      /* WSAEALREADY maps to EALREADY */
Packit 709fb3
      /* WSAENOTSOCK maps to ENOTSOCK */
Packit 709fb3
      /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
Packit 709fb3
      /* WSAEMSGSIZE maps to EMSGSIZE */
Packit 709fb3
      /* WSAEPROTOTYPE maps to EPROTOTYPE */
Packit 709fb3
      /* WSAENOPROTOOPT maps to ENOPROTOOPT */
Packit 709fb3
      /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
Packit 709fb3
      /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
Packit 709fb3
      /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
Packit 709fb3
      /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
Packit 709fb3
      /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
Packit 709fb3
      /* WSAEADDRINUSE maps to EADDRINUSE */
Packit 709fb3
      /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
Packit 709fb3
      /* WSAENETDOWN maps to ENETDOWN */
Packit 709fb3
      /* WSAENETUNREACH maps to ENETUNREACH */
Packit 709fb3
      /* WSAENETRESET maps to ENETRESET */
Packit 709fb3
      /* WSAECONNABORTED maps to ECONNABORTED */
Packit 709fb3
      /* WSAECONNRESET maps to ECONNRESET */
Packit 709fb3
      /* WSAENOBUFS maps to ENOBUFS */
Packit 709fb3
      /* WSAEISCONN maps to EISCONN */
Packit 709fb3
      /* WSAENOTCONN maps to ENOTCONN */
Packit 709fb3
      /* WSAESHUTDOWN is ESHUTDOWN */
Packit 709fb3
      /* WSAETOOMANYREFS is ETOOMANYREFS */
Packit 709fb3
      /* WSAETIMEDOUT maps to ETIMEDOUT */
Packit 709fb3
      /* WSAECONNREFUSED maps to ECONNREFUSED */
Packit 709fb3
      /* WSAELOOP maps to ELOOP */
Packit 709fb3
      /* WSAENAMETOOLONG maps to ENAMETOOLONG */
Packit 709fb3
      /* WSAEHOSTDOWN is EHOSTDOWN */
Packit 709fb3
      /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
Packit 709fb3
      /* WSAENOTEMPTY maps to ENOTEMPTY */
Packit 709fb3
      /* WSAEPROCLIM is EPROCLIM */
Packit 709fb3
      /* WSAEUSERS is EUSERS */
Packit 709fb3
      /* WSAEDQUOT is EDQUOT */
Packit 709fb3
      /* WSAESTALE is ESTALE */
Packit 709fb3
      /* WSAEREMOTE is EREMOTE */
Packit 709fb3
    case WSASYSNOTREADY:
Packit 709fb3
      return "Network subsystem is unavailable";
Packit 709fb3
    case WSAVERNOTSUPPORTED:
Packit 709fb3
      return "Winsock.dll version out of range";
Packit 709fb3
    case WSANOTINITIALISED:
Packit 709fb3
      return "Successful WSAStartup not yet performed";
Packit 709fb3
    case WSAEDISCON:
Packit 709fb3
      return "Graceful shutdown in progress";
Packit 709fb3
    case WSAENOMORE: case WSA_E_NO_MORE:
Packit 709fb3
      return "No more results";
Packit 709fb3
    case WSAECANCELLED: case WSA_E_CANCELLED:
Packit 709fb3
      return "Call was canceled";
Packit 709fb3
    case WSAEINVALIDPROCTABLE:
Packit 709fb3
      return "Procedure call table is invalid";
Packit 709fb3
    case WSAEINVALIDPROVIDER:
Packit 709fb3
      return "Service provider is invalid";
Packit 709fb3
    case WSAEPROVIDERFAILEDINIT:
Packit 709fb3
      return "Service provider failed to initialize";
Packit 709fb3
    case WSASYSCALLFAILURE:
Packit 709fb3
      return "System call failure";
Packit 709fb3
    case WSASERVICE_NOT_FOUND:
Packit 709fb3
      return "Service not found";
Packit 709fb3
    case WSATYPE_NOT_FOUND:
Packit 709fb3
      return "Class type not found";
Packit 709fb3
    case WSAEREFUSED:
Packit 709fb3
      return "Database query was refused";
Packit 709fb3
    case WSAHOST_NOT_FOUND:
Packit 709fb3
      return "Host not found";
Packit 709fb3
    case WSATRY_AGAIN:
Packit 709fb3
      return "Nonauthoritative host not found";
Packit 709fb3
    case WSANO_RECOVERY:
Packit 709fb3
      return "Nonrecoverable error";
Packit 709fb3
    case WSANO_DATA:
Packit 709fb3
      return "Valid name, no data record of requested type";
Packit 709fb3
      /* WSA_QOS_* omitted */
Packit 709fb3
# endif
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ENOMSG
Packit 709fb3
    case ENOMSG:
Packit 709fb3
      return "No message of desired type";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EIDRM
Packit 709fb3
    case EIDRM:
Packit 709fb3
      return "Identifier removed";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ENOLINK
Packit 709fb3
    case ENOLINK:
Packit 709fb3
      return "Link has been severed";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EPROTO
Packit 709fb3
    case EPROTO:
Packit 709fb3
      return "Protocol error";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EMULTIHOP
Packit 709fb3
    case EMULTIHOP:
Packit 709fb3
      return "Multihop attempted";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EBADMSG
Packit 709fb3
    case EBADMSG:
Packit 709fb3
      return "Bad message";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EOVERFLOW
Packit 709fb3
    case EOVERFLOW:
Packit 709fb3
      return "Value too large for defined data type";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ENOTSUP
Packit 709fb3
    case ENOTSUP:
Packit 709fb3
      return "Not supported";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ENETRESET
Packit 709fb3
    case ENETRESET:
Packit 709fb3
      return "Network dropped connection on reset";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ECONNABORTED
Packit 709fb3
    case ECONNABORTED:
Packit 709fb3
      return "Software caused connection abort";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ESTALE
Packit 709fb3
    case ESTALE:
Packit 709fb3
      return "Stale NFS file handle";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EDQUOT
Packit 709fb3
    case EDQUOT:
Packit 709fb3
      return "Disk quota exceeded";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ECANCELED
Packit 709fb3
    case ECANCELED:
Packit 709fb3
      return "Operation canceled";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EOWNERDEAD
Packit 709fb3
    case EOWNERDEAD:
Packit 709fb3
      return "Owner died";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_ENOTRECOVERABLE
Packit 709fb3
    case ENOTRECOVERABLE:
Packit 709fb3
      return "State not recoverable";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
#if GNULIB_defined_EILSEQ
Packit 709fb3
    case EILSEQ:
Packit 709fb3
      return "Invalid or incomplete multibyte or wide character";
Packit 709fb3
#endif
Packit 709fb3
Packit 709fb3
    default:
Packit 709fb3
      return NULL;
Packit 709fb3
    }
Packit 709fb3
}