vrb_read(3)
β¨ vrb_read(3) β the VRB Programmer's Manual, section 3, bestie β¨
okay so real talk, this one is from the VRB Programmer's Manual and it's genuinely one of my faves because it does exactly one thing and it does it slayfully π
πΈ NAME πΈ
vrb_read β read data into a VRB. that's it. that's the whole job. iconic.
π LIBRARY π
-lvrb
(link against it or you get nothing, fr fr π₯)
β¨ SYNOPSIS β¨
#include <vrb.h>
size_t vrb_read(vrb_p vrb, int fd, size_t size);
π¦ DESCRIPTION π¦
okay so here's the vibe: vrb_read reads data from a specified open file descriptor β using read(2) under the hood, ngl β straight into the specified virtual ring buffer. π«
and it keeps going until any of these happen:
- the specified maximum length has been read,
- the buffer is full,
- end-of-file hits,
- or an error comes back (and yes, that includes
EAGAINorEWOULDBLOCKif your descriptor is non-blocking π).
π ARGUMENTS π
vrb_p vrbβ specifies which virtual ring buffer. like, which one. this one. the one you mean. π«Άint fdβ specifies the open file descriptor to read from π₯size_t sizeβ specifies the maximum length to read, or~0for unlimited. go big or go home, yk? π
π RETURN VALUE π
returns size_t.
- if it's successful, you get the actual length of data read into the buffer back. slay. β¨
- if end-of-file occurs, the return value is
~0anderrnois0. - if an error occurs from
read(2), the return value is~0anderrnois set byread(2).
β οΈ bestie please note: this is a different way of returning an end-of-file condition than read(2) uses. that's not a bug, that's just the house style. don't come for me π
π ERRORS π
if an error is returned, then errno will have one of these values:
0β an end-of-file has occurred. and again, note that this is a different way of returning an end-of-file condition thanread(2)uses. i said what i said πEINVALβ an invalid virtual ring buffer pointer was specified. you handed it a fake vrb, it's not gonna pretend to like it π
π§ SEE ALSO π§
vrb(3), vrb_capacity(3), vrb_data_len(3), vrb_data_ptr(3), vrb_destroy(3), vrb_get(3), vrb_get_min(3), vrb_give(3), vrb_init(3), vrb_init_opt(3), vrb_is_empty(3), vrb_is_full(3), vrb_is_not_empty(3), vrb_is_not_full(3), vrb_move(3), vrb_new(3), vrb_new_opt(3), vrb_put(3), vrb_put_all(3), vrb_read_min(3), vrb_resize(3), vrb_space_len(3), vrb_space_ptr(3), vrb_take(3), vrb_uninit(3), vrb_write(3), vrb_write_min(3), read(2)
(the whole friend group, basically π«Ά go say hi)
and that's the page!! π authored under vrb, dated 2002-09-30, from the VRB Programmer's Manual β vintage but still eating, no cap πβ¨
π¦ where this page comes from
- nixos 26.05: vrb 0.5.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms