buffer_get_token_pred(3)
π buffer_get_token_pred(3) π
okay so bestie, welcome to the Library Functions Manual β¨ this one's a lil libowfat baddie that reads you a whole token off a buffer and she's honestly so iconic for it π
πΈ NAME πΈ
buffer_get_token_pred β read token from buffer π
β¨ SYNTAX β¨
lowkey just include the header and you're in, no cap:
#include <libowfat/buffer.h>
ssize_t buffer_get_token_pred(buffer* b,char* x,size_t len,
int (*predicate)(const char* s,size_t len));
π¦ DESCRIPTION π¦
so here's the vibe: buffer_get_token_pred copies data from b into x[0], x[1], ..., x[len-1] β literally one byte at a time, main character energy β and it keeps going until either
lenbytes have been read, orpredicategets called on the destination string and returns nonzero π
and the way that predicate has options?? it's giving choose-your-own-adventure fr fr:
- it can return
0β which means "bestie I need more input to finish this token, keep going" π₯Ί - or it can return
-1β which means abort and return-1π use this whenpredicatewants to enforce a maximum message size, or does timeout handling, or detects a malformed message. periodt.
then buffer_get_token_pred returns the number of bytes copied π«Ά or -1 on error (and yes, it sets errno appropriately, she's polite like that).
ngl the -1 path is a real one β if your predicate bails, the whole call bails. don't sleep on that.
π SEE ALSO π
go read her friends too, they're all slay:
and that's the whole page babes π
this was buffer_get_token_pred(3) from the Library Functions Manual β k bye, ily, go read a buffer π§π
π¦ 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