buffer_get_new_token_sa(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_get_new_token_sa ✨

okay bestie, come sit with me because we're doing libowfat tokens today and honestly? it's giving main character energy πŸŽ€

this page lives in the Library Functions Manual (that's the manual name, iykyk), and the whole thing is literally just: read a token out of a buffer. that's it. that's the vibe. πŸ’…


🌸 NAME 🌸

buffer_get_new_token_sa β€” read token from buffer

like. it reads a token. from a buffer. no cap. πŸ¦‹


✨ SYNTAX ✨

#include <libowfat/stralloc.h>
#include <libowfat/buffer.h>

int buffer_get_new_token_sa(buffer* b,stralloc* sa,
                    const char* charset,size_t setlen);

so you got your b (the buffer, the source of the tea), your sa (the stralloc, where the token lands), your charset (the delimiter squad), and your setlen (how many delimiters are actually in that squad). 🫢


πŸ’– DESCRIPTION πŸ’–

okay so here's the whole plot: buffer_get_new_token_sa copies data from the b over to sa until it bumps into one of the delimiters in charset. and the way it does this? it overwrites whatever was already chilling in sa before. not appending, not merging, not "aww let me preserve your old data" β€” full overwrite, periodt. πŸ’€

and the delimiter that stopped the party? yeah, that one gets copied to sa too. it's part of the token now. iconic behavior honestly. ✨

😭 now the sad part: if reading from the buffer fails, or if allocating memory fails, buffer_get_new_token_sa returns -1 and sets errno appropriately. and listen β€” at that point sa may already contain a partial token. so like, don't be out here trusting sa after an error, bestie. it's half-baked. πŸ™ˆ

also, real talk: if you're trying to read from a non-blocking socket, use buffer_get_token_sa instead. this one is not the one for that job. different function, different vibe. 🧚


πŸ”₯ RETURN VALUE πŸ”₯

  • -1 β€” error, and it's setting errno on the way out. 😭
  • 0 β€” EOF. that's the end of the road, babe. 🌈
  • 1 β€” successful. slay. we ate. πŸ‘‘

⭐ SEE ALSO ⭐

go read these next, they're all in the same friend group:


and that's the whole page, bestie!! πŸŽ€ no source version, no date stamp, nothing extra β€” the footer just echoes buffer_get_new_token_sa(3) right back at us from the Library Functions Manual like a lil mirror. cute. obsessed. go read your tokens. πŸ’œβœ¨