buffer_getline(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_getline(3) ✨

okay bestie, pull up a chair because we're talking about buffer_getline, a lil function from the Library Functions Manual (section 3, library functions, iykyk πŸ’…). she reads a line from a buffer. that's it. that's the girl. and honestly? iconic. πŸŽ€


🌸 NAME 🌸

buffer_getline β€” read line from buffer πŸ“–βœ¨


πŸ¦‹ SYNTAX πŸ¦‹

#include <libowfat/buffer.h>

ssize_t buffer_getline(buffer* b,char* x,size_t len);

like, that's the whole vibe check right there 🫢


πŸ’– DESCRIPTION πŸ’–

okay so here's the tea β˜• β€” buffer_getline copies data from b into x[0], x[1], ..., x[len-1], and it keeps going until either:

  • len bytes have been copied, or
  • a new-line character ('\n') shows up πŸ‘€

and bestie, that new-line character? it gets copied too. it's included. it's part of the group. no cap. πŸŽ‰

🚨 not me about to tell you the most important part 🚨 β€” the line is not 0-terminated! and that's on purpose, fr fr. it's so that reading lines with 0-bytes in them is actually possible through this interface. the 0-bytes get to exist. we love that for them. 🌈

πŸ‘‘ RETURN VALUE πŸ‘‘

  • Number of bytes read β€” and heads up, that count does not include the '\n' ✨
  • -1 on error β€” and yeah, it sets errno when that happens 😭

πŸ”₯ SEE ALSO πŸ”₯

go read these next, bestie, they're all in the family:


and that's the whole page, babes β€” straight outta the Library Functions Manual, filed under buffer_getline(3) (same name top and bottom, we love consistency πŸ’…). no version or date on this one, just pure unfiltered libowfat energy. stay hydrated, read your buffers, and remember: the '\n' counts as read but not as read-read. periodt. 🫢✨