xref: /freebsd/share/man/man9/sbuf.9 (revision c5f9218b48ead7bd8838450c541449bb221ed9bc)
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.\"
28371c0c84SKelly Yancey.Dd January 3, 2002
295f95f24bSRuslan Ermilov.Dt SBUF 9
303d45e180SRuslan Ermilov.Os
31863edaecSDag-Erling Smørgrav.Sh NAME
32863edaecSDag-Erling Smørgrav.Nm sbuf_new ,
33e499b74dSDag-Erling Smørgrav.Nm sbuf_clear ,
34863edaecSDag-Erling Smørgrav.Nm sbuf_setpos ,
35b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcat ,
36b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcopyin ,
37b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcpy ,
38863edaecSDag-Erling Smørgrav.Nm sbuf_cat ,
39b0def2b5SDag-Erling Smørgrav.Nm sbuf_copyin ,
40863edaecSDag-Erling Smørgrav.Nm sbuf_cpy ,
41863edaecSDag-Erling Smørgrav.Nm sbuf_printf ,
42371c0c84SKelly Yancey.Nm sbuf_vprintf ,
43863edaecSDag-Erling Smørgrav.Nm sbuf_putc ,
44371c0c84SKelly Yancey.Nm sbuf_trim ,
45e499b74dSDag-Erling Smørgrav.Nm sbuf_overflowed ,
46863edaecSDag-Erling Smørgrav.Nm sbuf_finish ,
47863edaecSDag-Erling Smørgrav.Nm sbuf_data ,
48863edaecSDag-Erling Smørgrav.Nm sbuf_len ,
49c5f9218bSPoul-Henning Kamp.Nm sbuf_done ,
50863edaecSDag-Erling Smørgrav.Nm sbuf_delete
51863edaecSDag-Erling Smørgrav.Nd safe string formatting
52863edaecSDag-Erling Smørgrav.Sh SYNOPSIS
5332eef9aeSRuslan Ermilov.In sys/types.h
5432eef9aeSRuslan Ermilov.In sys/sbuf.h
558a5bc771SBruce Evans.Ft struct sbuf *
56e499b74dSDag-Erling Smørgrav.Fn sbuf_new "struct sbuf *s" "char *buf" "int length" "int flags"
57e499b74dSDag-Erling Smørgrav.Ft void
58e499b74dSDag-Erling Smørgrav.Fn sbuf_clear "struct sbuf *s"
59863edaecSDag-Erling Smørgrav.Ft int
60e499b74dSDag-Erling Smørgrav.Fn sbuf_setpos "struct sbuf *s" "int pos"
61863edaecSDag-Erling Smørgrav.Ft int
62b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcat "struct sbuf *s" "const char *str" "size_t len"
63b0def2b5SDag-Erling Smørgrav.Ft int
64b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcopyin "struct sbuf *s" "const void *uaddr" "size_t len"
65b0def2b5SDag-Erling Smørgrav.Ft int
66b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcpy "struct sbuf *s" "const char *str" "size_t len"
67b0def2b5SDag-Erling Smørgrav.Ft int
683393f8daSKenneth D. Merry.Fn sbuf_cat "struct sbuf *s" "const char *str"
69863edaecSDag-Erling Smørgrav.Ft int
70b0def2b5SDag-Erling Smørgrav.Fn sbuf_copyin "struct sbuf *s" "const void *uaddr" "size_t len"
71b0def2b5SDag-Erling Smørgrav.Ft int
723393f8daSKenneth D. Merry.Fn sbuf_cpy "struct sbuf *s" "const char *str"
73863edaecSDag-Erling Smørgrav.Ft int
748cce2ebaSDag-Erling Smørgrav.Fn sbuf_printf "struct sbuf *s" "const char *fmt" "..."
75863edaecSDag-Erling Smørgrav.Ft int
76371c0c84SKelly Yancey.Fn sbuf_vprintf "struct sbuf *s" "const char *fmt" "va_list ap"
77371c0c84SKelly Yancey.Ft int
78863edaecSDag-Erling Smørgrav.Fn sbuf_putc "struct sbuf *s" "int c"
79863edaecSDag-Erling Smørgrav.Ft int
80371c0c84SKelly Yancey.Fn sbuf_trim "struct sbuf *s"
81371c0c84SKelly Yancey.Ft int
82e499b74dSDag-Erling Smørgrav.Fn sbuf_overflowed "struct sbuf *s"
83e499b74dSDag-Erling Smørgrav.Ft void
84863edaecSDag-Erling Smørgrav.Fn sbuf_finish "struct sbuf *s"
85863edaecSDag-Erling Smørgrav.Ft char *
86863edaecSDag-Erling Smørgrav.Fn sbuf_data "struct sbuf *s"
87e499b74dSDag-Erling Smørgrav.Ft int
88863edaecSDag-Erling Smørgrav.Fn sbuf_len "struct sbuf *s"
89c5f9218bSPoul-Henning Kamp.Ft int
90c5f9218bSPoul-Henning Kamp.Fn sbuf_done "struct sbuf *s"
91863edaecSDag-Erling Smørgrav.Ft void
92863edaecSDag-Erling Smørgrav.Fn sbuf_delete "struct sbuf *s"
93863edaecSDag-Erling Smørgrav.Sh DESCRIPTION
94863edaecSDag-Erling SmørgravThe
95863edaecSDag-Erling Smørgrav.Nm sbuf
9667e35919SSheldon Hearnfamily of functions allows one to safely allocate, construct and
97863edaecSDag-Erling Smørgravrelease bounded null-terminated strings in kernel space.
98863edaecSDag-Erling SmørgravInstead of arrays of characters, these functions operate on structures
99863edaecSDag-Erling Smørgravcalled
100863edaecSDag-Erling Smørgrav.Fa sbufs ,
101863edaecSDag-Erling Smørgravdefined in
102863edaecSDag-Erling Smørgrav.Aq Pa sys/sbuf.h .
103863edaecSDag-Erling Smørgrav.Pp
104863edaecSDag-Erling SmørgravThe
105863edaecSDag-Erling Smørgrav.Fn sbuf_new
106863edaecSDag-Erling Smørgravfunction initializes the
107863edaecSDag-Erling Smørgrav.Fa sbuf
108863edaecSDag-Erling Smørgravpointed to by its first argument.
109d6479358SDag-Erling SmørgravIf that pointer is
110d6479358SDag-Erling Smørgrav.Dv NULL ,
111d6479358SDag-Erling Smørgrav.Fn sbuf_new
112d6479358SDag-Erling Smørgravallocates a
113d68b700aSRuslan Ermilov.Vt struct sbuf
114d6479358SDag-Erling Smørgravusing
115d6479358SDag-Erling Smørgrav.Xr malloc 9 .
116863edaecSDag-Erling SmørgravThe
117863edaecSDag-Erling Smørgrav.Fa buf
118863edaecSDag-Erling Smørgravargument is a pointer to a buffer in which to store the actual string;
119863edaecSDag-Erling Smørgravif it is
120863edaecSDag-Erling Smørgrav.Dv NULL ,
121863edaecSDag-Erling Smørgrav.Fn sbuf_new
122863edaecSDag-Erling Smørgravwill allocate one using
123863edaecSDag-Erling Smørgrav.Xr malloc 9 .
124863edaecSDag-Erling SmørgravThe
125863edaecSDag-Erling Smørgrav.Fa length
126371c0c84SKelly Yanceyis the initial size of the storage buffer.
127863edaecSDag-Erling SmørgravThe fourth argument,
128863edaecSDag-Erling Smørgrav.Fa flags ,
129371c0c84SKelly Yanceymay be comprised of the following flags:
1303b0536faSRuslan Ermilov.Bl -tag -width ".Dv SBUF_AUTOEXTEND"
131371c0c84SKelly Yancey.It Dv SBUF_FIXEDLEN
1323b0536faSRuslan ErmilovThe storage buffer is fixed at its initial size.
133371c0c84SKelly YanceyAttempting to extend the sbuf beyond this size results in an overflow condition.
134371c0c84SKelly Yancey.It Dv SBUF_AUTOEXTEND
135371c0c84SKelly YanceyThis indicates that the storage buffer may be extended as necessary, so long
136371c0c84SKelly Yanceyas resources allow, to hold additional data.
137371c0c84SKelly Yancey.El
138863edaecSDag-Erling Smørgrav.Pp
139863edaecSDag-Erling SmørgravNote that if
140863edaecSDag-Erling Smørgrav.Fa buf
141863edaecSDag-Erling Smørgravis not
142863edaecSDag-Erling Smørgrav.Dv NULL ,
143863edaecSDag-Erling Smørgravit must point to an array of at least
144863edaecSDag-Erling Smørgrav.Fa length
145863edaecSDag-Erling Smørgravcharacters.
146371c0c84SKelly YanceyThe contents of the provided buffer are undefined; to retrieve the sbuf data
147371c0c84SKelly Yancey.Fn sbuf_data
148371c0c84SKelly Yanceymust be called on the finished
149371c0c84SKelly Yancey.Fa sbuf .
150863edaecSDag-Erling Smørgrav.Pp
151863edaecSDag-Erling SmørgravThe
152e499b74dSDag-Erling Smørgrav.Fn sbuf_clear
153e499b74dSDag-Erling Smørgravfunction invalidates the contents of the
154e499b74dSDag-Erling Smørgrav.Fa sbuf
155e499b74dSDag-Erling Smørgravand resets its position to zero.
156e499b74dSDag-Erling Smørgrav.Pp
157e499b74dSDag-Erling SmørgravThe
158863edaecSDag-Erling Smørgrav.Fn sbuf_setpos
159863edaecSDag-Erling Smørgravfunction sets the
160863edaecSDag-Erling Smørgrav.Fa sbuf Ns 's
161371c0c84SKelly Yanceyend position to
162863edaecSDag-Erling Smørgrav.Fa pos ,
163863edaecSDag-Erling Smørgravwhich is a value between zero and one less than the size of the
164863edaecSDag-Erling Smørgravstorage buffer.
165371c0c84SKelly YanceyThis effectively truncates the sbuf at the new position.
166863edaecSDag-Erling Smørgrav.Pp
167863edaecSDag-Erling SmørgravThe
168b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcat
169b0def2b5SDag-Erling Smørgravfunction appends the first
170b0def2b5SDag-Erling Smørgrav.Fa len
171b0def2b5SDag-Erling Smørgravbytes from the byte string
172b0def2b5SDag-Erling Smørgrav.Fa str
173b0def2b5SDag-Erling Smørgravto the
174b0def2b5SDag-Erling Smørgrav.Fa sbuf .
175b0def2b5SDag-Erling Smørgrav.Pp
176b0def2b5SDag-Erling SmørgravThe
177b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcopyin
178b0def2b5SDag-Erling Smørgravfunction copies
179b0def2b5SDag-Erling Smørgrav.Fa len
180b0def2b5SDag-Erling Smørgravbytes from the specified userland address into the
181b0def2b5SDag-Erling Smørgrav.Fa sbuf .
182b0def2b5SDag-Erling Smørgrav.Pp
183b0def2b5SDag-Erling SmørgravThe
184b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcpy
185b0def2b5SDag-Erling Smørgravfunction replaces the contents of the
186b0def2b5SDag-Erling Smørgrav.Fa sbuf
187b0def2b5SDag-Erling Smørgravwith the first
188b0def2b5SDag-Erling Smørgrav.Fa len
189b0def2b5SDag-Erling Smørgravbytes from the byte string
190b0def2b5SDag-Erling Smørgrav.Fa str .
191b0def2b5SDag-Erling Smørgrav.Pp
192b0def2b5SDag-Erling SmørgravThe
193863edaecSDag-Erling Smørgrav.Fn sbuf_cat
194b0def2b5SDag-Erling Smørgravfunction appends the NUL-terminated string
195863edaecSDag-Erling Smørgrav.Fa str
196863edaecSDag-Erling Smørgravto the
197863edaecSDag-Erling Smørgrav.Fa sbuf
198863edaecSDag-Erling Smørgravat the current position.
199863edaecSDag-Erling Smørgrav.Pp
200863edaecSDag-Erling SmørgravThe
201b0def2b5SDag-Erling Smørgrav.Fn sbuf_copyin
202b0def2b5SDag-Erling Smørgravfunction copies a NUL-terminated string from the specified userland
203b0def2b5SDag-Erling Smørgravaddress into the
204b0def2b5SDag-Erling Smørgrav.Fa sbuf .
205b0def2b5SDag-Erling SmørgravIf the
206b0def2b5SDag-Erling Smørgrav.Fa len
207b0def2b5SDag-Erling Smørgravargument is non-zero, no more than
208b0def2b5SDag-Erling Smørgrav.Fa len
209b0def2b5SDag-Erling Smørgravcharacters (not counting the terminating NUL) are copied; otherwise
210b0def2b5SDag-Erling Smørgravthe entire string, or as much of it as can fit in the
211b0def2b5SDag-Erling Smørgrav.Fa sbuf ,
212b0def2b5SDag-Erling Smørgravis copied.
213b0def2b5SDag-Erling Smørgrav.Pp
214b0def2b5SDag-Erling SmørgravThe
215863edaecSDag-Erling Smørgrav.Fn sbuf_cpy
216863edaecSDag-Erling Smørgravfunction replaces the contents of the
217863edaecSDag-Erling Smørgrav.Fa sbuf
218b0def2b5SDag-Erling Smørgravwith those of the NUL-terminated string
219863edaecSDag-Erling Smørgrav.Fa str .
220863edaecSDag-Erling SmørgravThis is equivalent to calling
221863edaecSDag-Erling Smørgrav.Fn sbuf_cat
222863edaecSDag-Erling Smørgravwith a fresh
223863edaecSDag-Erling Smørgrav.Fa sbuf
224863edaecSDag-Erling Smørgravor one which position has been reset to zero with
225e499b74dSDag-Erling Smørgrav.Fn sbuf_clear
226e499b74dSDag-Erling Smørgravor
227863edaecSDag-Erling Smørgrav.Fn sbuf_setpos .
228863edaecSDag-Erling Smørgrav.Pp
229863edaecSDag-Erling SmørgravThe
230863edaecSDag-Erling Smørgrav.Fn sbuf_printf
231863edaecSDag-Erling Smørgravfunction formats its arguments according to the format string pointed
232863edaecSDag-Erling Smørgravto by
233863edaecSDag-Erling Smørgrav.Fa fmt
234863edaecSDag-Erling Smørgravand appends the resulting string to the
235863edaecSDag-Erling Smørgrav.Fa sbuf
236863edaecSDag-Erling Smørgravat the current position.
237863edaecSDag-Erling Smørgrav.Pp
238863edaecSDag-Erling SmørgravThe
239371c0c84SKelly Yancey.Fn sbuf_vprintf
240371c0c84SKelly Yanceyfunction behaves the same as
241371c0c84SKelly Yancey.Fn sbuf_printf
242371c0c84SKelly Yanceyexcept that the arguments are obtained from the variable-length argument list
243371c0c84SKelly Yancey.Fa ap .
244371c0c84SKelly Yancey.Pp
245371c0c84SKelly YanceyThe
246863edaecSDag-Erling Smørgrav.Fn sbuf_putc
247863edaecSDag-Erling Smørgravfunction appends the character
248863edaecSDag-Erling Smørgrav.Fa c
249863edaecSDag-Erling Smørgravto the
250863edaecSDag-Erling Smørgrav.Fa sbuf
251863edaecSDag-Erling Smørgravat the current position.
252863edaecSDag-Erling Smørgrav.Pp
253863edaecSDag-Erling SmørgravThe
254371c0c84SKelly Yancey.Fn sbuf_trim
255371c0c84SKelly Yanceyfunction removes trailing whitespace from the
256371c0c84SKelly Yancey.Fa sbuf .
257371c0c84SKelly Yancey.Pp
258371c0c84SKelly YanceyThe
259e499b74dSDag-Erling Smørgrav.Fn sbuf_overflowed
260e499b74dSDag-Erling Smørgravfunction returns a non-zero value if the
261e499b74dSDag-Erling Smørgrav.Fa sbuf
262e499b74dSDag-Erling Smørgravoverflowed.
263e499b74dSDag-Erling Smørgrav.Pp
264e499b74dSDag-Erling SmørgravThe
265863edaecSDag-Erling Smørgrav.Fn sbuf_finish
266863edaecSDag-Erling Smørgravfunction null-terminates the
267863edaecSDag-Erling Smørgrav.Fa sbuf
268863edaecSDag-Erling Smørgravand marks it as finished, which means that it may no longer be
269863edaecSDag-Erling Smørgravmodified using
270863edaecSDag-Erling Smørgrav.Fn sbuf_setpos ,
271863edaecSDag-Erling Smørgrav.Fn sbuf_cat ,
2723393f8daSKenneth D. Merry.Fn sbuf_cpy ,
273863edaecSDag-Erling Smørgrav.Fn sbuf_printf
274863edaecSDag-Erling Smørgravor
275863edaecSDag-Erling Smørgrav.Fn sbuf_putc .
276863edaecSDag-Erling Smørgrav.Pp
277863edaecSDag-Erling SmørgravThe
278863edaecSDag-Erling Smørgrav.Fn sbuf_data
279863edaecSDag-Erling Smørgravand
280863edaecSDag-Erling Smørgrav.Fn sbuf_len
281e499b74dSDag-Erling Smørgravfunctions return the actual string and its length, respectively;
282e499b74dSDag-Erling Smørgrav.Fn sbuf_data
283e499b74dSDag-Erling Smørgravonly works on a finished
284863edaecSDag-Erling Smørgrav.Fa sbuf .
285c5f9218bSPoul-Henning Kamp.Fn sbuf_done
286c5f9218bSPoul-Henning Kampreturns non-zero if the sbuf is finished.
287863edaecSDag-Erling Smørgrav.Pp
288863edaecSDag-Erling SmørgravFinally, the
289863edaecSDag-Erling Smørgrav.Fn sbuf_delete
290863edaecSDag-Erling Smørgravfunction clears the
291863edaecSDag-Erling Smørgrav.Fa sbuf
292863edaecSDag-Erling Smørgravand frees its storage buffer if it was allocated by
293863edaecSDag-Erling Smørgrav.Fn sbuf_new .
294863edaecSDag-Erling Smørgrav.Sh NOTES
295863edaecSDag-Erling SmørgravIf an operation caused an
296863edaecSDag-Erling Smørgrav.Fa sbuf
297e499b74dSDag-Erling Smørgravto overflow, most subsequent operations on it will fail until the
298e499b74dSDag-Erling Smørgrav.Fa sbuf
299e499b74dSDag-Erling Smørgravis finished using
300e499b74dSDag-Erling Smørgrav.Fn sbuf_finish
301e499b74dSDag-Erling Smørgravor reset using
302e499b74dSDag-Erling Smørgrav.Fn sbuf_clear ,
303e499b74dSDag-Erling Smørgravor its position is reset to a value between 0 and one less than the
304e499b74dSDag-Erling Smørgravsize of its storage buffer using
305863edaecSDag-Erling Smørgrav.Fn sbuf_setpos ,
306863edaecSDag-Erling Smørgravor it is reinitialized to a sufficiently short string using
307863edaecSDag-Erling Smørgrav.Fn sbuf_cpy .
308863edaecSDag-Erling Smørgrav.Sh RETURN VALUES
309863edaecSDag-Erling Smørgrav.Fn sbuf_new
310d6479358SDag-Erling Smørgravreturns
311d6479358SDag-Erling Smørgrav.Dv NULL
312d6479358SDag-Erling Smørgravif it failed to allocate a storage buffer, and a pointer to the new
313d6479358SDag-Erling Smørgrav.Fa sbuf
314863edaecSDag-Erling Smørgravotherwise.
315863edaecSDag-Erling Smørgrav.Pp
316863edaecSDag-Erling Smørgrav.Fn sbuf_setpos
317863edaecSDag-Erling Smørgravreturns \-1 if
318863edaecSDag-Erling Smørgrav.Fa pos
319863edaecSDag-Erling Smørgravwas invalid, and zero otherwise.
320863edaecSDag-Erling Smørgrav.Pp
321863edaecSDag-Erling Smørgrav.Fn sbuf_cat ,
322863edaecSDag-Erling Smørgrav.Fn sbuf_cpy ,
323863edaecSDag-Erling Smørgrav.Fn sbuf_printf ,
324371c0c84SKelly Yancey.Fn sbuf_putc ,
325863edaecSDag-Erling Smørgravand
326371c0c84SKelly Yancey.Fn sbuf_trim
327863edaecSDag-Erling Smørgravall return \-1 if the buffer overflowed, and zero otherwise.
328863edaecSDag-Erling Smørgrav.Pp
329e499b74dSDag-Erling Smørgrav.Fn sbuf_overflowed
330e499b74dSDag-Erling Smørgravreturns a non-zero value if the buffer overflowed, and zero otherwise.
331e499b74dSDag-Erling Smørgrav.Pp
332863edaecSDag-Erling Smørgrav.Fn sbuf_data
333863edaecSDag-Erling Smørgravand
334863edaecSDag-Erling Smørgrav.Fn sbuf_len
335863edaecSDag-Erling Smørgravreturn
336863edaecSDag-Erling Smørgrav.Dv NULL
337e499b74dSDag-Erling Smørgravand \-1, respectively, if the buffer overflowed.
338863edaecSDag-Erling Smørgrav.Sh SEE ALSO
339863edaecSDag-Erling Smørgrav.Xr printf 3 ,
340863edaecSDag-Erling Smørgrav.Xr strcat 3 ,
341d68b700aSRuslan Ermilov.Xr strcpy 3 ,
342d68b700aSRuslan Ermilov.Xr copyin 9 ,
343e05f3134SAndrew R. Reiter.Xr copyinstr 9 ,
344e05f3134SAndrew R. Reiter.Xr printf 9
345863edaecSDag-Erling Smørgrav.Sh HISTORY
346863edaecSDag-Erling SmørgravThe
347863edaecSDag-Erling Smørgrav.Nm sbuf
348863edaecSDag-Erling Smørgravfamily of functions first appeared in
34922cbe5e3SDag-Erling Smørgrav.Fx 4.4 .
350863edaecSDag-Erling Smørgrav.Sh AUTHORS
351863edaecSDag-Erling Smørgrav.An -nosplit
352863edaecSDag-Erling SmørgravThe
353863edaecSDag-Erling Smørgrav.Nm sbuf
354863edaecSDag-Erling Smørgravfamily of functions was designed by
355863edaecSDag-Erling Smørgrav.An Poul-Henning Kamp Aq phk@FreeBSD.org
356863edaecSDag-Erling Smørgravand implemented by
357863edaecSDag-Erling Smørgrav.An Dag-Erling Co\(:idan Sm\(/orgrav Aq des@FreeBSD.org .
358e499b74dSDag-Erling SmørgravAdditional improvements were suggested by
359e499b74dSDag-Erling Smørgrav.An Justin T. Gibbs Aq gibbs@FreeBSD.org .
360371c0c84SKelly YanceyAuto-extend support added by
361371c0c84SKelly Yancey.An Kelly Yancey Aq kbyanc@FreeBSD.org .
362863edaecSDag-Erling Smørgrav.Pp
363863edaecSDag-Erling SmørgravThis manual page was written by
364863edaecSDag-Erling Smørgrav.An Dag-Erling Co\(:idan Sm\(/orgrav .
365