buffer_get(3)
π buffer_get(3) π
okay bestie, welcome to the Library Functions Manual β¨ we're doing buffer_get today, she's the one who reads binary data out of a buffer, and she ATE π
πΈ NAME πΈ
buffer_get β read binary data from buffer π¦
β¨ SYNTAX β¨
#include <libowfat/buffer.h>
ssize_t buffer_get(buffer* b,char* x,size_t len);
like. that's it. that's the whole summoning circle π
π«Ά DESCRIPTION π«Ά
so normally, buffer_get copies data to x[0], x[1], ..., x[len-1] from the beginning of a string stored in preallocated space. then it removes those len bytes from the string, and returns len. clean. iconic. no crumbs left behind π
BUT. and this is the plot twist π if the string has fewer than len bytes β but more than 0 β then buffer_get copies only that many bytes, and returns that number. so it gives you what it's got, ngl, it's doing its best π
and if the string is empty? buffer_get first uses a read operation to feed data into the string. that read operation can do two things:
- it may indicate end of input β in which case
buffer_getreturns0 - or it may hit a read error β in which case
buffer_getreturns-1, and setserrnoappropriately π
fr fr do not sleep on that-1. check yourerrno. it's giving "i tried my best and the world said no" π
the preallocated space and the read operation are specified by b. you must initialize b using buffer_init before calling buffer_get β or, alternatively, use the pre-initialized buffer_0 π (she comes ready-made, main character energy, no setup required π)
lowkey important:buffer_initfirst orbuffer_0, bestie. no uninitialized buffers in this house π
π SEE ALSO π
go read the whole squad, they're all slaying in their own way π
okay that's the page!! this one lives in the Library Functions Manual, and yeah the page is so iconic she literally signs her own name again at the bottom: buffer_get(3), 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