dns_mx(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’Œ dns_mx(3) β€” the Library Functions Manual girlies know πŸ’…

okay so bestie, we're in the Library Functions Manual and this page is literally called dns_mx(3). it's giving DNS detective energy and i'm obsessed. let's get into it ✨


🌸 NAME 🌸

dns_mx β€” look up Mail eXchanger πŸ¦‹


πŸŽ€ SYNTAX πŸŽ€

#include <libowfat/dns.h>

int dns_mx(stralloc* out,stralloc* fqdn);

πŸ’– DESCRIPTION πŸ’–

okay so dns_mx looks up MX records for the fully-qualified domain name sitting in fqdn. yes, the whole fqdn, don't be shy about it.

it drops the MX records into out and returns 0. and what does each MX record look like, you ask? periodt, i'll tell you:

  • a two-byte MX distance (big endian, no cap), followed by
  • a \0-terminated dot-encoded domain name

so each record is literally a little sandwich: distance first, name second. iconic.

if the domain doesn't exist in DNS, or it exists but has no MX records, then out will be empty. that's it. that's the vibe. πŸ’€

⚠️ and now the part we do NOT gloss over: if dns_mx has trouble with the DNS lookup, or it runs out of memory, it returns -1 and sets errno appropriately. it may or may not change out. yes bestie, MAY OR MAY NOT. so don't go trusting out after a -1, fr fr. πŸ™ˆ

πŸ”₯ SEE ALSO πŸ”₯

go read those next, i promise they slay too 🫢


πŸ‘‘ cute little sign-off πŸ‘‘

and that's the page!! it signs itself off as dns_mx(3) in the Library Functions Manual β€” no extra source, no version, no date, just the name and the manual, which is honestly main character energy. anyway bestie, go resolve some mail exchangers, you're gonna eat πŸ’…βœ¨πŸŒˆ