mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibC: Add herror() and hstrerror()
This commit is contained in:
parent
bc18fa75ec
commit
6a7d3006d7
Notes:
sideshowbarker
2024-07-17 11:59:39 +09:00
Author: https://github.com/cocateh
Commit: 6a7d3006d7
Pull-request: https://github.com/SerenityOS/serenity/pull/14001
Reviewed-by: https://github.com/Lubrsi
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 26 additions and 0 deletions
|
@ -829,4 +829,26 @@ int getnameinfo(const struct sockaddr* __restrict addr, socklen_t addrlen, char*
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void herror(char const* s)
|
||||
{
|
||||
dbgln("herror(): {}: {}", s, hstrerror(h_errno));
|
||||
warnln("{}: {}", s, hstrerror(h_errno));
|
||||
}
|
||||
|
||||
char const* hstrerror(int err)
|
||||
{
|
||||
switch (err) {
|
||||
case HOST_NOT_FOUND:
|
||||
return "The specified host is unknown.";
|
||||
case NO_DATA:
|
||||
return "The requested name is valid but does not have an IP address.";
|
||||
case NO_RECOVERY:
|
||||
return "A nonrecoverable name server error occurred.";
|
||||
case TRY_AGAIN:
|
||||
return "A temporary error occurred on an authoritative name server. Try again later.";
|
||||
default:
|
||||
return "Unknown error.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue