Files
rosetta/lib/libc/core/string/strerror.c

343 lines
7.9 KiB
C
Raw Normal View History

#include <errno.h>
const char *strerror(int errnum)
{
switch (errnum) {
case SUCCESS:
return "Success";
case EPERM:
return "Operation not permitted";
case ENOENT:
return "No such file or directory";
case ESRCH:
return "No such process";
case EINTR:
return "Interrupted system call";
case EIO:
return "Input/output error";
case ENXIO:
return "Device not configured";
case E2BIG:
return "Argument list too long";
case ENOEXEC:
return "Exec format error";
case EBADF:
return "Bad file descriptor";
case ECHILD:
return "No child processes";
case EDEADLK:
return "Resource deadlock avoided";
case ENOMEM:
return "Cannot allocate memory";
case EACCES:
return "Permission denied";
case EFAULT:
return "Bad address";
case ENOTBLK:
return "Block device required";
case EBUSY:
return "Resource busy";
case EEXIST:
return "File exists";
case EXDEV:
return "Cross-device link";
case ENODEV:
return "Operation not supported by device";
case ENOTDIR:
return "Not a directory";
case EISDIR:
return "Is a directory";
case EINVAL:
return "Invalid argument";
case ENFILE:
return "Too many open files in system";
case EMFILE:
return "Too many open files";
case ENOTTY:
return "Inappropriate ioctl for device";
case ETXTBSY:
return "Text file busy";
case EFBIG:
return "File too large";
case ENOSPC:
return "No space left on device";
case ESPIPE:
return "Illegal seek";
case EROFS:
return "Read-only file system";
case EMLINK:
return "Too many links";
case EPIPE:
return "Broken pipe";
case EDOM:
return "Numerical argument out of domain";
case ERANGE:
return "Result too large";
case EAGAIN:
return "Resource temporarily unavailable";
case EINPROGRESS:
return "Operation now in progress";
case EALREADY:
return "Operation already in progress";
case ENOTSOCK:
return "Socket operation on non-socket";
case EDESTADDRREQ:
return "Destination address required";
case EMSGSIZE:
return "Message too long";
case EPROTOTYPE:
return "Protocol wrong type for socket";
case ENOPROTOOPT:
return "Protocol not available";
case EPROTONOSUPPORT:
return "Protocol not supported";
case ESOCKTNOSUPPORT:
return "Socket type not supported";
case ENOTSUP:
return "Operation not supported";
case EPFNOSUPPORT:
return "Protocol family not supported";
case EAFNOSUPPORT:
return "Address family not supported by protocol family";
case EADDRINUSE:
return "Address already in use";
case EADDRNOTAVAIL:
return "Can't assign requested address";
case ENETDOWN:
return "Network is down";
case ENETUNREACH:
return "Network is unreachable";
case ENETRESET:
return "Network dropped connection on reset";
case ECONNABORTED:
return "Software caused connection abort";
case ECONNRESET:
return "Connection reset by peer";
case ENOBUFS:
return "No buffer space available";
case EISCONN:
return "Socket is already connected";
case ENOTCONN:
return "Socket is not connected";
case ESHUTDOWN:
return "Can't send after socket shutdown";
case ETOOMANYREFS:
return "Too many references: can't splice";
case ETIMEDOUT:
return "Operation timed out";
case ECONNREFUSED:
return "Connection refused";
case ELOOP:
return "Too many levels of symbolic links";
case ENAMETOOLONG:
return "File name too long";
case EHOSTDOWN:
return "Host is down";
case EHOSTUNREACH:
return "No route to host";
case ENOTEMPTY:
return "Directory not empty";
case EPROCLIM:
return "Too many processes";
case EUSERS:
return "Too many users";
case EDQUOT:
return "Disc quota exceeded";
case ESTALE:
return "Stale NFS file handle";
case EREMOTE:
return "Too many levels of remote in path";
case EBADRPC:
return "RPC struct is bad";
case ERPCMISMATCH:
return "RPC version wrong";
case EPROGUNAVAIL:
return "RPC prog. not avail";
case EPROGMISMATCH:
return "Program version wrong";
case EPROCUNAVAIL:
return "Bad procedure for program";
case ENOLCK:
return "No locks available";
case ENOSYS:
return "Function not implemented";
case EFTYPE:
return "Inappropriate file type or format";
case EAUTH:
return "Authentication error";
case ENEEDAUTH:
return "Need authenticator";
case EPWROFF:
return "Device power is off";
case EDEVERR:
return "Device error";
case EOVERFLOW:
return "Value too large to be stored in data type";
case EBADEXEC:
return "Bad executable (or shared library)";
case EBADARCH:
return "Bad CPU type in executable";
case ESHLIBVERS:
return "Shared library version mismatch";
case EBADMACHO:
return "Malformed Mach-o file";
case ECANCELED:
return "Operation canceled";
case EIDRM:
return "Identifier removed";
case ENOMSG:
return "No message of desired type";
case EILSEQ:
return "Illegal byte sequence";
case ENOATTR:
return "Attribute not found";
case EBADMSG:
return "Bad message";
case EMULTIHOP:
return "EMULTIHOP (Reserved)";
case ENODATA:
return "No message available on STREAM";
case ENOLINK:
return "ENOLINK (Reserved)";
case ENOSR:
return "No STREAM resources";
case ENOSTR:
return "Not a STREAM";
case EPROTO:
return "Protocol error";
case ETIME:
return "STREAM ioctl timeout";
case EOPNOTSUPP:
return "Operation not supported on socket";
case ENOPOLICY:
return "Policy not found";
case ENOTRECOVERABLE:
return "State not recoverable";
case EOWNERDEAD:
return "Previous owner died";
case EQFULL:
return "Interface output queue is full";
default:
return "Unknown error";
}
}
#define ENUM_STR(x) \
case x: \
return #x
const char *strerror_code(int errnum)
{
switch (errnum) {
ENUM_STR(SUCCESS);
ENUM_STR(EPERM);
ENUM_STR(ENOENT);
ENUM_STR(ESRCH);
ENUM_STR(EINTR);
ENUM_STR(EIO);
ENUM_STR(ENXIO);
ENUM_STR(E2BIG);
ENUM_STR(ENOEXEC);
ENUM_STR(EBADF);
ENUM_STR(ECHILD);
ENUM_STR(EDEADLK);
ENUM_STR(ENOMEM);
ENUM_STR(EACCES);
ENUM_STR(EFAULT);
ENUM_STR(ENOTBLK);
ENUM_STR(EBUSY);
ENUM_STR(EEXIST);
ENUM_STR(EXDEV);
ENUM_STR(ENODEV);
ENUM_STR(ENOTDIR);
ENUM_STR(EISDIR);
ENUM_STR(EINVAL);
ENUM_STR(ENFILE);
ENUM_STR(EMFILE);
ENUM_STR(ENOTTY);
ENUM_STR(ETXTBSY);
ENUM_STR(EFBIG);
ENUM_STR(ENOSPC);
ENUM_STR(ESPIPE);
ENUM_STR(EROFS);
ENUM_STR(EMLINK);
ENUM_STR(EPIPE);
ENUM_STR(EDOM);
ENUM_STR(ERANGE);
ENUM_STR(EAGAIN);
ENUM_STR(EINPROGRESS);
ENUM_STR(EALREADY);
ENUM_STR(ENOTSOCK);
ENUM_STR(EDESTADDRREQ);
ENUM_STR(EMSGSIZE);
ENUM_STR(EPROTOTYPE);
ENUM_STR(ENOPROTOOPT);
ENUM_STR(EPROTONOSUPPORT);
ENUM_STR(ESOCKTNOSUPPORT);
ENUM_STR(ENOTSUP);
ENUM_STR(EPFNOSUPPORT);
ENUM_STR(EAFNOSUPPORT);
ENUM_STR(EADDRINUSE);
ENUM_STR(EADDRNOTAVAIL);
ENUM_STR(ENETDOWN);
ENUM_STR(ENETUNREACH);
ENUM_STR(ENETRESET);
ENUM_STR(ECONNABORTED);
ENUM_STR(ECONNRESET);
ENUM_STR(ENOBUFS);
ENUM_STR(EISCONN);
ENUM_STR(ENOTCONN);
ENUM_STR(ESHUTDOWN);
ENUM_STR(ETOOMANYREFS);
ENUM_STR(ETIMEDOUT);
ENUM_STR(ECONNREFUSED);
ENUM_STR(ELOOP);
ENUM_STR(ENAMETOOLONG);
ENUM_STR(EHOSTDOWN);
ENUM_STR(EHOSTUNREACH);
ENUM_STR(ENOTEMPTY);
ENUM_STR(EPROCLIM);
ENUM_STR(EUSERS);
ENUM_STR(EDQUOT);
ENUM_STR(ESTALE);
ENUM_STR(EREMOTE);
ENUM_STR(EBADRPC);
ENUM_STR(ERPCMISMATCH);
ENUM_STR(EPROGUNAVAIL);
ENUM_STR(EPROGMISMATCH);
ENUM_STR(EPROCUNAVAIL);
ENUM_STR(ENOLCK);
ENUM_STR(ENOSYS);
ENUM_STR(EFTYPE);
ENUM_STR(EAUTH);
ENUM_STR(ENEEDAUTH);
ENUM_STR(EPWROFF);
ENUM_STR(EDEVERR);
ENUM_STR(EOVERFLOW);
ENUM_STR(EBADEXEC);
ENUM_STR(EBADARCH);
ENUM_STR(ESHLIBVERS);
ENUM_STR(EBADMACHO);
ENUM_STR(ECANCELED);
ENUM_STR(EIDRM);
ENUM_STR(ENOMSG);
ENUM_STR(EILSEQ);
ENUM_STR(ENOATTR);
ENUM_STR(EBADMSG);
ENUM_STR(EMULTIHOP);
ENUM_STR(ENODATA);
ENUM_STR(ENOLINK);
ENUM_STR(ENOSR);
ENUM_STR(ENOSTR);
ENUM_STR(EPROTO);
ENUM_STR(ETIME);
ENUM_STR(EOPNOTSUPP);
ENUM_STR(ENOPOLICY);
ENUM_STR(ENOTRECOVERABLE);
ENUM_STR(EOWNERDEAD);
ENUM_STR(EQFULL);
default:
return "";
}
}