buffer_get_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_token_sa(3) πŸ’–

okay bestie, welcome to the manual page for buffer_get_token_sa β€” she lives in the Library Functions Manual and she is so useful, no cap. this is the girl that reads a token off a buffer. let's get into it πŸŽ€


✨ NAME ✨

buffer_get_token_sa β€” read token from buffer


🌸 SYNTAX 🌸

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

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

πŸ’… DESCRIPTION πŸ’…

so here's the tea. buffer_get_token_sa keeps appending data from b into sa until it hits one of the delimiters in charset, and it does NOT overwrite whatever was already chillin' in sa before. it just adds to the pile. and the delimiter that stopped it? yeah, that one gets appended to sa too. she's included, periodt. ✨

now, the sad part 😭 β€” if reading from the buffer fails, or if allocating memory fails, buffer_get_token_sa returns -1 and sets errno appropriately. and heads up bestie: at that exact moment, sa may already contain a partial token. so don't come for her, she tried her best 🫢


πŸ‘‘ RETURN VALUE πŸ‘‘

  • -1 β€” on error (and she sets errno, iconically)
  • 0 β€” on EOF
  • 1 β€” when successful πŸŽ‰

πŸ¦‹ RATIONALE πŸ¦‹

okay so why does she append instead of overwrite? because that's literally the whole point, iykyk. appending means you can use her on non-blocking sockets 🧚 β€” those babies signal an error and set errno to EAGAIN. and when that happens? you literally just call buffer_get_token_sa again later, once select or poll tells you more data has arrived. it's giving main character energy with a comeback arc πŸ’œ


🌈 SEE ALSO 🌈


and that's the whole page, bestie πŸ“ thanks for reading all the way through, you ate that. this was buffer_get_token_sa(3) from the Library Functions Manual β€” the page footer just shows the name again with no date on it, so that's all we've got, and honestly? iconic. bye pookie πŸ’–βœ¨πŸŽ€