2012-09-22 10:44:50 -04:00
|
|
|
/*******************************************************************************
|
2011-08-05 08:25:00 -04:00
|
|
|
|
2013-03-19 17:39:32 -04:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
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-07-10 09:26:01 -04:00
|
|
|
strerror.cpp
|
|
|
|
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";
|
|
|
|
case EILSEQ: return "Illegal byte sequence";
|
|
|
|
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";
|
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);
|
|
|
|
}
|