dns_ip4(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_ip4 β€” look up IPv4 addresses πŸ’–

okay bestie, welcome to dns_ip4(3) from the Library Functions Manual, this is the one that gets you those sweet sweet 4-byte IP addresses πŸ¦‹


✨ NAME ✨

dns_ip4 β€” look up IPv4 addresses. that's it. that's the vibe. πŸ‘‘


🌸 SYNTAX 🌸

#include <libowfat/dns.h>

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

two stralloc*s, one int, no drama. πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

so like. dns_ip4 looks up the 4-byte IP addresses for the fully-qualified domain name sitting in fqdn. it takes the concatenation of those IP addresses, drops them into out, and returns 0. iconic behavior, no notes. ✨

and if the domain doesn't exist in DNS, or it exists but has no IP addresses? then out will be empty. like, ghosted. πŸ’€

now for the part where it gets real. if dns_ip4 has trouble with the DNS lookup, or if it runs out of memory, it returns -1 and sets errno appropriately. also β€” heads up β€” it may or may not change out. so don't go trusting out after a -1, bestie, that's not a safe place to be. πŸ™ˆ

but wait, here's the fun shortcut πŸ“: if fqdn is already a dotted-decimal IP address, dns_ip4 just puts that IP address into out without checking DNS. why ask the internet when you already know the answer, right?

and more generally β€” yes, it gets more general, she contains multitudes β€” if fqdn is a dot-separated sequence of dotted-decimal IP addresses, dns_ip4 puts those IP addresses into out without checking DNS too. multi-IP slay. πŸ’…

also, brackets may appear inside the dotted-decimal IP addresses, and they are ignored. they're just there for decoration i guess, we don't question them. πŸŽ€

ngl, the "may or may not change out" thing is the one to remember. that's the lore. 🫢

🌈 SEE ALSO 🌈


and that's the whole page, bestie πŸ’– this was dns_ip4(3), living in the Library Functions Manual, and yes she's still called dns_ip4(3) on the way out too β€” she said her name twice because she's that girl. 🌟 periodt. πŸŽ€πŸ¦‹βœ¨