ARES_EXPAND_NAME(3)

πŸ“¦
version 1.34.9 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ ARES_EXPAND_NAME ✨

okay bestie, welcome to the ares_expand_name(3) page from the Library Functions Manual πŸ’– this one's a lil c-ares function and it's genuinely so useful, i promise it's not scary.


🌸 NAME 🌸

ares_expand_name β€” expand a DNS-encoded domain name πŸ¦‹

πŸŽ€ SYNOPSIS πŸŽ€

#include <ares.h>

int ares_expand_name(const unsigned char *encoded,
                     const unsigned char *abuf, int alen,
                     char **s, long *enclen)

πŸ’… DESCRIPTION πŸ’…

so basically, ares_expand_name takes a domain name that's been encoded the DNS way and turns it into a normal dot-separated C string. the glow-up, honestly. ✨

  • encoded β€” this is where the encoded domain name starts. it points at the beginning of it.
  • abuf and alen β€” these two give you the whole containing message buffer. and yes you literally need them, because the encoded name can have indirection pointers inside it and we gotta be able to follow those. no buffer, no pointer-following, no vibes. πŸ™ˆ

the result goes into a NUL-terminated allocated buffer, and a pointer to that buffer gets stashed in the variable that s points at. then the length of the encoded name gets stored in whatever variable enclen points at β€” this is the part that lets the caller skip past the encoded domain name and keep reading the rest of the data in the message. it's giving "know where you are so you can move on" energy. πŸ‘‘

πŸ’– heads up bestie: when you're done with the allocated hostname, free it with ares_free_string(3). don't just leave it there, that's not the move. 🫢

⭐ RETURN VALUES ⭐

ares_expand_name can hand you any of these:

  • ARES_SUCCESS β€” yay! the encoded name expanded successfully. slay. πŸŽ‰
  • ARES_EBADNAME β€” nope 😭 the encoded domain name was malformed and could not be expanded. it's giving broken.
  • ARES_ENOMEM β€” memory was exhausted πŸ’€ we ran out. tragic.

🌈 SEE ALSO 🌈


and that's the whole page bestie!! written by the c-ares crew, dated 20 Nov 2009 β€” vintage but iconic, we stan a classic. πŸ’œβœ¨ go forth and expand those names responsibly, and remember to free your strings!! πŸŽ€πŸ¦‹