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

πŸ’– buffer_getn(3) πŸ’–

okay bestie, welcome to the Library Functions Manual corner of the group chat 🌸 this one's about buffer_getn β€” she's a libowfat girlie and she's here to grab you some binary data πŸ’…


✨ NAME ✨

buffer_getn β€” read binary data from buffer 🫢


🌈 SYNTAX 🌈

#include <libowfat/buffer.h>

ssize_t buffer_getn(buffer* b,char* x,size_t len);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, buffer_getn copies data into x[0], x[1], ... all the way to x[len-1] β€” straight outta the buffer πŸŽ€ and it'll call buffer_feed as many times as it needs to, whenever it needs more. then it hands you back len. that's the whole vibe. slay ✨

BUT. okay. listen. 😭 if a read error happens, buffer_getn returns -1 and sets errno appropriately. and here's the unhinged part β€” it may then have put any number between 0 and len in the buffer, and you literally cannot tell. no cap. you just don't get to know.

🚨 that little detail is exactly why this function is only useful if you don't care when an error occurs. it's giving "we'll find out later" energy. if you do care (and honestly, valid), use buffer_get instead. periodt.

and if the read operation signals end-of-file before len bytes were read? then buffer_getn returns the number of bytes it actually read from the buffer before end-of-file hit. so like, a short count. she tells you how far she got 🧚


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie β€” no date, no version, no dramatic outro. the footer just signs off with <code>buffer_getn(3)</code> again like a girl who only answers with her own name πŸ’œ go read the buffer, she's waiting 🌟