fmt_ip6c(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

πŸ’– fmt_ip6c β€” the IPv6 glow-up formatter πŸ’–

okay bestie, welcome to fmt_ip6c(3) from the Library Functions Manual. she takes a raw IPv6 number and turns it into a cute little ASCII string. it's giving translator, it's giving main character. let's go ✨


🌸 NAME 🌸

fmt_ip6c β€” write a formatted ASCII representation of an IPv6 number


πŸŽ€ SYNTAX πŸŽ€

#include <libowfat/ip6.h>

unsigned int fmt_ip6c(char *dest,const char ip[16]);

✨ DESCRIPTION ✨

so basically fmt_ip6c takes an IPv6 number from ip, formats it in ASCII representation, and writes the result into dest. it returns the number of bytes written. no cap. πŸ’…

fmt_ip6c will apply "::" compression to the output. yes queen, she's compact.

if ip is an IPv4-mapped IPv6 address, fmt_ip6c will output it as an IPv4 address. she switches lanes when the vibe calls for it πŸ¦‹

if dest equals FMT_LEN (i.e. is zero), fmt_ip6c returns the number of bytes it would have written. a hypothetical slay. πŸ”₯

⚠️ real talk: fmt_ip6c does not append \0. she is NOT going to null-terminate your string for you, bestie. that's on you, periodt.

for convenience, ip6.h defines the integer IP6_FMT to be big enough to contain every possible fmt_ip6c output plus \0. so use that buffer size and you're safe 🫢


🌈 EXAMPLE 🌈

#include <libowfat/ip6.h>

  char buf[IP6_FMT];
  char ip[16];
  buf[fmt_ip6c(buf,ip)]=0;

see how we manually slap that 0 on the end? yeah. because no \0, remember? 😭


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, angel πŸ’œ this was fmt_ip6c(3) from the Library Functions Manual β€” go forth and format your IPv6 addresses with "::" compression and zero null terminators, iykyk. mwah πŸŽ€βœ¨