scan_netstring(3)
β¨ scan_netstring β NAME π
okay bestie so scan_netstring is literally the function that parses a netstring π no cap, that's the whole vibe. it lives in the libowfat library, section 3 of the manual, and it's giving "quietly essential utility" energy fr fr π¦
πΈ SYNTAX πΈ
here's how you summon it:
#include <libowfat/scan.h>
size_t scan_netstring(const char *in,size_t len,char** dest, size_t
*slen);
yeah that's the whole thing. five arguments, no drama, just vibes β¨
π«Ά DESCRIPTION π«Ά
so here's the tea: scan_netstring tries to parse the netstring sitting in your input buffer, which is (in,len) β like, the pointer in and the length len, that's your buffer, periodt.
if that buffer contains a valid netstring, then the pair (*dest,*slen) gets set to the start and length of the transported string. slay π
but wait, important caveats, don't skip these bestie:
- that string is not zero terminated. like, do not go treating it like a C string, i'm begging π
- no copy is made. none. zero.
scan_netstringjust points*destinside your input buffer, so it's a view not a clone π the way it just points into the original buffer is so efficient honestly, ate and left no crumbs.
β RETURN VALUE β
- if parsing worked, you get the number of bytes in the netstring β and no, that's the outer representation, not the transported inner string, don't get it twisted π
- if the input buffer did not contain a valid netstring (or a full one), you get
0. that's it. that's the signal π
π EXAMPLE π
the raw memory buffer "foo" would become the netstring:
"3:foo,"
literally so simple, main character encoding behavior π§
π SPEC π
the official spec lives right here:
http://cr.yp.to/proto/netstrings.txt
go read it, it's giving foundational literature πβ¨
π SEE ALSO π
fmt_netstring(3)β the other half of the duo, the making side to this parsing side π₯
and that's the page bestie! this one's from the Library Functions Manual, and it's scan_netstring(3) all the way down β same name up top, same name down bottom, iconic symmetry, we love a consistent queen ππ
π¦
π¦ 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