buffer_getnewline_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_getnewline_sa(3) πŸ’–

okay bestie, so this one lives in the Library Functions Manual and it's called buffer_getnewline_sa β€” say it with me, it's giving "grab me a line, queen". πŸŽ€


✨ NAME ✨

buffer_getnewline_sa β€” read line from buffer


🌸 SYNTAX 🌸

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

int buffer_getnewline_sa(buffer* b,stralloc* sa);

πŸ¦‹ DESCRIPTION πŸ¦‹

so what this icon actually does: buffer_getnewline_sa copies data from b over into sa, and it keeps going until it finds a '\n'. and here's the thing β€” it overwrites whatever was chilling in sa before, so don't get attached to the old contents, they're gone, periodt. πŸ’… and yes, that newline character itself also gets appended to sa. she comes with the line, she is part of the line. no cap.

if reading from the buffer fails, or if allocating memory fails, buffer_getnewline_sa returns -1 and sets errno appropriately. and at that point? sa may be empty, or it may already contain a partial token. so like, it's a vibe check that failed halfway through. 😭

ok important side note bestie β€” if you're trying to read from a non-blocking socket, use buffer_getline_sa instead. this one is not the girl for that job. πŸ™ˆ

πŸ‘‘ RETURN VALUE πŸ‘‘

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

🌈 SEE ALSO 🌈


and that's the whole page, bestie!! mwah πŸ’œ this was buffer_getnewline_sa(3) from the Library Functions Manual β€” go read a line, slay, and remember: overwriting is forever. πŸ«Άβœ¨πŸ’–