summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-07-18 08:15:02 +0000
committerngie <ngie@FreeBSD.org>2017-07-18 08:15:02 +0000
commitc7011a5a1b3d6103cd31a38f677d6d77c44158d3 (patch)
treec945395db5b500babb8919fd9cda50ab96aa8a3f /share
parent64e85b71e8a50aa56fe271bbb1ee1a7fd9a5cbb2 (diff)
downloadFreeBSD-src-c7011a5a1b3d6103cd31a38f677d6d77c44158d3.zip
FreeBSD-src-c7011a5a1b3d6103cd31a38f677d6d77c44158d3.tar.gz
MFC r279992,r280149,r280193,r288223,r288484,r321109:
r279992 (by ian): Add a new flag, SBUF_INCLUDENUL, and new get/set/clear functions for flags. The SBUF_INCLUDENUL flag causes the nulterm byte at the end of the string to be counted in the length of the data. If copying the data using the sbuf_data() and sbuf_len() functions, or if writing it automatically with a drain function, the net effect is that the nulterm byte is copied along with the rest of the data. r280149 (by ian): Update an sbuf assertion to allow for the new SBUF_INCLUDENUL flag. If INCLUDENUL is set and sbuf_finish() has been called, the length has been incremented to count the nulterm byte, and in that case current length is allowed to be equal to buffer size, otherwise it must be less than. Add a predicate macro to test for SBUF_INCLUDENUL, and use it in tests, to be consistant with the style in the rest of this file. r280193 (by ian): The minimum sbuf buffer size is 2 bytes (a byte plus a nulterm), assert that. Values smaller than two lead to strange asserts that have nothing to do with the actual problem (in the case of size=0), or to writing beyond the end of the allocated buffer in sbuf_finish() (in the case of size=1). r288223 (by cem): sbuf: Process more than one char at a time Revamp sbuf_put_byte() to sbuf_put_bytes() in the obvious fashion and fixup callers. Add a thin shim around sbuf_put_bytes() with the old ABI to avoid ugly changes to some callers. Obtained from: Dan Sledz r288484 (by phk): Fail the sbuf if vsnprintf(3) fails. r321109: Fix whitespace regression accidentally checked in via ^/head@r280149
Diffstat (limited to 'share')
-rw-r--r--share/man/man9/sbuf.925
1 files changed, 24 insertions, 1 deletions
diff --git a/share/man/man9/sbuf.9 b/share/man/man9/sbuf.9
index a74a569..4dcb894 100644
--- a/share/man/man9/sbuf.9
+++ b/share/man/man9/sbuf.9
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 11, 2013
+.Dd March 14, 2015
.Dt SBUF 9
.Os
.Sh NAME
@@ -34,6 +34,9 @@
.Nm sbuf_new_auto ,
.Nm sbuf_new_for_sysctl ,
.Nm sbuf_clear ,
+.Nm sbuf_get_flags ,
+.Nm sbuf_set_flags ,
+.Nm sbuf_clear_flags ,
.Nm sbuf_setpos ,
.Nm sbuf_bcat ,
.Nm sbuf_bcopyin ,
@@ -69,6 +72,12 @@
.Ft void
.Fn sbuf_clear "struct sbuf *s"
.Ft int
+.Fn sbuf_get_flags "struct sbuf *s"
+.Ft void
+.Fn sbuf_set_flags "struct sbuf *s" "int flags"
+.Ft void
+.Fn sbuf_clear_flags "struct sbuf *s" "int flags"
+.Ft int
.Fn sbuf_setpos "struct sbuf *s" "int pos"
.Ft int
.Fn sbuf_bcat "struct sbuf *s" "const void *buf" "size_t len"
@@ -171,6 +180,8 @@ Attempting to extend the sbuf beyond this size results in an overflow condition.
.It Dv SBUF_AUTOEXTEND
This indicates that the storage buffer may be extended as necessary, so long
as resources allow, to hold additional data.
+.It Dv SBUF_INCLUDENUL
+This causes the final nulterm byte to be counted in the length of the data.
.El
.Pp
Note that if
@@ -223,6 +234,18 @@ function invalidates the contents of the
and resets its position to zero.
.Pp
The
+.Fn sbuf_get_flags
+function returns the current user flags.
+The
+.Fn sbuf_set_flags
+and
+.Fn sbuf_get_flags
+functions set or clear one or more user flags, respectively.
+The user flags are described under the
+.Fn sbuf_new
+function.
+.Pp
+The
.Fn sbuf_setpos
function sets the
.Fa sbuf Ns 's
OpenPOWER on IntegriCloud