diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-03-31 18:52:45 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-03-31 18:52:45 +0200 |
commit | b6dc4ba5a44a2ed2a68266598ceb28b7a7d51af2 (patch) | |
tree | b2af773db48a3606bd078055db925dbba6d4ffaa /sys/src/ape/lib/bsd/gai_strerror.c | |
parent | 9c7e1db701e0e80b42bb5990e2f6839d712bb984 (diff) |
ape: initial IPv6 support, inet_pton()/inet_ntop(), getaddrinfo()/getnameinfo()
Diffstat (limited to 'sys/src/ape/lib/bsd/gai_strerror.c')
-rw-r--r-- | sys/src/ape/lib/bsd/gai_strerror.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/src/ape/lib/bsd/gai_strerror.c b/sys/src/ape/lib/bsd/gai_strerror.c new file mode 100644 index 000000000..bcb1f8e70 --- /dev/null +++ b/sys/src/ape/lib/bsd/gai_strerror.c @@ -0,0 +1,34 @@ +/* posix */ +#include <sys/types.h> +#include <unistd.h> + +/* bsd extensions */ +#include <sys/uio.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netdb.h> + +char* +gai_strerror(int err) +{ + static char *tab[] = { + /* 0 */ "No error", + /* EAI_BADFLAGS */ "Invalid value for `ai_flags' field", + /* EAI_NONAME */ "NAME or SERVICE is unknown", + /* EAI_AGAIN */ "Temporary failure in name resolution", + /* EAI_FAIL */ "Non-recoverable failure in name resolution", + /* EAI_NODATA */ "No address associated with NAME", + /* EAI_FAMILY */ "`ai_family' not supported", + /* EAI_SOCKTYPE */ "`ai_socktype' not supported", + /* EAI_SERVICE */ "SERVICE not supported for `ai_socktype'", + /* EAI_ADDRFAMILY */ "Address family for NAME not supported", + /* EAI_MEMORY */ "Memory allocation failure", + /* EAI_SYSTEM */ "System error returned in `errno'", + /* EAI_OVERFLOW */ "Argument buffer overflow", + }; + + err = -err; + if(err < 0 || err >= (sizeof(tab)/sizeof(tab[0]))) + return "Unknown error"; + return tab[err]; +} |