fmt_netstring(3)
π fmt_netstring(3) π
okay bestie, so this one lives in the Library Functions Manual and it's literally called fmt_netstring β say it with me, it's giving format a netstring. π
β¨ NAME β¨
fmt_netstring β turn a raw memory buffer into a netstring π¦
πΈ SYNTAX πΈ
#include <libowfat/fmt.h>
size_t fmt_netstring(char *dest,const char *source,
size_t len);
no cap, that's the whole signature π
π DESCRIPTION π
so fmt_netstring takes a raw memory buffer and builds a netstring out of it, then hands you back the length. that's it. that's the job. iconic. π
important: fmt_netstring does not append \0. like, it's not that kind of function, don't come for it. π«
and here's the lil trick that makes it so good β if dest equals FMT_LEN (i.e. it's zero), then fmt_netstring just returns the number of bytes it would have written. a little "just tell me how much room I need" moment. so thoughtful fr fr π«Ά
π RETURN VALUE π
fmt_netstring returns the number of bytes written β or the number that would have been written, if the destination pointer was pointed at NULL. π«
but heads up bestie: if the input buffer is implausibly large, fmt_netstring returns 0 instead. not a vibe, but it's the rules. π
π EXAMPLE π
the raw memory buffer "foo" would become the netstring "3:foo,"
β¨ literally that simple β¨
π§ SPEC π§
http://cr.yp.to/proto/netstrings.txt
go read the source of truth, iykyk π
β SEE ALSO β
scan_netstring(3)β the other half of the duo, go check on them π
and that's the whole page, bestie!! this was page fmt_netstring(3) from the Library Functions Manual, and it slayed, periodt. π
β¨π
π¦ 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