File: bs_capacityassert.3

package info (click to toggle)
libowfat 0.34-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,288 kB
  • sloc: ansic: 20,181; makefile: 16
file content (31 lines) | stat: -rw-r--r-- 1,269 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
.TH bs_capacityassert 3
.SH NAME
bs_capacityassert \- assert that there are least n bytes left in the stream
.SH SYNTAX
.B #include <libowfat/parse.h>

int \fBbs_capacityassert\fR(struct bytestream* &\fIbs\fR,
                size_t \fIcapacity\fR);
.SH DESCRIPTION
bs_capacityassert will check that there are at least this many bytes in
the bytestream. If there are not, it will set the bytestream to the
error state and return 0; otherwise it will return 1.

Note that this compares against the limits of the bytestream, not the
actual length. These are often the same, but bytestreams can be tied
to a buffer*, in which case the actual length of the stream is not known
beforehand. Even if bs_capacityassert returns successful, the following
actual reads could still run into an error.

bs_capacitycheck does the same thing but does not set the bytestream to
the error state if there is not enough space.

Us bs_capacityleft to find out how many bytes are left in the bytestream.

bs_nomoredataassert is the inverse assertion.

Use bs_err to find out whether the bytestream is in the error state.
.SH "SEE ALSO"
bs_init_membuf(3), bs_init_iobuf(3), bs_init_iobuf_size(3),
bs_init_membuf(3), bs_capacitycheck(3), bs_capacityleft(3),
bs_err(3), bs_nomoredataassert(3)