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

πŸ’– scan_ip6_flat β€” it's in the NAME section bestie πŸ’–

okay so real quick, this whole page is scan_ip6_flat(3) from the Library Functions Manual, and she's here to parse an IPv6 number in flat ASCII representation. yes ma'am. πŸŽ€


✨ SYNTAX ✨

like, the whole vibe starts with this include:

#include <libowfat/ip6.h>

int scan_ip6_flat(const char *src,char ip[16]);

that's it. that's the whole signature. she's small but she's mighty. πŸ’…


🌸 DESCRIPTION 🌸

so scan_ip6_flat does the thing where it parses an IPv6 number in flat ASCII representation β€” reading it out of src β€” and then writes the result into ip. πŸ¦‹

and then she tells you how it went: she returns the number of bytes read from src, or 0 if the parsing failed. that's the whole status report, no cap.

she's also super chill about letter case β€” scan_ip6_flat accepts upper AND lower case hex letters. equal opportunity hex. periodt. πŸ‘‘

one little note tho: the flat representation you feed her should have been output by fmt_ip6_flat. they're a matched set, an iconic duo, iykyk. 🫢


⭐ EXAMPLE ⭐

here's the moment you've been waiting for, the code:

#include <libowfat/str.h>
#include <libowfat/ip6.h>

  char buf[]="00000000000000000000000000000001";
  char ip[16];
  if (scan_ip6_flat(buf,ip) != str_len(buf))
    parse_error();

see how she checks that the return value equals str_len(buf)? if it doesn't, parse_error(). not me being obsessive about checking the return value, it's giving responsible. πŸ’€βœ¨


πŸ”₯ SEE ALSO πŸ”₯


okay that's the whole page bestie, no notes. this was scan_ip6_flat(3) straight outta the <strong>Library Functions Manual</strong>, so go forth and parse those flat IPv6 numbers. mwah. πŸ’œπŸŽ€πŸ¦‹