xref: /freebsd/share/man/man9/sbuf.9 (revision 81ae4b8da9920ccfb697984dbb2e8751573d183a)
1863edaecSDag-Erling Smørgrav.\"-
2863edaecSDag-Erling Smørgrav.\" Copyright (c) 2000 Poul Henning Kamp and Dag-Erling Co�dan Sm�rgrav
3863edaecSDag-Erling Smørgrav.\" All rights reserved.
4863edaecSDag-Erling Smørgrav.\"
5863edaecSDag-Erling Smørgrav.\" Redistribution and use in source and binary forms, with or without
6863edaecSDag-Erling Smørgrav.\" modification, are permitted provided that the following conditions
7863edaecSDag-Erling Smørgrav.\" are met:
8863edaecSDag-Erling Smørgrav.\" 1. Redistributions of source code must retain the above copyright
9863edaecSDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer.
10863edaecSDag-Erling Smørgrav.\" 2. Redistributions in binary form must reproduce the above copyright
11863edaecSDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer in the
12863edaecSDag-Erling Smørgrav.\"    documentation and/or other materials provided with the distribution.
13863edaecSDag-Erling Smørgrav.\"
14863edaecSDag-Erling Smørgrav.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15863edaecSDag-Erling Smørgrav.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16863edaecSDag-Erling Smørgrav.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17863edaecSDag-Erling Smørgrav.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18863edaecSDag-Erling Smørgrav.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19863edaecSDag-Erling Smørgrav.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20863edaecSDag-Erling Smørgrav.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21863edaecSDag-Erling Smørgrav.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22863edaecSDag-Erling Smørgrav.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23863edaecSDag-Erling Smørgrav.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24863edaecSDag-Erling Smørgrav.\" SUCH DAMAGE.
25863edaecSDag-Erling Smørgrav.\"
26863edaecSDag-Erling Smørgrav.\" $FreeBSD$
27863edaecSDag-Erling Smørgrav.\"
289f5965ddSDag-Erling Smørgrav.Dd July 9, 2004
295f95f24bSRuslan Ermilov.Dt SBUF 9
303d45e180SRuslan Ermilov.Os
31863edaecSDag-Erling Smørgrav.Sh NAME
3281ae4b8dSRuslan Ermilov.Nm sbuf ,
33863edaecSDag-Erling Smørgrav.Nm sbuf_new ,
34e499b74dSDag-Erling Smørgrav.Nm sbuf_clear ,
35863edaecSDag-Erling Smørgrav.Nm sbuf_setpos ,
36b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcat ,
37b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcopyin ,
38b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcpy ,
39863edaecSDag-Erling Smørgrav.Nm sbuf_cat ,
40b0def2b5SDag-Erling Smørgrav.Nm sbuf_copyin ,
41863edaecSDag-Erling Smørgrav.Nm sbuf_cpy ,
42863edaecSDag-Erling Smørgrav.Nm sbuf_printf ,
43371c0c84SKelly Yancey.Nm sbuf_vprintf ,
44863edaecSDag-Erling Smørgrav.Nm sbuf_putc ,
45371c0c84SKelly Yancey.Nm sbuf_trim ,
46e499b74dSDag-Erling Smørgrav.Nm sbuf_overflowed ,
47863edaecSDag-Erling Smørgrav.Nm sbuf_finish ,
48863edaecSDag-Erling Smørgrav.Nm sbuf_data ,
49863edaecSDag-Erling Smørgrav.Nm sbuf_len ,
50c5f9218bSPoul-Henning Kamp.Nm sbuf_done ,
51863edaecSDag-Erling Smørgrav.Nm sbuf_delete
52863edaecSDag-Erling Smørgrav.Nd safe string formatting
53863edaecSDag-Erling Smørgrav.Sh SYNOPSIS
5432eef9aeSRuslan Ermilov.In sys/types.h
5532eef9aeSRuslan Ermilov.In sys/sbuf.h
568a5bc771SBruce Evans.Ft struct sbuf *
57e499b74dSDag-Erling Smørgrav.Fn sbuf_new "struct sbuf *s" "char *buf" "int length" "int flags"
58e499b74dSDag-Erling Smørgrav.Ft void
59e499b74dSDag-Erling Smørgrav.Fn sbuf_clear "struct sbuf *s"
60863edaecSDag-Erling Smørgrav.Ft int
61e499b74dSDag-Erling Smørgrav.Fn sbuf_setpos "struct sbuf *s" "int pos"
62863edaecSDag-Erling Smørgrav.Ft int
634aa90de3SDag-Erling Smørgrav.Fn sbuf_bcat "struct sbuf *s" "const void *buf" "size_t len"
64b0def2b5SDag-Erling Smørgrav.Ft int
65b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcopyin "struct sbuf *s" "const void *uaddr" "size_t len"
66b0def2b5SDag-Erling Smørgrav.Ft int
674aa90de3SDag-Erling Smørgrav.Fn sbuf_bcpy "struct sbuf *s" "const void *buf" "size_t len"
68b0def2b5SDag-Erling Smørgrav.Ft int
693393f8daSKenneth D. Merry.Fn sbuf_cat "struct sbuf *s" "const char *str"
70863edaecSDag-Erling Smørgrav.Ft int
71b0def2b5SDag-Erling Smørgrav.Fn sbuf_copyin "struct sbuf *s" "const void *uaddr" "size_t len"
72b0def2b5SDag-Erling Smørgrav.Ft int
733393f8daSKenneth D. Merry.Fn sbuf_cpy "struct sbuf *s" "const char *str"
74863edaecSDag-Erling Smørgrav.Ft int
758cce2ebaSDag-Erling Smørgrav.Fn sbuf_printf "struct sbuf *s" "const char *fmt" "..."
76863edaecSDag-Erling Smørgrav.Ft int
77371c0c84SKelly Yancey.Fn sbuf_vprintf "struct sbuf *s" "const char *fmt" "va_list ap"
78371c0c84SKelly Yancey.Ft int
79863edaecSDag-Erling Smørgrav.Fn sbuf_putc "struct sbuf *s" "int c"
80863edaecSDag-Erling Smørgrav.Ft int
81371c0c84SKelly Yancey.Fn sbuf_trim "struct sbuf *s"
82371c0c84SKelly Yancey.Ft int
83e499b74dSDag-Erling Smørgrav.Fn sbuf_overflowed "struct sbuf *s"
84e499b74dSDag-Erling Smørgrav.Ft void
85863edaecSDag-Erling Smørgrav.Fn sbuf_finish "struct sbuf *s"
86863edaecSDag-Erling Smørgrav.Ft char *
87863edaecSDag-Erling Smørgrav.Fn sbuf_data "struct sbuf *s"
88e499b74dSDag-Erling Smørgrav.Ft int
89863edaecSDag-Erling Smørgrav.Fn sbuf_len "struct sbuf *s"
90c5f9218bSPoul-Henning Kamp.Ft int
91c5f9218bSPoul-Henning Kamp.Fn sbuf_done "struct sbuf *s"
92863edaecSDag-Erling Smørgrav.Ft void
93863edaecSDag-Erling Smørgrav.Fn sbuf_delete "struct sbuf *s"
94863edaecSDag-Erling Smørgrav.Sh DESCRIPTION
95863edaecSDag-Erling SmørgravThe
9681ae4b8dSRuslan Ermilov.Nm
9767e35919SSheldon Hearnfamily of functions allows one to safely allocate, construct and
98863edaecSDag-Erling Smørgravrelease bounded null-terminated strings in kernel space.
99863edaecSDag-Erling SmørgravInstead of arrays of characters, these functions operate on structures
100863edaecSDag-Erling Smørgravcalled
101863edaecSDag-Erling Smørgrav.Fa sbufs ,
102863edaecSDag-Erling Smørgravdefined in
103fe08efe6SRuslan Ermilov.In sys/sbuf.h .
104863edaecSDag-Erling Smørgrav.Pp
105863edaecSDag-Erling SmørgravThe
106863edaecSDag-Erling Smørgrav.Fn sbuf_new
107863edaecSDag-Erling Smørgravfunction initializes the
108863edaecSDag-Erling Smørgrav.Fa sbuf
109863edaecSDag-Erling Smørgravpointed to by its first argument.
110d6479358SDag-Erling SmørgravIf that pointer is
111d6479358SDag-Erling Smørgrav.Dv NULL ,
112d6479358SDag-Erling Smørgrav.Fn sbuf_new
113d6479358SDag-Erling Smørgravallocates a
114d68b700aSRuslan Ermilov.Vt struct sbuf
115d6479358SDag-Erling Smørgravusing
116d6479358SDag-Erling Smørgrav.Xr malloc 9 .
117863edaecSDag-Erling SmørgravThe
118863edaecSDag-Erling Smørgrav.Fa buf
119863edaecSDag-Erling Smørgravargument is a pointer to a buffer in which to store the actual string;
120863edaecSDag-Erling Smørgravif it is
121863edaecSDag-Erling Smørgrav.Dv NULL ,
122863edaecSDag-Erling Smørgrav.Fn sbuf_new
123863edaecSDag-Erling Smørgravwill allocate one using
124863edaecSDag-Erling Smørgrav.Xr malloc 9 .
125863edaecSDag-Erling SmørgravThe
126863edaecSDag-Erling Smørgrav.Fa length
127371c0c84SKelly Yanceyis the initial size of the storage buffer.
128863edaecSDag-Erling SmørgravThe fourth argument,
129863edaecSDag-Erling Smørgrav.Fa flags ,
130371c0c84SKelly Yanceymay be comprised of the following flags:
1313b0536faSRuslan Ermilov.Bl -tag -width ".Dv SBUF_AUTOEXTEND"
132371c0c84SKelly Yancey.It Dv SBUF_FIXEDLEN
1333b0536faSRuslan ErmilovThe storage buffer is fixed at its initial size.
134371c0c84SKelly YanceyAttempting to extend the sbuf beyond this size results in an overflow condition.
135371c0c84SKelly Yancey.It Dv SBUF_AUTOEXTEND
136371c0c84SKelly YanceyThis indicates that the storage buffer may be extended as necessary, so long
137371c0c84SKelly Yanceyas resources allow, to hold additional data.
138371c0c84SKelly Yancey.El
139863edaecSDag-Erling Smørgrav.Pp
140863edaecSDag-Erling SmørgravNote that if
141863edaecSDag-Erling Smørgrav.Fa buf
142863edaecSDag-Erling Smørgravis not
143863edaecSDag-Erling Smørgrav.Dv NULL ,
144863edaecSDag-Erling Smørgravit must point to an array of at least
145863edaecSDag-Erling Smørgrav.Fa length
146863edaecSDag-Erling Smørgravcharacters.
14791c9d24eSDag-Erling SmørgravThe result of accessing that array directly while it is in use by the
14891c9d24eSDag-Erling Smørgravsbuf is undefined.
14991c9d24eSDag-Erling Smørgrav.Pp
15091c9d24eSDag-Erling SmørgravThe
15191c9d24eSDag-Erling Smørgrav.Fn sbuf_delete
15291c9d24eSDag-Erling Smørgravfunction clears the
15391c9d24eSDag-Erling Smørgrav.Fa sbuf
15491c9d24eSDag-Erling Smørgravand frees any memory allocated for it.
15591c9d24eSDag-Erling SmørgravThere must be a call to
15691c9d24eSDag-Erling Smørgrav.Fn sbuf_delete
15791c9d24eSDag-Erling Smørgravfor every call to
15891c9d24eSDag-Erling Smørgrav.Fn sbuf_new .
15991c9d24eSDag-Erling SmørgravAny attempt to access the sbuf after it has been deleted will fail.
160863edaecSDag-Erling Smørgrav.Pp
161863edaecSDag-Erling SmørgravThe
162e499b74dSDag-Erling Smørgrav.Fn sbuf_clear
163e499b74dSDag-Erling Smørgravfunction invalidates the contents of the
164e499b74dSDag-Erling Smørgrav.Fa sbuf
165e499b74dSDag-Erling Smørgravand resets its position to zero.
166e499b74dSDag-Erling Smørgrav.Pp
167e499b74dSDag-Erling SmørgravThe
168863edaecSDag-Erling Smørgrav.Fn sbuf_setpos
169863edaecSDag-Erling Smørgravfunction sets the
170863edaecSDag-Erling Smørgrav.Fa sbuf Ns 's
171371c0c84SKelly Yanceyend position to
172863edaecSDag-Erling Smørgrav.Fa pos ,
173863edaecSDag-Erling Smørgravwhich is a value between zero and one less than the size of the
174863edaecSDag-Erling Smørgravstorage buffer.
175371c0c84SKelly YanceyThis effectively truncates the sbuf at the new position.
176863edaecSDag-Erling Smørgrav.Pp
177863edaecSDag-Erling SmørgravThe
178b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcat
179b0def2b5SDag-Erling Smørgravfunction appends the first
180b0def2b5SDag-Erling Smørgrav.Fa len
1814aa90de3SDag-Erling Smørgravbytes from the buffer
1824aa90de3SDag-Erling Smørgrav.Fa buf
183b0def2b5SDag-Erling Smørgravto the
184b0def2b5SDag-Erling Smørgrav.Fa sbuf .
185b0def2b5SDag-Erling Smørgrav.Pp
186b0def2b5SDag-Erling SmørgravThe
187b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcopyin
188b0def2b5SDag-Erling Smørgravfunction copies
189b0def2b5SDag-Erling Smørgrav.Fa len
190b0def2b5SDag-Erling Smørgravbytes from the specified userland address into the
191b0def2b5SDag-Erling Smørgrav.Fa sbuf .
192b0def2b5SDag-Erling Smørgrav.Pp
193b0def2b5SDag-Erling SmørgravThe
194b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcpy
195b0def2b5SDag-Erling Smørgravfunction replaces the contents of the
196b0def2b5SDag-Erling Smørgrav.Fa sbuf
197b0def2b5SDag-Erling Smørgravwith the first
198b0def2b5SDag-Erling Smørgrav.Fa len
1994aa90de3SDag-Erling Smørgravbytes from the buffer
2004aa90de3SDag-Erling Smørgrav.Fa buf .
201b0def2b5SDag-Erling Smørgrav.Pp
202b0def2b5SDag-Erling SmørgravThe
203863edaecSDag-Erling Smørgrav.Fn sbuf_cat
204b0def2b5SDag-Erling Smørgravfunction appends the NUL-terminated string
205863edaecSDag-Erling Smørgrav.Fa str
206863edaecSDag-Erling Smørgravto the
207863edaecSDag-Erling Smørgrav.Fa sbuf
208863edaecSDag-Erling Smørgravat the current position.
209863edaecSDag-Erling Smørgrav.Pp
210863edaecSDag-Erling SmørgravThe
211b0def2b5SDag-Erling Smørgrav.Fn sbuf_copyin
212b0def2b5SDag-Erling Smørgravfunction copies a NUL-terminated string from the specified userland
213b0def2b5SDag-Erling Smørgravaddress into the
214b0def2b5SDag-Erling Smørgrav.Fa sbuf .
215b0def2b5SDag-Erling SmørgravIf the
216b0def2b5SDag-Erling Smørgrav.Fa len
217b0def2b5SDag-Erling Smørgravargument is non-zero, no more than
218b0def2b5SDag-Erling Smørgrav.Fa len
219b0def2b5SDag-Erling Smørgravcharacters (not counting the terminating NUL) are copied; otherwise
220b0def2b5SDag-Erling Smørgravthe entire string, or as much of it as can fit in the
221b0def2b5SDag-Erling Smørgrav.Fa sbuf ,
222b0def2b5SDag-Erling Smørgravis copied.
223b0def2b5SDag-Erling Smørgrav.Pp
224b0def2b5SDag-Erling SmørgravThe
225863edaecSDag-Erling Smørgrav.Fn sbuf_cpy
226863edaecSDag-Erling Smørgravfunction replaces the contents of the
227863edaecSDag-Erling Smørgrav.Fa sbuf
228b0def2b5SDag-Erling Smørgravwith those of the NUL-terminated string
229863edaecSDag-Erling Smørgrav.Fa str .
230863edaecSDag-Erling SmørgravThis is equivalent to calling
231863edaecSDag-Erling Smørgrav.Fn sbuf_cat
232863edaecSDag-Erling Smørgravwith a fresh
233863edaecSDag-Erling Smørgrav.Fa sbuf
234863edaecSDag-Erling Smørgravor one which position has been reset to zero with
235e499b74dSDag-Erling Smørgrav.Fn sbuf_clear
236e499b74dSDag-Erling Smørgravor
237863edaecSDag-Erling Smørgrav.Fn sbuf_setpos .
238863edaecSDag-Erling Smørgrav.Pp
239863edaecSDag-Erling SmørgravThe
240863edaecSDag-Erling Smørgrav.Fn sbuf_printf
241863edaecSDag-Erling Smørgravfunction formats its arguments according to the format string pointed
242863edaecSDag-Erling Smørgravto by
243863edaecSDag-Erling Smørgrav.Fa fmt
244863edaecSDag-Erling Smørgravand appends the resulting string to the
245863edaecSDag-Erling Smørgrav.Fa sbuf
246863edaecSDag-Erling Smørgravat the current position.
247863edaecSDag-Erling Smørgrav.Pp
248863edaecSDag-Erling SmørgravThe
249371c0c84SKelly Yancey.Fn sbuf_vprintf
250371c0c84SKelly Yanceyfunction behaves the same as
251371c0c84SKelly Yancey.Fn sbuf_printf
252371c0c84SKelly Yanceyexcept that the arguments are obtained from the variable-length argument list
253371c0c84SKelly Yancey.Fa ap .
254371c0c84SKelly Yancey.Pp
255371c0c84SKelly YanceyThe
256863edaecSDag-Erling Smørgrav.Fn sbuf_putc
257863edaecSDag-Erling Smørgravfunction appends the character
258863edaecSDag-Erling Smørgrav.Fa c
259863edaecSDag-Erling Smørgravto the
260863edaecSDag-Erling Smørgrav.Fa sbuf
261863edaecSDag-Erling Smørgravat the current position.
262863edaecSDag-Erling Smørgrav.Pp
263863edaecSDag-Erling SmørgravThe
264371c0c84SKelly Yancey.Fn sbuf_trim
265371c0c84SKelly Yanceyfunction removes trailing whitespace from the
266371c0c84SKelly Yancey.Fa sbuf .
267371c0c84SKelly Yancey.Pp
268371c0c84SKelly YanceyThe
269e499b74dSDag-Erling Smørgrav.Fn sbuf_overflowed
270e499b74dSDag-Erling Smørgravfunction returns a non-zero value if the
271e499b74dSDag-Erling Smørgrav.Fa sbuf
272e499b74dSDag-Erling Smørgravoverflowed.
273e499b74dSDag-Erling Smørgrav.Pp
274e499b74dSDag-Erling SmørgravThe
275863edaecSDag-Erling Smørgrav.Fn sbuf_finish
276863edaecSDag-Erling Smørgravfunction null-terminates the
277863edaecSDag-Erling Smørgrav.Fa sbuf
278863edaecSDag-Erling Smørgravand marks it as finished, which means that it may no longer be
279863edaecSDag-Erling Smørgravmodified using
280863edaecSDag-Erling Smørgrav.Fn sbuf_setpos ,
281863edaecSDag-Erling Smørgrav.Fn sbuf_cat ,
2823393f8daSKenneth D. Merry.Fn sbuf_cpy ,
283863edaecSDag-Erling Smørgrav.Fn sbuf_printf
284863edaecSDag-Erling Smørgravor
285863edaecSDag-Erling Smørgrav.Fn sbuf_putc .
286863edaecSDag-Erling Smørgrav.Pp
287863edaecSDag-Erling SmørgravThe
288863edaecSDag-Erling Smørgrav.Fn sbuf_data
289863edaecSDag-Erling Smørgravand
290863edaecSDag-Erling Smørgrav.Fn sbuf_len
291e499b74dSDag-Erling Smørgravfunctions return the actual string and its length, respectively;
292e499b74dSDag-Erling Smørgrav.Fn sbuf_data
293e499b74dSDag-Erling Smørgravonly works on a finished
294863edaecSDag-Erling Smørgrav.Fa sbuf .
295c5f9218bSPoul-Henning Kamp.Fn sbuf_done
296c5f9218bSPoul-Henning Kampreturns non-zero if the sbuf is finished.
297863edaecSDag-Erling Smørgrav.Sh NOTES
298863edaecSDag-Erling SmørgravIf an operation caused an
299863edaecSDag-Erling Smørgrav.Fa sbuf
300e499b74dSDag-Erling Smørgravto overflow, most subsequent operations on it will fail until the
301e499b74dSDag-Erling Smørgrav.Fa sbuf
302e499b74dSDag-Erling Smørgravis finished using
303e499b74dSDag-Erling Smørgrav.Fn sbuf_finish
304e499b74dSDag-Erling Smørgravor reset using
305e499b74dSDag-Erling Smørgrav.Fn sbuf_clear ,
306e499b74dSDag-Erling Smørgravor its position is reset to a value between 0 and one less than the
307e499b74dSDag-Erling Smørgravsize of its storage buffer using
308863edaecSDag-Erling Smørgrav.Fn sbuf_setpos ,
309863edaecSDag-Erling Smørgravor it is reinitialized to a sufficiently short string using
310863edaecSDag-Erling Smørgrav.Fn sbuf_cpy .
311863edaecSDag-Erling Smørgrav.Sh RETURN VALUES
31281ae4b8dSRuslan ErmilovThe
313863edaecSDag-Erling Smørgrav.Fn sbuf_new
31481ae4b8dSRuslan Ermilovfunction returns
315d6479358SDag-Erling Smørgrav.Dv NULL
316d6479358SDag-Erling Smørgravif it failed to allocate a storage buffer, and a pointer to the new
317d6479358SDag-Erling Smørgrav.Fa sbuf
318863edaecSDag-Erling Smørgravotherwise.
319863edaecSDag-Erling Smørgrav.Pp
32081ae4b8dSRuslan ErmilovThe
321863edaecSDag-Erling Smørgrav.Fn sbuf_setpos
32281ae4b8dSRuslan Ermilovfunction returns \-1 if
323863edaecSDag-Erling Smørgrav.Fa pos
324863edaecSDag-Erling Smørgravwas invalid, and zero otherwise.
325863edaecSDag-Erling Smørgrav.Pp
32681ae4b8dSRuslan ErmilovThe
327863edaecSDag-Erling Smørgrav.Fn sbuf_cat ,
328863edaecSDag-Erling Smørgrav.Fn sbuf_cpy ,
329863edaecSDag-Erling Smørgrav.Fn sbuf_printf ,
330371c0c84SKelly Yancey.Fn sbuf_putc ,
331863edaecSDag-Erling Smørgravand
332371c0c84SKelly Yancey.Fn sbuf_trim
33381ae4b8dSRuslan Ermilovfunctions
334863edaecSDag-Erling Smørgravall return \-1 if the buffer overflowed, and zero otherwise.
335863edaecSDag-Erling Smørgrav.Pp
33681ae4b8dSRuslan ErmilovThe
337e499b74dSDag-Erling Smørgrav.Fn sbuf_overflowed
33881ae4b8dSRuslan Ermilovfunction
339e499b74dSDag-Erling Smørgravreturns a non-zero value if the buffer overflowed, and zero otherwise.
340e499b74dSDag-Erling Smørgrav.Pp
34181ae4b8dSRuslan ErmilovThe
342863edaecSDag-Erling Smørgrav.Fn sbuf_data
343863edaecSDag-Erling Smørgravand
344863edaecSDag-Erling Smørgrav.Fn sbuf_len
34581ae4b8dSRuslan Ermilovfunctions return
346863edaecSDag-Erling Smørgrav.Dv NULL
347e499b74dSDag-Erling Smørgravand \-1, respectively, if the buffer overflowed.
34849091c48SPoul-Henning Kamp.Pp
34981ae4b8dSRuslan ErmilovThe
35049091c48SPoul-Henning Kamp.Fn sbuf_copyin
35181ae4b8dSRuslan Ermilovfunction
35249091c48SPoul-Henning Kampreturns \-1 if copying string from userland failed, and number of bytes
35349091c48SPoul-Henning Kampcopied otherwise.
354863edaecSDag-Erling Smørgrav.Sh SEE ALSO
355863edaecSDag-Erling Smørgrav.Xr printf 3 ,
356863edaecSDag-Erling Smørgrav.Xr strcat 3 ,
357d68b700aSRuslan Ermilov.Xr strcpy 3 ,
358d68b700aSRuslan Ermilov.Xr copyin 9 ,
359e05f3134SAndrew R. Reiter.Xr copyinstr 9 ,
360e05f3134SAndrew R. Reiter.Xr printf 9
361863edaecSDag-Erling Smørgrav.Sh HISTORY
362863edaecSDag-Erling SmørgravThe
36381ae4b8dSRuslan Ermilov.Nm
364863edaecSDag-Erling Smørgravfamily of functions first appeared in
36522cbe5e3SDag-Erling Smørgrav.Fx 4.4 .
366863edaecSDag-Erling Smørgrav.Sh AUTHORS
367863edaecSDag-Erling Smørgrav.An -nosplit
368863edaecSDag-Erling SmørgravThe
36981ae4b8dSRuslan Ermilov.Nm
370863edaecSDag-Erling Smørgravfamily of functions was designed by
371863edaecSDag-Erling Smørgrav.An Poul-Henning Kamp Aq phk@FreeBSD.org
372863edaecSDag-Erling Smørgravand implemented by
37309e06539SDag-Erling Smørgrav.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
374e499b74dSDag-Erling SmørgravAdditional improvements were suggested by
375e499b74dSDag-Erling Smørgrav.An Justin T. Gibbs Aq gibbs@FreeBSD.org .
376371c0c84SKelly YanceyAuto-extend support added by
377371c0c84SKelly Yancey.An Kelly Yancey Aq kbyanc@FreeBSD.org .
378863edaecSDag-Erling Smørgrav.Pp
379863edaecSDag-Erling SmørgravThis manual page was written by
38009e06539SDag-Erling Smørgrav.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
381