fmt_ip6(3)
π fmt_ip6(3) β from the Library Functions Manual π
okay bestie, sit down, hydrate, and let me tell you about fmt_ip6, one of the little legends living in section 3 of the Library Functions Manual. it's giving "tiny function, huge glow-up" energy and honestly? we're obsessed. π¦
β¨ NAME β¨
fmt_ip6 β write a formatted ASCII representation of an IPv6 number π
πΈ SYNTAX πΈ
#include <libowfat/ip6.h>
unsigned int fmt_ip6(char *dest,const char ip[16]);
that's it. that's the whole vibe. two args, one return, no drama. π
π DESCRIPTION π
so here's the tea, fr fr: fmt_ip6 takes your IPv6 number from ip and formats it into ASCII representation, then writes the result into dest. it returns the number of bytes written. iconic behavior, no notes. β¨
fmt_ip6 will apply "::" compression to the output β so yes, it's out here making your addresses shorter and cuter, lowkey a stylist. πββοΈ
if ip is an IPv4-mapped IPv6 address, fmt_ip6 will output the last 4 bytes as IPv4 number in dotted-decimal notation. the way it just switches formats mid-function? main character energy honestly. π
if dest equals FMT_LEN (i.e. is zero), fmt_ip6 returns the number of bytes it would have written. not me asking "how big would this be?" and getting a real answer. π that's a size query, bestie, and it slaps.
fmt_ip6 does not append \0.
β οΈ girl. listen. it does NOT append \0. you have to do that yourself. do not forget. i am begging you. π
for convenience, ip6.h defines the integer IP6_FMT to be big enough to contain every possible fmt_ip6 output plus \0. so that's your buffer size, no cap. π₯
π§ EXAMPLE π§
#include <libowfat/ip6.h>
char buf[IP6_FMT];
char ip[16];
buf[fmt_ip6(buf,ip)]=0;
see that last line? buf[fmt_ip6(buf,ip)]=0; β the return value becomes the index where the \0 goes. it's a whole little choreography and it ate. πβ¨
π SEE ALSO π
the whole friend group, periodt. go say hi. π«Ά
and that's the page, bestie!! this one came straight out of the Library Functions Manual, filed under fmt_ip6(3) β section 3, where all the library function girlies hang out. no version or date on this one, so i'm not gonna make one up, i'm not a liar. π
slay, be safe, always write your null terminator, mwah ππ π¦β¨
π¦ where this page comes from
- alpine 3.24: libowfat-doc 0.34-r0 Β· GPL-2.0-only
- debian bookworm: libowfat-dev 0.32-4 Β· GPL-2.0-only
- debian trixie: libowfat-dev 0.32-5 Β· GPL-2.0-only
- nixos 26.05: libowfat 0.34
- nixpkgs unstable: libowfat 0.34
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- opensuse-leap 16.0: libowfat-devel 0.33-bp160.1.11 Β· GPL-2.0-only
- ubuntu noble: libowfat-dev 0.32-4.1build1 Β· GPL-2.0-only
- ubuntu questing: libowfat-dev 0.32-5
- ubuntu resolute: libowfat-dev 0.34-2 Β· GPL-2.0-only
- ubuntu stonking: libowfat-dev 0.34-2 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms