From 9501c3f45b9b5d3b2cef5e78c83c362dbe6295a5 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Mon, 16 Dec 2024 20:26:20 +0100 Subject: libc: Add gai_strerror --- userland/libc/netdb/gai_strerror.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 userland/libc/netdb/gai_strerror.c (limited to 'userland/libc/netdb/gai_strerror.c') diff --git a/userland/libc/netdb/gai_strerror.c b/userland/libc/netdb/gai_strerror.c new file mode 100644 index 0000000..81457cb --- /dev/null +++ b/userland/libc/netdb/gai_strerror.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include + +const char *gai_strerror(int errcode) { + switch (errcode) { + case EAI_AGAIN: + return "The name could not be resolved at this time. Future attempts may " + "succeed."; + case EAI_BADFLAGS: + return "The flags had an invalid value."; + case EAI_FAIL: + return "A non-recoverable error occurred."; + case EAI_FAMILY: + return "The address family was not recognized or the address length was " + "invalid for the specified family."; + case EAI_MEMORY: + return "There was a memory allocation failure."; + case EAI_NONAME: + return "The name does not resolve for the supplied parameters. NI_NAMEREQD " + "is set and the host's name cannot be located, or both nodename and " + "servname were null."; + case EAI_SERVICE: + return "The service passed was not recognized for the specified socket " + "type."; + case EAI_SOCKTYPE: + return "The intended socket type was not recognized."; + case EAI_SYSTEM: + return "A system error occurred. The error code can be found in errno."; + case EAI_OVERFLOW: + return "An argument buffer overflowed."; + default: + return "Invalid gai error code, no error string found."; + } +} -- cgit v1.2.3