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 ENOSYS: return "Invalid instruction/syscall";
25 case EINVAL: return "Bad argument(s)";
26 case EBADF: return "Invalid file";
27 case ENOMEM: return "No free memory";
28 case EACCES: return "Not permitted";
29 case EBUSY: return "Resource is busy";
30 case ERANGE: return "Value out of range";
31 case ENOTFOUND: return "Item not found";
32 case EROFS: return "Read only filesystem";
33 case ENOTIMPL: return "Not implimented";
34 case ENOENT: return "No such file or directory";
35 case EEXIST: return "Already exists";
36 case ENFILE: return "Too many open files";
37 case ENOTDIR: return "Not a directory";
38 case EISDIR: return "Is a directory";
39 case EIO: return "IO Error";
40 case EINTR: return "Interrupted";
41 case EWOULDBLOCK: return "Operation would have blocked";
42 case ENODEV: return "No such device";
43 case EADDRNOTAVAIL: return "Address not avaliable";
44 case EINPROGRESS: return "Operation in process";
45 case EPERM: return "Operation not permitted";
46 case ENOTTY: return "Not a TTY";
47 case EAGAIN: return "Try again";
48 case EALREADY: return "Operation was no-op";
49 case EINTERNAL: return "Internal error";
51 _SysDebug("strerror: errnum=%i unk", errnum);
53 return "unknown error";
56 EXPORT int strerror_r(int errnum, char *buf, size_t bufsiz)
58 const char *str = strerror(errnum);
62 strncpy(buf, str, bufsiz);
67 EXPORT void perror(const char *s)
71 fprintf(stderr, "%s: (%i) %s\n", s, err, strerror(err));
74 fprintf(stderr, "(%i) %s\n", err, strerror(err));
76 _SysDebug("perror('%s'): %s (%i)", s, strerror(err), err);