vrb_read_min(3)

πŸ“¦ version 0.5.1, in nixos 26.05

πŸ’… vrb_read_min(3) β€” from the VRB Programmer's Manual, bestie

okay so picture this: it's vrb_read_min(3), she's a real one, and she lives in the VRB Programmer's Manual. that's the whole vibe. let's get into it 🫢


✨ NAME ✨

vrb_read_min β€” reading a minimum of data into a VRB. not vibes, actual bytes. minimum effort is NOT the point here for once πŸ’€

πŸ“š LIBRARY πŸ“š

-lvrb

link it and go, bestie 🌸

πŸŽ€ SYNOPSIS πŸŽ€

#include <vrb.h>

size_t vrb_read_min(vrb_p vrb, int fd, size_t maxsize, size_t minsize);

πŸ”₯ DESCRIPTION πŸ”₯

okay so here's the tea β˜• β€” vrb_read_min reads a minimum amount of data from a specified open file descriptor, using read(2), into the specified virtual ring buffer. she keeps going until:

  • the specified maximum length has been read,
  • the buffer is full,
  • end-of-file hits, or
  • an error is returned (this includes EAGAIN or EWOULDBLOCK for a non-blocking descriptor 😭).

and here's the iconic part: if there is insufficient space in the buffer to read the minimum amount, then read(2) will not be called at all. she simply does not show up. main character boundary-setting energy πŸ‘‘

🌈 ARGUMENTS 🌈

  • vrb_p vrb β€” specifies which virtual ring buffer. like, which one, bestie.
  • int fd β€” specifies the open file descriptor to read from πŸ“
  • size_t maxsize β€” specifies the maximum length to read, or ~0 for unlimited. go off, no cap ✨
  • size_t minsize β€” specifies the minimum length to read. the bare minimum, literally.

πŸ’– RETURN VALUE πŸ’–

size_t

  • if successful, the actual length of data read into the buffer is returned πŸ’…
  • if the minimum amount of space was not available to read into, 0 is returned.
  • if end-of-file occurs, the return value is ~0 and errno is 0.
  • if an error occurs from read(2), the return value is ~0 and errno is set by read(2).

πŸ¦‹ ERRORS πŸ¦‹

if an error is returned, then errno will have one of the following values:

  • 0 β€” an end-of-file has occurred. ⚠️ note that this is a different way of returning an end-of-file condition than read(2) uses. yes really, she does it her own way πŸ™ˆ
  • EINVAL β€” an invalid virtual ring buffer pointer was specified. wrong pointer, wrong girl πŸ’€

πŸ‘‘ 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(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, fr fr 🧚


and that's the page, bestie β€” brought to you by the legend herself, vrb, dated 2002-09-30. she's been iconic since day one and she's not stopping πŸ’œβ­

πŸ“¦ where this page comes from