mirror of
https://github.com/diegocr/libnix.git
synced 2026-09-11 19:25:43 +00:00
102 lines
2.6 KiB
Plaintext
102 lines
2.6 KiB
Plaintext
#include <stdlib.h>
|
|
|
|
static const char *sys_errlist[] = {
|
|
"Undefined error",
|
|
"Operation not permitted",
|
|
"No such file or directory",
|
|
"No such process",
|
|
"Interrupted system call",
|
|
"Input/output error",
|
|
"Device not configured",
|
|
"Argument list too long",
|
|
"Exec format error",
|
|
"Bad file descriptor",
|
|
"No child processes",
|
|
"Resource deadlock avoided",
|
|
"Cannot allocate memory",
|
|
"Permission denied",
|
|
"Bad address",
|
|
"Block device required",
|
|
"Device busy",
|
|
"File exists",
|
|
"Cross-device link",
|
|
"Operation not supported by device",
|
|
"Not a directory",
|
|
"Is a directory",
|
|
"Invalid argument",
|
|
"Too many open files in system",
|
|
"Too many open files",
|
|
"Inappropriate ioctl for device",
|
|
"Text file busy",
|
|
"File too large",
|
|
"No space left on device",
|
|
"Illegal seek",
|
|
"Read-only file system",
|
|
"Too many links",
|
|
"Broken pipe",
|
|
"Numerical argument out of domain",
|
|
"Result too large",
|
|
"Resource temporarily unavailable",
|
|
"Operation now in progress",
|
|
"Operation already in progress",
|
|
"Socket operation on non-socket",
|
|
"Destination address required",
|
|
"Message too long",
|
|
"Protocol wrong type for socket",
|
|
"Protocol not available",
|
|
"Protocol not supported",
|
|
"Socket type not supported",
|
|
"Operation not supported",
|
|
"Protocol family not supported",
|
|
"Address family not supported by protocol family",
|
|
"Address already in use",
|
|
"Can't assign requested address",
|
|
"Network is down",
|
|
"Network is unreachable",
|
|
"Network dropped connection on reset",
|
|
"Software caused connection abort",
|
|
"Connection reset by peer",
|
|
"No buffer space available",
|
|
"Socket is already connected",
|
|
"Socket is not connected",
|
|
"Can't send after socket shutdown",
|
|
"Too many references: can't splice",
|
|
"Connection timed out",
|
|
"Connection refused",
|
|
"Too many levels of symbolic links",
|
|
"File name too long",
|
|
"Host is down",
|
|
"No route to host",
|
|
"Directory not empty",
|
|
"Too many processes",
|
|
"Too many users",
|
|
"Disc quota exceeded",
|
|
"Stale NFS file handle",
|
|
"Too many levels of remote in path",
|
|
"RPC struct is bad",
|
|
"RPC version wrong",
|
|
"RPC prog. not avail",
|
|
"Program version wrong",
|
|
"Bad procedure for program",
|
|
"No locks available",
|
|
"Function not implemented",
|
|
"Inappropriate file type or format"
|
|
};
|
|
|
|
static const int sys_nerr=sizeof(sys_errlist)/sizeof(sys_errlist[0]);
|
|
|
|
char *strerror(int errno)
|
|
{ if(errno<0||errno>=sys_nerr)
|
|
errno=0;
|
|
return(char *)sys_errlist[errno];
|
|
}
|
|
|
|
char *strerror_r(int errno,char *buffer,size_t buflen)
|
|
{ char *b=buffer,*ptr=strerror(errno);
|
|
while(buflen-- > 1)
|
|
{ if(!(*b++ = *ptr++))
|
|
break;
|
|
} *b = '\0';
|
|
return buffer;
|
|
}
|