vrb_read_min(3)
π 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
EAGAINorEWOULDBLOCKfor 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~0for 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,
0is returned. - 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).
π¦ 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 thanread(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
- 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