Blame lib/strerror-override.c

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