buffer_get...en_sa_pred(3)
π NAME π
buffer_get_new_token_sa_pred β bestie, this one reads a token from a buffer π
So this is a page from the Library Functions Manual, and it's giving "grab me a token, but make it custom." Let's get into it π«Ά
β¨ SYNTAX β¨
#include <libowfat/stralloc.h>
#include <libowfat/buffer.h>
int buffer_get_new_token_sa_pred(buffer* b, stralloc* sa,
int (*predicate)(stralloc* * sa));
πΈ DESCRIPTION πΈ
okay so. buffer_get_token_sa_pred copies data from b to sa until predicate(sa) returns 1 or -1. That's the whole vibe π
If predicate returns 1 once a '\n' was read, that new-line character is still appended to sa β no cap, it's just sitting there π so use stralloc_chop or stralloc_chomp to get rid of it. And predicate can also return:
- 0 β meaning further input is required to complete the token (we're not done yet, keep waiting bestie β³)
- -1 β meaning abort and return
-1. Use this ifpredicatewants to enforce a maximum message size, or does timeout handling, or detects a malformed message π©
If reading from the buffer or allocating memory fails, buffer_get_new_token_sa_pred returns -1 and sets errno appropriately π and at that point sa may already contain a partial token β so heads up, it's not clean in there.
On success, buffer_get_new_token_sa_pred returns 0 β¨
If you want to read from a non-blocking socket, use buffer_get_token_sa_pred instead. Periodt π₯
π¦ SEE ALSO π¦
and that's the page, bestie π this one lives in the Library Functions Manual and signs off as buffer_get...en_sa_pred(3) β no version, no date, just vibes π go read those SEE ALSOs, iykyk π
π¦ 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