ARES_GETHOSTBYNAME(3)
β¨ ares_gethostbyname_file β the manual page, bestie edition β¨
okay so you're reading the Library Functions Manual page for ares_gethostbyname_file, which lives in section 3 of the manual (ARES_GETHOSTBYNAME(3), yes the function name and the page name are lowkey different, that's just how it is π
).
πΈ NAME πΈ
ares_gethostbyname_file β Lookup a name in the system's hosts file
like literally just that. she looks stuff up in your hosts file. no network, no drama π
π¦ SYNOPSIS π¦
#include <ares.h>
int ares_gethostbyname_file(ares_channel_t *channel, const char *name,
int family, struct hostent **host)
π DESCRIPTION π
so the way that ares_gethostbyname_file works is it performs a host lookup by name against the system's hosts file (or equivalent local hostname database). local files only, bestie β she's not going anywhere, she's staying home π
the channel parameter is required, but no asynchronous queries are performed. not one. zero. none. instead, the lookup is done via the same mechanism used to perform 'f' lookups (see the lookups options field in ares_init_options(3)). iykyk π
the parameter name gives the hostname as a NUL-terminated C string, and family gives the desired type of address for the resulting host entry.
π«Ά the return values, aka the vibe check π«Ά
the return value indicates whether the query succeeded and, if not, how it failed. it may have any of the following values:
ARES_SUCCESSβ the host lookup completed successfully andhostnow points to the result (and must be freed withares_free_hostent(3)). slay, but also: free her. periodt πARES_ENOTFOUNDβ the hostnamenamewas not found. she's just not in there πARES_EFILEβ there was a file I/O error while performing the lookup. the file said no πARES_ENOMEMβ memory was exhausted. brain empty, no thoughts π
π and what you actually get back π
on successful completion of the query, the pointer pointed to by host points to a struct hostent containing the address of the host returned by the lookup. the user must free the memory pointed to by host when finished with it by calling ares_free_hostent(3). not optional. not negotiable. free your hostent, bestie π«Ά
β οΈ if the lookup did not complete successfully,hostwill beNULL. so always check before you go dereferencing, ok? protect your peace and also your segfaults π
β AVAILABILITY β
added in c-ares 1.5.4 β she's been iconic since day one, an OG π
π SEE ALSO π
and that's the whole page, fr fr β¨ this one's dated 25 July 1998, from the ARES_GETHOSTBYNAME(3) page in the Library Functions Manual β yes the 1998 date is giving vintage, and honestly? vintage is back. no cap. bye bestie ππ¦πΈ
π¦ where this page comes from
- alpine 3.22: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.23: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.24: c-ares-doc 1.34.9-r0 Β· MIT
- arch rolling: c-ares 1.34.9-1 Β· MIT
- centos-stream 10: c-ares-devel 1.34.9-1.el10 Β· MIT
- debian trixie: libc-ares-dev 1.34.5-1+deb13u1 Β· MIT
- fedora 43: c-ares-devel 1.34.5-2.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.5-2.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.8-1.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.8-1.fc43 Β· MIT
- fedora 44: c-ares-devel 1.34.6-3.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.6-3.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.8-1.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.8-1.fc44 Β· MIT
- nixos 26.05: c-ares 1.34.9
- nixpkgs unstable: c-ares 1.34.8
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- ubuntu questing: libc-ares-dev 1.34.5-1
- ubuntu questing: libc-ares-dev 1.34.5-1ubuntu0.1
- ubuntu resolute: libc-ares-dev 1.34.6-1 Β· MIT
- ubuntu resolute: libc-ares-dev 1.34.6-1ubuntu0.1
- ubuntu resolute: libc-ares-dev 1.34.6-1ubuntu0.2 Β· MIT
- ubuntu stonking: libc-ares-dev 1.34.8-1 Β· MIT
- π the page's license: MIT
- Copyright 1998 by the Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms