qlibs:(ipv4)

πŸ“¦ version 31, in alpine 3.24

πŸ’– NAME πŸ’–

okay bestie, welcome to the qlibs:(ipv4) manual page ✨ β€” this one is all about IPv4 address evaluation and conversion, and honestly it's giving very useful little toolkit energy πŸŽ€

ipv4 β€” IPv4 address evaluation and conversion


🧚 SYNTAX 🧚

#include "ip.h"

unsigned int ip4_fmt(char *s,char ip[4]);
unsigned int ip4_scan(const char *s,char ip[4]);
unsigned int ip4_scanbracket(char *s,char ip[4]);
unsigned int ip_scanbracket(char *ip_str,char *s);
unsigned int ip4_cidr(char *s,char ip[4],unsigned long *plen);
unsigned int ip4_bytestring(stralloc *ip4string,char ip[4],int plen);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the vibe check on every function, bestie πŸ’…

  • ip4_fmt β€” reads the char[4] IPv4 address and returns a dotted-decimal IPv4 address string 1.2.3.4. literally the glow-up from packed bytes to pretty dotted-decimal πŸ’–
  • ip4_scan β€” reads an IPv4 address string 1.2.3.4 and converts it to the char[4] IPv4 address. yes ma'am, string in, packed address out 🫢
  • ip4_scanbracket β€” reads an IPv4 address string enclosed in brackets [1.2.3.4], removes the brackets, and calls ip4_scan on the result. bracket removal is the main character here πŸŽ€
  • ip_scanbracket β€” reads an IP address string enclosed in brackets [1.2.3.4] or [fe80::1], removes the brackets, and calls ip4_scan or ip6_scan upon detecting an IPv6 address on the result. so it's flexible like that ✨
  • ip4_cidr β€” reads the CIDR IPv4 address string 1.2.3.4/15, determines the prefix as integer plen, and calls ip4_scan. If no prefix is identified, it returns 32. periodt πŸ’…
  • ip4_bytestring β€” reads the IPv4 address given as char[4] while returning a 0-terminated 'bytestring' representation 1001001.... up to the given prefix length plen. it's giving binary reveal, no cap πŸ¦‹

πŸ’€ RETURN CODES πŸ’€

The ip(4)* programs return the number of bytes processed.

ip4_bytestring returns regative numbers on failure.

bestie, yes β€” the page literally says regative, and I'm not out here editing the original lore πŸ™ˆπŸ’€

🌈 SEE ALSO 🌈


xoxo, signing off from your qlibs:(ipv4) corner of the manual πŸ’– β€” source/version tag at the bottom was qlibs:(ipv4), and the original footer didn't give a separate date, so I'm not inventing one, periodt 🫢✨

πŸ“¦ where this page comes from