3 * - By John Hodge (thePowersGang)
11 #include <acess/sys.h>
14 EXPORT int *libc_geterrno()
19 EXPORT char *strerror(int errnum)
21 switch((enum libc_eErrorNumbers)errnum)
23 case EOK: return "Success";
24 case ERANGE: return "Value out of range";
25 case EDOM: return "Value out of domain";
26 case EILSEQ: return "Illegal character sequence";
28 case ENOSYS: return "Invalid instruction/syscall";
29 case EINVAL: return "Bad argument(s)";
30 case EBADF: return "Invalid file";
31 case ENOMEM: return "No free memory";
32 case EACCES: return "Not permitted";
33 case EBUSY: return "Resource is busy";
34 case ENOTFOUND: return "Item not found";
35 case EROFS: return "Read only filesystem";
36 case ENOTIMPL: return "Not implimented";
37 case ENOENT: return "No such file or directory";
38 case EEXIST: return "Already exists";
39 case ENFILE: return "Too many open files";
40 case ENOTDIR: return "Not a directory";
41 case EISDIR: return "Is a directory";
42 case EIO: return "IO Error";
43 case EINTR: return "Interrupted";
44 case EWOULDBLOCK: return "Operation would have blocked";
45 case ENODEV: return "No such device";
46 case EADDRNOTAVAIL: return "Address not avaliable";
47 case EINPROGRESS: return "Operation in process";
48 case EPERM: return "Operation not permitted";
49 case ENOTTY: return "Not a TTY";
50 case EAGAIN: return "Try again";
51 case EFBIG: return "File too big";
52 case E2BIG: return "Value too big";
53 case EALREADY: return "Operation was no-op";
54 case ENOSPC: return "No space left on the device";
56 case EAFNOSUPPORT: return "Address family not supported";
57 case EADDRINUSE: return "Address already in use";
58 case ETIMEDOUT: return "Operation timed out";
60 case EINTERNAL: return "Internal error";
62 _SysDebug("strerror: errnum=%i unk", errnum);
64 return "unknown error";
67 EXPORT int strerror_r(int errnum, char *buf, size_t bufsiz)
69 const char *str = strerror(errnum);
73 strncpy(buf, str, bufsiz);
78 EXPORT void perror(const char *s)
82 fprintf(stderr, "%s: (%i) %s\n", s, err, strerror(err));
85 fprintf(stderr, "(%i) %s\n", err, strerror(err));
87 _SysDebug("perror('%s'): %s (%i)", s, strerror(err), err);