2012-09-22 10:44:50 -04:00
|
|
|
/*******************************************************************************
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2014-08-18 13:17:11 -04:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
This file is part of the Sortix C Library.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
The Sortix C Library is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
The Sortix C Library is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-06-12 07:35:22 -04:00
|
|
|
string/strerror.cpp
|
2013-07-10 09:26:01 -04:00
|
|
|
Convert error code to a string.
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-05-27 11:38:00 -04:00
|
|
|
*******************************************************************************/
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2012-05-27 11:38:00 -04:00
|
|
|
#define __SORTIX_STDLIB_REDIRECTS 0
|
2012-09-22 10:44:50 -04:00
|
|
|
#include <errno.h>
|
2012-09-26 11:56:39 -04:00
|
|
|
#include <string.h>
|
2012-03-26 16:22:59 -04:00
|
|
|
|
2012-05-27 11:38:00 -04:00
|
|
|
extern "C" const char* sortix_strerror(int errnum)
|
|
|
|
{
|
|
|
|
switch ( errnum )
|
|
|
|
{
|
|
|
|
case ENOTBLK: return "Block device required";
|
|
|
|
case ENODEV: return "No such device";
|
|
|
|
case EWOULDBLOCK: return "Operation would block";
|
|
|
|
case EBADF: return "Bad file descriptor";
|
|
|
|
case EOVERFLOW: return "Value too large to be stored in data type";
|
|
|
|
case ENOENT: return "No such file or directory";
|
|
|
|
case ENOSPC: return "No space left on device";
|
|
|
|
case EEXIST: return "File exists";
|
|
|
|
case EROFS: return "Read-only file system";
|
|
|
|
case EINVAL: return "Invalid argument";
|
|
|
|
case ENOTDIR: return "Not a directory";
|
|
|
|
case ENOMEM: return "Not enough memory";
|
|
|
|
case ERANGE: return "Result too large";
|
|
|
|
case EISDIR: return "Is a directory";
|
|
|
|
case EPERM: return "Operation not permitted";
|
|
|
|
case EIO: return "Input/output error";
|
|
|
|
case ENOEXEC: return "Exec format error";
|
|
|
|
case EACCES: return "Permission denied";
|
|
|
|
case ESRCH: return "No such process";
|
|
|
|
case ENOTTY: return "Not a tty";
|
|
|
|
case ECHILD: return "No child processes";
|
|
|
|
case ENOSYS: return "Function not implemented";
|
|
|
|
case ENOTSUP: return "Operation not supported";
|
|
|
|
case EBLOCKING: return "Operation is blocking";
|
|
|
|
case EINTR: return "Interrupted function call";
|
|
|
|
case ENOTEMPTY: return "Directory not empty";
|
|
|
|
case EBUSY: return "Device or resource busy";
|
|
|
|
case EPIPE: return "Broken pipe";
|
2014-08-03 07:40:35 -04:00
|
|
|
case EILSEQ: return "Invalid byte sequence";
|
2012-05-27 11:38:00 -04:00
|
|
|
case ELAKE: return "Sit by a lake";
|
|
|
|
case EMFILE: return "Too many open files";
|
|
|
|
case EAGAIN: return "Resource temporarily unavailable";
|
|
|
|
case EEOF: return "End of file";
|
|
|
|
case EBOUND: return "Out of bounds";
|
|
|
|
case EINIT: return "Not initialized";
|
2012-09-07 14:25:10 -04:00
|
|
|
case ENODRV: return "No such driver";
|
|
|
|
case E2BIG: return "Argument list too long";
|
2013-01-29 16:33:57 -05:00
|
|
|
case EFBIG: return "File too large";
|
2013-01-29 16:34:23 -05:00
|
|
|
case EXDEV: return "Improper link";
|
2013-01-29 16:34:54 -05:00
|
|
|
case ESPIPE: return "Cannot seek on stream";
|
2013-01-05 09:06:22 -05:00
|
|
|
case ENAMETOOLONG: return "Filename too long";
|
2013-01-05 09:07:35 -05:00
|
|
|
case ELOOP: return "Too many levels of symbolic links";
|
2012-12-19 20:01:29 -05:00
|
|
|
case EMLINK: return "Too many links";
|
2012-12-20 16:48:14 -05:00
|
|
|
case ENXIO: return "No such device or address";
|
2013-03-19 17:39:32 -04:00
|
|
|
case EPROTONOSUPPORT: return "Protocol not supported";
|
2013-03-19 17:39:41 -04:00
|
|
|
case EAFNOSUPPORT: return "Address family not supported";
|
2013-03-19 17:40:14 -04:00
|
|
|
case ENOTSOCK: return "Not a socket";
|
2013-02-23 08:56:34 -05:00
|
|
|
case EADDRINUSE: return "Address already in use";
|
2013-03-08 17:49:41 -05:00
|
|
|
case ETIMEDOUT: return "Connection timed out";
|
2013-03-08 17:50:26 -05:00
|
|
|
case ECONNREFUSED: return "Connection refused";
|
2013-03-22 20:35:17 -04:00
|
|
|
case EDOM: return "Mathematics argument out of domain of function";
|
2013-03-22 21:04:02 -04:00
|
|
|
case EINPROGRESS: return "Operation in progress";
|
2013-03-23 18:01:38 -04:00
|
|
|
case EALREADY: return "Connection already in progress";
|
2013-03-23 18:02:25 -04:00
|
|
|
case ESHUTDOWN: return "Cannot send after transport endpoint shutdown";
|
2013-03-23 18:03:08 -04:00
|
|
|
case ECONNABORTED: return "Connection aborted";
|
2013-03-23 18:03:53 -04:00
|
|
|
case ECONNRESET: return "Connection reset";
|
2013-04-21 17:05:43 -04:00
|
|
|
case EADDRNOTAVAIL: return "Address not available";
|
2013-04-21 17:06:13 -04:00
|
|
|
case EISCONN: return "Socket is connected";
|
2013-04-21 17:07:31 -04:00
|
|
|
case EFAULT: return "Bad address";
|
2013-04-21 17:10:24 -04:00
|
|
|
case EDESTADDRREQ: return "Destinatiohn address required";
|
2013-04-21 17:11:09 -04:00
|
|
|
case EHOSTUNREACH: return "Host is unreachable";
|
2013-04-21 17:12:04 -04:00
|
|
|
case EMSGSIZE: return "Message too long";
|
2013-04-21 17:12:43 -04:00
|
|
|
case ENETDOWN: return "Network is down";
|
2013-04-21 17:13:48 -04:00
|
|
|
case ENETRESET: return "Connection aborted by network";
|
2013-04-21 17:14:30 -04:00
|
|
|
case ENETUNREACH: return "Network is unreachable";
|
2013-04-21 17:15:20 -04:00
|
|
|
case ENOBUFS: return "No buffer space available";
|
2013-04-21 17:16:07 -04:00
|
|
|
case ENOMSG: return "No message of the desired type";
|
2013-04-21 17:16:57 -04:00
|
|
|
case ENOPROTOOPT: return "Protocol not available";
|
2013-04-21 17:17:28 -04:00
|
|
|
case ENOTCONN: return "Socket is not connected";
|
2013-04-21 17:19:39 -04:00
|
|
|
case EDEADLK: return "Resource deadlock avoided";
|
2013-04-21 17:20:34 -04:00
|
|
|
case ENFILE: return "Too many open files in system";
|
2013-04-21 17:23:24 -04:00
|
|
|
case EPROTOTYPE: return "Wrong protocol type for socket";
|
2013-04-21 18:39:03 -04:00
|
|
|
case ENOLCK: return "No locks available";
|
2013-10-02 17:54:13 -04:00
|
|
|
case ENOUSER: return "No such user";
|
2013-10-02 17:55:39 -04:00
|
|
|
case ENOGROUP: return "No such group";
|
2014-01-30 09:07:27 -05:00
|
|
|
case ESIGPENDING: return "Signal is already pending";
|
2014-06-23 13:06:43 -04:00
|
|
|
case ESTALE: return "Stale file handle";
|
2014-08-18 13:17:11 -04:00
|
|
|
case EBADMSG: return "Bad message";
|
|
|
|
case ECANCELED: return "Operation canceled";
|
|
|
|
case EDQUOT: return "Disk quota exceeded";
|
|
|
|
case EIDRM: return "Identifier removed";
|
|
|
|
case EMULTIHOP: return "Multihop attempted";
|
|
|
|
case ENOLINK: return "Link has been severed";
|
|
|
|
case ENOTRECOVERABLE: return "State not recoverable";
|
|
|
|
case EOWNERDEAD: return "Previous owner died";
|
|
|
|
case EPROTO: return "Protocol error";
|
|
|
|
case ETXTBSY: return "Text file busy";
|
2012-05-27 11:38:00 -04:00
|
|
|
default: return "Unknown error condition";
|
2011-08-05 08:25:00 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-27 11:38:00 -04:00
|
|
|
extern "C" char* strerror(int errnum)
|
|
|
|
{
|
|
|
|
return (char*) sortix_strerror(errnum);
|
|
|
|
}
|