REALHOSTNAME(3)
π¦ realhostname(3) β LOCAL manual energy π¦
okay so the header is being a little mysterious with UNTITLED(), but bestie, this is realhostname(3) from the LOCAL manual, and we are getting into it. π
β¨ NAME β¨
realhostname β convert an IP number to the real host name π
π LIBRARY π
System Utilities Library (libutil, -lutil) β yes, that one, periodt. π
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <netinet/in.h>
#include <libutil.h>
int
realhostname(char *host, size_t hsize, const struct in_addr *ip);
π« DESCRIPTION π«
okay so realhostname() converts ip to the corresponding host name. The way it does this: it resolves ip to a host name, then makes sure that host name resolves back to ip β both directions or it does not count, no cap. π«Ά
host must point to a buffer of at least hsize bytes, and it will always be written to by this function. always always. π
If the name resolution does not work both ways, or if the host name is longer than hsize bytes, inet_ntoa(3) is used to convert ip to an ASCII form. fallback slay. β¨
β οΈ heads up bestie: if the string written tohostishsizebytes long,hostwill not be NUL terminated. that is the whole warning, and it matters. π
π RETURN VALUES π
The realhostname() function will return one of the following constants, which are defined in <libutil.h>:
HOSTNAME_FOUNDβ a valid host name was found. iconic. β¨HOSTNAME_INCORRECTNAMEβ a host name was found, but it did not resolve back to the passedip.hostnow contains the numeric value ofip. rude but okay. πHOSTNAME_INVALIDADDRβipcould not be resolved.hostnow contains the numeric value ofip. π«HOSTNAME_INVALIDNAMEβ a host name was found, but it could not be resolved back to any ip number.hostnow contains the numeric value ofip. the drama. π
π SEE ALSO π
okay bye bestie π this pageβs footer energy is Debian, dated April 6, 1999 β vintage, honestly. πβ¨
π¦ where this page comes from
- nixpkgs unstable: libutil 73
- Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms