xref: /freebsd/share/man/man9/sbuf.9 (revision 5a82fc7859f746d95811e43b3a117b8eea297749)
1863edaecSDag-Erling Smørgrav.\"-
2e738085bSDag-Erling Smørgrav.\" Copyright (c) 2000 Poul-Henning Kamp and Dag-Erling 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.\"
26*5a82fc78SMateusz Piotrowski.Dd October 3, 2023
275f95f24bSRuslan Ermilov.Dt SBUF 9
283d45e180SRuslan Ermilov.Os
29863edaecSDag-Erling Smørgrav.Sh NAME
3081ae4b8dSRuslan Ermilov.Nm sbuf ,
31863edaecSDag-Erling Smørgrav.Nm sbuf_new ,
3272fba9d7SChristian Brueffer.Nm sbuf_new_auto ,
337c2dd57bSMatthew D Fleming.Nm sbuf_new_for_sysctl ,
34e499b74dSDag-Erling Smørgrav.Nm sbuf_clear ,
35f4d28142SIan Lepore.Nm sbuf_get_flags ,
36f4d28142SIan Lepore.Nm sbuf_set_flags ,
37f4d28142SIan Lepore.Nm sbuf_clear_flags ,
38863edaecSDag-Erling Smørgrav.Nm sbuf_setpos ,
39b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcat ,
40b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcopyin ,
41b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcpy ,
42863edaecSDag-Erling Smørgrav.Nm sbuf_cat ,
43b0def2b5SDag-Erling Smørgrav.Nm sbuf_copyin ,
44863edaecSDag-Erling Smørgrav.Nm sbuf_cpy ,
4576cb1112SConrad Meyer.Nm sbuf_nl_terminate ,
46863edaecSDag-Erling Smørgrav.Nm sbuf_printf ,
47371c0c84SKelly Yancey.Nm sbuf_vprintf ,
48863edaecSDag-Erling Smørgrav.Nm sbuf_putc ,
494351ba27SMatthew D Fleming.Nm sbuf_set_drain ,
50371c0c84SKelly Yancey.Nm sbuf_trim ,
514d369413SMatthew D Fleming.Nm sbuf_error ,
52863edaecSDag-Erling Smørgrav.Nm sbuf_finish ,
53863edaecSDag-Erling Smørgrav.Nm sbuf_data ,
54863edaecSDag-Erling Smørgrav.Nm sbuf_len ,
55c5f9218bSPoul-Henning Kamp.Nm sbuf_done ,
56f02db7b4SMikolaj Golub.Nm sbuf_delete ,
57f02db7b4SMikolaj Golub.Nm sbuf_start_section ,
585672fac9SKenneth D. Merry.Nm sbuf_end_section ,
59388f3ce6SScott Long.Nm sbuf_hexdump ,
607d7db529SConrad Meyer.Nm sbuf_printf_drain ,
61388f3ce6SScott Long.Nm sbuf_putbuf
626ab7244aSPoul-Henning Kamp.Nd safe string composition
63*5a82fc78SMateusz Piotrowski.Sh LIBRARY
64*5a82fc78SMateusz Piotrowski.Lb libsbuf
65863edaecSDag-Erling Smørgrav.Sh SYNOPSIS
6632eef9aeSRuslan Ermilov.In sys/types.h
6732eef9aeSRuslan Ermilov.In sys/sbuf.h
68e3e46985SYuri Pankov.Ft typedef int
69e3e46985SYuri Pankov.Fo (sbuf_drain_func)
70e3e46985SYuri Pankov.Fa "void *arg"
71e3e46985SYuri Pankov.Fa "const char *data"
72e3e46985SYuri Pankov.Fa "int len"
73e3e46985SYuri Pankov.Fc
744351ba27SMatthew D Fleming.Pp
758a5bc771SBruce Evans.Ft struct sbuf *
76a6848fd5SEnji Cooper.Fo sbuf_new
77a6848fd5SEnji Cooper.Fa "struct sbuf *s"
78a6848fd5SEnji Cooper.Fa "char *buf"
79a6848fd5SEnji Cooper.Fa "int length"
80a6848fd5SEnji Cooper.Fa "int flags"
81a6848fd5SEnji Cooper.Fc
8272fba9d7SChristian Brueffer.Ft struct sbuf *
83a6848fd5SEnji Cooper.Fo sbuf_new_auto
84a6848fd5SEnji Cooper.Fa "void"
85a6848fd5SEnji Cooper.Fc
86e499b74dSDag-Erling Smørgrav.Ft void
87a6848fd5SEnji Cooper.Fo sbuf_clear
88a6848fd5SEnji Cooper.Fa "struct sbuf *s"
89a6848fd5SEnji Cooper.Fc
90863edaecSDag-Erling Smørgrav.Ft int
91a6848fd5SEnji Cooper.Fo sbuf_get_flags
92a6848fd5SEnji Cooper.Fa "struct sbuf *s"
93a6848fd5SEnji Cooper.Fc
94f4d28142SIan Lepore.Ft void
95a6848fd5SEnji Cooper.Fo sbuf_set_flags
96a6848fd5SEnji Cooper.Fa "struct sbuf *s"
97a6848fd5SEnji Cooper.Fa "int flags"
98a6848fd5SEnji Cooper.Fc
99f4d28142SIan Lepore.Ft void
100a6848fd5SEnji Cooper.Fo sbuf_clear_flags
101a6848fd5SEnji Cooper.Fa "struct sbuf *s"
102a6848fd5SEnji Cooper.Fa "int flags"
103a6848fd5SEnji Cooper.Fc
104f4d28142SIan Lepore.Ft int
105a6848fd5SEnji Cooper.Fo sbuf_setpos
106a6848fd5SEnji Cooper.Fa "struct sbuf *s"
107a6848fd5SEnji Cooper.Fa "int pos"
108a6848fd5SEnji Cooper.Fc
109863edaecSDag-Erling Smørgrav.Ft int
110a6848fd5SEnji Cooper.Fo sbuf_bcat
111a6848fd5SEnji Cooper.Fa "struct sbuf *s"
112a6848fd5SEnji Cooper.Fa "const void *buf"
113a6848fd5SEnji Cooper.Fa "size_t len"
114a6848fd5SEnji Cooper.Fc
115b0def2b5SDag-Erling Smørgrav.Ft int
116a6848fd5SEnji Cooper.Fo sbuf_bcpy
117a6848fd5SEnji Cooper.Fa "struct sbuf *s"
118a6848fd5SEnji Cooper.Fa "const void *buf"
119a6848fd5SEnji Cooper.Fa "size_t len"
120a6848fd5SEnji Cooper.Fc
121b0def2b5SDag-Erling Smørgrav.Ft int
122a6848fd5SEnji Cooper.Fo sbuf_cat
123a6848fd5SEnji Cooper.Fa "struct sbuf *s"
124a6848fd5SEnji Cooper.Fa "const char *str"
125a6848fd5SEnji Cooper.Fc
126863edaecSDag-Erling Smørgrav.Ft int
127a6848fd5SEnji Cooper.Fo sbuf_cpy
128a6848fd5SEnji Cooper.Fa "struct sbuf *s"
129a6848fd5SEnji Cooper.Fa "const char *str"
130a6848fd5SEnji Cooper.Fc
131b0def2b5SDag-Erling Smørgrav.Ft int
13276cb1112SConrad Meyer.Fn sbuf_nl_terminate "struct sbuf *"
13376cb1112SConrad Meyer.Ft int
134a6848fd5SEnji Cooper.Fo sbuf_printf
135a6848fd5SEnji Cooper.Fa "struct sbuf *s"
136a6848fd5SEnji Cooper.Fa "const char *fmt" "..."
137a6848fd5SEnji Cooper.Fc
138863edaecSDag-Erling Smørgrav.Ft int
139a6848fd5SEnji Cooper.Fo sbuf_vprintf
140a6848fd5SEnji Cooper.Fa "struct sbuf *s"
141a6848fd5SEnji Cooper.Fa "const char *fmt"
142a6848fd5SEnji Cooper.Fa "va_list ap"
143a6848fd5SEnji Cooper.Fc
144371c0c84SKelly Yancey.Ft int
145a6848fd5SEnji Cooper.Fo sbuf_putc
146a6848fd5SEnji Cooper.Fa "struct sbuf *s"
147a6848fd5SEnji Cooper.Fa "int c"
148a6848fd5SEnji Cooper.Fc
1494351ba27SMatthew D Fleming.Ft void
150a6848fd5SEnji Cooper.Fo sbuf_set_drain
151a6848fd5SEnji Cooper.Fa "struct sbuf *s"
152a6848fd5SEnji Cooper.Fa "sbuf_drain_func *func"
153a6848fd5SEnji Cooper.Fa "void *arg"
154a6848fd5SEnji Cooper.Fc
155863edaecSDag-Erling Smørgrav.Ft int
156a6848fd5SEnji Cooper.Fo sbuf_trim
157a6848fd5SEnji Cooper.Fa "struct sbuf *s"
158a6848fd5SEnji Cooper.Fc
159371c0c84SKelly Yancey.Ft int
160a6848fd5SEnji Cooper.Fo sbuf_error
161a6848fd5SEnji Cooper.Fa "struct sbuf *s"
162a6848fd5SEnji Cooper.Fc
1634351ba27SMatthew D Fleming.Ft int
164a6848fd5SEnji Cooper.Fo sbuf_finish
165a6848fd5SEnji Cooper.Fa "struct sbuf *s"
166a6848fd5SEnji Cooper.Fc
167863edaecSDag-Erling Smørgrav.Ft char *
168a6848fd5SEnji Cooper.Fo sbuf_data
169a6848fd5SEnji Cooper.Fa "struct sbuf *s"
170a6848fd5SEnji Cooper.Fc
171b397b9b7SMikolaj Golub.Ft ssize_t
172a6848fd5SEnji Cooper.Fo sbuf_len
173a6848fd5SEnji Cooper.Fa "struct sbuf *s"
174a6848fd5SEnji Cooper.Fc
175c5f9218bSPoul-Henning Kamp.Ft int
176a6848fd5SEnji Cooper.Fo sbuf_done
177a6848fd5SEnji Cooper.Fa "struct sbuf *s"
178a6848fd5SEnji Cooper.Fc
179863edaecSDag-Erling Smørgrav.Ft void
180a6848fd5SEnji Cooper.Fo sbuf_delete
181a6848fd5SEnji Cooper.Fa "struct sbuf *s"
182a6848fd5SEnji Cooper.Fc
183f02db7b4SMikolaj Golub.Ft void
184a6848fd5SEnji Cooper.Fo sbuf_start_section
185a6848fd5SEnji Cooper.Fa "struct sbuf *s"
186a6848fd5SEnji Cooper.Fa "ssize_t *old_lenp"
187a6848fd5SEnji Cooper.Fc
188f02db7b4SMikolaj Golub.Ft ssize_t
189a6848fd5SEnji Cooper.Fo sbuf_end_section
190a6848fd5SEnji Cooper.Fa "struct sbuf *s"
191a6848fd5SEnji Cooper.Fa "ssize_t old_len"
192a6848fd5SEnji Cooper.Fa "size_t pad"
193a6848fd5SEnji Cooper.Fa "int c"
194a6848fd5SEnji Cooper.Fc
1955672fac9SKenneth D. Merry.Ft void
1965672fac9SKenneth D. Merry.Fo sbuf_hexdump
1975672fac9SKenneth D. Merry.Fa "struct sbuf *sb"
1985672fac9SKenneth D. Merry.Fa "void *ptr"
1995672fac9SKenneth D. Merry.Fa "int length"
2005672fac9SKenneth D. Merry.Fa "const char *hdr"
2015672fac9SKenneth D. Merry.Fa "int flags"
2025672fac9SKenneth D. Merry.Fc
2037d7db529SConrad Meyer.Ft int
2047d7db529SConrad Meyer.Fo sbuf_printf_drain
2057d7db529SConrad Meyer.Fa "void *arg"
2067d7db529SConrad Meyer.Fa "const char *data"
2077d7db529SConrad Meyer.Fa "int len"
2087d7db529SConrad Meyer.Fc
209388f3ce6SScott Long.Ft void
210a6848fd5SEnji Cooper.Fo sbuf_putbuf
211a6848fd5SEnji Cooper.Fa "struct sbuf *s"
212a6848fd5SEnji Cooper.Fc
213e90ede1cSEnji Cooper.Fd #ifdef _KERNEL
214e90ede1cSEnji Cooper.In sys/types.h
215e90ede1cSEnji Cooper.In sys/sbuf.h
216e90ede1cSEnji Cooper.Ft int
217e90ede1cSEnji Cooper.Fo sbuf_bcopyin
218e90ede1cSEnji Cooper.Fa "struct sbuf *s"
219e90ede1cSEnji Cooper.Fa "const void *uaddr"
220e90ede1cSEnji Cooper.Fa "size_t len"
221e90ede1cSEnji Cooper.Fc
222e90ede1cSEnji Cooper.Ft int
223e90ede1cSEnji Cooper.Fo sbuf_copyin
224e90ede1cSEnji Cooper.Fa "struct sbuf *s"
225e90ede1cSEnji Cooper.Fa "const void *uaddr"
226e90ede1cSEnji Cooper.Fa "size_t len"
227e90ede1cSEnji Cooper.Fc
2287c2dd57bSMatthew D Fleming.In sys/sysctl.h
2297c2dd57bSMatthew D Fleming.Ft struct sbuf *
230a6848fd5SEnji Cooper.Fo sbuf_new_for_sysctl
231a6848fd5SEnji Cooper.Fa "struct sbuf *s"
232a6848fd5SEnji Cooper.Fa "char *buf"
233a6848fd5SEnji Cooper.Fa "int length"
234a6848fd5SEnji Cooper.Fa "struct sysctl_req *req"
235a6848fd5SEnji Cooper.Fc
236e90ede1cSEnji Cooper.Fd #endif	/* _KERNEL */
237863edaecSDag-Erling Smørgrav.Sh DESCRIPTION
238863edaecSDag-Erling SmørgravThe
23981ae4b8dSRuslan Ermilov.Nm
2406ab7244aSPoul-Henning Kampfamily of functions allows one to safely allocate, compose and
2416ab7244aSPoul-Henning Kamprelease strings in kernel or user space.
2426ab7244aSPoul-Henning Kamp.Pp
243863edaecSDag-Erling SmørgravInstead of arrays of characters, these functions operate on structures
244863edaecSDag-Erling Smørgravcalled
245863edaecSDag-Erling Smørgrav.Fa sbufs ,
246863edaecSDag-Erling Smørgravdefined in
247fe08efe6SRuslan Ermilov.In sys/sbuf.h .
248863edaecSDag-Erling Smørgrav.Pp
2496ab7244aSPoul-Henning KampAny errors encountered during the allocation or composition of the
2506ab7244aSPoul-Henning Kampstring will be latched in the data structure,
2516ab7244aSPoul-Henning Kampmaking a single error test at the end of the composition
2526ab7244aSPoul-Henning Kampsufficient to determine success or failure of the entire process.
2536ab7244aSPoul-Henning Kamp.Pp
254863edaecSDag-Erling SmørgravThe
255863edaecSDag-Erling Smørgrav.Fn sbuf_new
256863edaecSDag-Erling Smørgravfunction initializes the
257863edaecSDag-Erling Smørgrav.Fa sbuf
258863edaecSDag-Erling Smørgravpointed to by its first argument.
259d6479358SDag-Erling SmørgravIf that pointer is
260d6479358SDag-Erling Smørgrav.Dv NULL ,
261d6479358SDag-Erling Smørgrav.Fn sbuf_new
262d6479358SDag-Erling Smørgravallocates a
263d68b700aSRuslan Ermilov.Vt struct sbuf
264d6479358SDag-Erling Smørgravusing
265d6479358SDag-Erling Smørgrav.Xr malloc 9 .
266863edaecSDag-Erling SmørgravThe
267863edaecSDag-Erling Smørgrav.Fa buf
268863edaecSDag-Erling Smørgravargument is a pointer to a buffer in which to store the actual string;
269863edaecSDag-Erling Smørgravif it is
270863edaecSDag-Erling Smørgrav.Dv NULL ,
271863edaecSDag-Erling Smørgrav.Fn sbuf_new
272863edaecSDag-Erling Smørgravwill allocate one using
273863edaecSDag-Erling Smørgrav.Xr malloc 9 .
274863edaecSDag-Erling SmørgravThe
275863edaecSDag-Erling Smørgrav.Fa length
276371c0c84SKelly Yanceyis the initial size of the storage buffer.
277863edaecSDag-Erling SmørgravThe fourth argument,
278863edaecSDag-Erling Smørgrav.Fa flags ,
279371c0c84SKelly Yanceymay be comprised of the following flags:
2803b0536faSRuslan Ermilov.Bl -tag -width ".Dv SBUF_AUTOEXTEND"
281371c0c84SKelly Yancey.It Dv SBUF_FIXEDLEN
2823b0536faSRuslan ErmilovThe storage buffer is fixed at its initial size.
283371c0c84SKelly YanceyAttempting to extend the sbuf beyond this size results in an overflow condition.
284371c0c84SKelly Yancey.It Dv SBUF_AUTOEXTEND
285371c0c84SKelly YanceyThis indicates that the storage buffer may be extended as necessary, so long
286371c0c84SKelly Yanceyas resources allow, to hold additional data.
287f4d28142SIan Lepore.It Dv SBUF_INCLUDENUL
288f4d28142SIan LeporeThis causes the final nulterm byte to be counted in the length of the data.
289a8ec96afSLawrence Stewart.It Dv SBUF_DRAINTOEOR
290a8ec96afSLawrence StewartTreat top-level sections started with
291a8ec96afSLawrence Stewart.Fn sbuf_start_section
292a8ec96afSLawrence Stewartas a record boundary marker that will be used during drain operations to avoid
293a8ec96afSLawrence Stewartrecords being split.
294a8ec96afSLawrence StewartIf a record grows sufficiently large such that it fills the
295a8ec96afSLawrence Stewart.Fa sbuf
2967d7db529SConrad Meyerand therefore cannot be drained without being split, an error of
2977d7db529SConrad Meyer.Er EDEADLK
2987d7db529SConrad Meyeris set.
29971db411eSConrad Meyer.It Dv SBUF_NOWAIT
30071db411eSConrad MeyerIndicates that attempts to extend the storage buffer should fail in low memory
30171db411eSConrad Meyerconditions, like
30271db411eSConrad Meyer.Xr malloc 9
30371db411eSConrad Meyer.Dv M_NOWAIT .
304371c0c84SKelly Yancey.El
305863edaecSDag-Erling Smørgrav.Pp
306863edaecSDag-Erling SmørgravNote that if
307863edaecSDag-Erling Smørgrav.Fa buf
308863edaecSDag-Erling Smørgravis not
309863edaecSDag-Erling Smørgrav.Dv NULL ,
310863edaecSDag-Erling Smørgravit must point to an array of at least
311863edaecSDag-Erling Smørgrav.Fa length
312863edaecSDag-Erling Smørgravcharacters.
31391c9d24eSDag-Erling SmørgravThe result of accessing that array directly while it is in use by the
31491c9d24eSDag-Erling Smørgravsbuf is undefined.
31591c9d24eSDag-Erling Smørgrav.Pp
31691c9d24eSDag-Erling SmørgravThe
31772fba9d7SChristian Brueffer.Fn sbuf_new_auto
31872fba9d7SChristian Bruefferfunction is a shortcut for creating a completely dynamic
31972fba9d7SChristian Brueffer.Nm .
32072fba9d7SChristian BruefferIt is the equivalent of calling
32172fba9d7SChristian Brueffer.Fn sbuf_new
32272fba9d7SChristian Bruefferwith values
32372fba9d7SChristian Brueffer.Dv NULL ,
32472fba9d7SChristian Brueffer.Dv NULL ,
32572fba9d7SChristian Brueffer.Dv 0 ,
32672fba9d7SChristian Bruefferand
32772fba9d7SChristian Brueffer.Dv SBUF_AUTOEXTEND .
32872fba9d7SChristian Brueffer.Pp
32972fba9d7SChristian BruefferThe
3307c2dd57bSMatthew D Fleming.Fn sbuf_new_for_sysctl
3317c2dd57bSMatthew D Flemingfunction will set up an sbuf with a drain function to use
3327c2dd57bSMatthew D Fleming.Fn SYSCTL_OUT
3337c2dd57bSMatthew D Flemingwhen the internal buffer fills.
33400f0e671SMatthew D FlemingNote that if the various functions which append to an sbuf are used while
33500f0e671SMatthew D Fleminga non-sleepable lock is held, the user buffer should be wired using
33600f0e671SMatthew D Fleming.Fn sysctl_wire_old_buffer .
3377c2dd57bSMatthew D Fleming.Pp
3387c2dd57bSMatthew D FlemingThe
33991c9d24eSDag-Erling Smørgrav.Fn sbuf_delete
34091c9d24eSDag-Erling Smørgravfunction clears the
34191c9d24eSDag-Erling Smørgrav.Fa sbuf
34291c9d24eSDag-Erling Smørgravand frees any memory allocated for it.
34391c9d24eSDag-Erling SmørgravThere must be a call to
34491c9d24eSDag-Erling Smørgrav.Fn sbuf_delete
34591c9d24eSDag-Erling Smørgravfor every call to
34691c9d24eSDag-Erling Smørgrav.Fn sbuf_new .
34791c9d24eSDag-Erling SmørgravAny attempt to access the sbuf after it has been deleted will fail.
348863edaecSDag-Erling Smørgrav.Pp
349863edaecSDag-Erling SmørgravThe
350e499b74dSDag-Erling Smørgrav.Fn sbuf_clear
351e499b74dSDag-Erling Smørgravfunction invalidates the contents of the
352e499b74dSDag-Erling Smørgrav.Fa sbuf
353e499b74dSDag-Erling Smørgravand resets its position to zero.
354e499b74dSDag-Erling Smørgrav.Pp
355e499b74dSDag-Erling SmørgravThe
356f4d28142SIan Lepore.Fn sbuf_get_flags
357f4d28142SIan Leporefunction returns the current user flags.
358f4d28142SIan LeporeThe
359f4d28142SIan Lepore.Fn sbuf_set_flags
360f4d28142SIan Leporeand
361204a5f58SMitchell Horne.Fn sbuf_clear_flags
362f4d28142SIan Leporefunctions set or clear one or more user flags, respectively.
363f4d28142SIan LeporeThe user flags are described under the
364f4d28142SIan Lepore.Fn sbuf_new
365f4d28142SIan Leporefunction.
366f4d28142SIan Lepore.Pp
367f4d28142SIan LeporeThe
368863edaecSDag-Erling Smørgrav.Fn sbuf_setpos
369863edaecSDag-Erling Smørgravfunction sets the
370863edaecSDag-Erling Smørgrav.Fa sbuf Ns 's
371371c0c84SKelly Yanceyend position to
372863edaecSDag-Erling Smørgrav.Fa pos ,
373513575d4SWarner Loshwhich is a value between zero and the current position in the buffer.
374513575d4SWarner LoshIt can only truncate the sbuf to the new position.
375863edaecSDag-Erling Smørgrav.Pp
376863edaecSDag-Erling SmørgravThe
377b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcat
378b0def2b5SDag-Erling Smørgravfunction appends the first
379b0def2b5SDag-Erling Smørgrav.Fa len
3804aa90de3SDag-Erling Smørgravbytes from the buffer
3814aa90de3SDag-Erling Smørgrav.Fa buf
382b0def2b5SDag-Erling Smørgravto the
383b0def2b5SDag-Erling Smørgrav.Fa sbuf .
384b0def2b5SDag-Erling Smørgrav.Pp
385b0def2b5SDag-Erling SmørgravThe
386b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcopyin
387b0def2b5SDag-Erling Smørgravfunction copies
388b0def2b5SDag-Erling Smørgrav.Fa len
389b0def2b5SDag-Erling Smørgravbytes from the specified userland address into the
390b0def2b5SDag-Erling Smørgrav.Fa sbuf .
391b0def2b5SDag-Erling Smørgrav.Pp
392b0def2b5SDag-Erling SmørgravThe
393b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcpy
394b0def2b5SDag-Erling Smørgravfunction replaces the contents of the
395b0def2b5SDag-Erling Smørgrav.Fa sbuf
396b0def2b5SDag-Erling Smørgravwith the first
397b0def2b5SDag-Erling Smørgrav.Fa len
3984aa90de3SDag-Erling Smørgravbytes from the buffer
3994aa90de3SDag-Erling Smørgrav.Fa buf .
400b0def2b5SDag-Erling Smørgrav.Pp
401b0def2b5SDag-Erling SmørgravThe
402863edaecSDag-Erling Smørgrav.Fn sbuf_cat
403b0def2b5SDag-Erling Smørgravfunction appends the NUL-terminated string
404863edaecSDag-Erling Smørgrav.Fa str
405863edaecSDag-Erling Smørgravto the
406863edaecSDag-Erling Smørgrav.Fa sbuf
407863edaecSDag-Erling Smørgravat the current position.
408863edaecSDag-Erling Smørgrav.Pp
409863edaecSDag-Erling SmørgravThe
4104351ba27SMatthew D Fleming.Fn sbuf_set_drain
4114351ba27SMatthew D Flemingfunction sets a drain function
4124351ba27SMatthew D Fleming.Fa func
4134351ba27SMatthew D Flemingfor the
4144351ba27SMatthew D Fleming.Fa sbuf ,
4154351ba27SMatthew D Flemingand records a pointer
4164351ba27SMatthew D Fleming.Fa arg
4174351ba27SMatthew D Flemingto be passed to the drain on callback.
4184351ba27SMatthew D FlemingThe drain function cannot be changed while
4194351ba27SMatthew D Fleming.Fa sbuf_len
4204351ba27SMatthew D Flemingis non-zero.
4214351ba27SMatthew D Fleming.Pp
4224351ba27SMatthew D FlemingThe registered drain function
4234351ba27SMatthew D Fleming.Vt sbuf_drain_func
4244351ba27SMatthew D Flemingwill be called with the argument
4254351ba27SMatthew D Fleming.Fa arg
4264351ba27SMatthew D Flemingprovided to
4274351ba27SMatthew D Fleming.Fn sbuf_set_drain ,
4284351ba27SMatthew D Fleminga pointer
4294351ba27SMatthew D Fleming.Fa data
4304351ba27SMatthew D Flemingto a byte string that is the contents of the sbuf, and the length
4314351ba27SMatthew D Fleming.Fa len
4324351ba27SMatthew D Flemingof the data.
4334351ba27SMatthew D FlemingIf the drain function exists, it will be called when the sbuf internal
4344351ba27SMatthew D Flemingbuffer is full, or on behalf of
4354351ba27SMatthew D Fleming.Fn sbuf_finish .
4364351ba27SMatthew D FlemingThe drain function may drain some or all of the data, but must drain
4374351ba27SMatthew D Flemingat least 1 byte.
4384351ba27SMatthew D FlemingThe return value from the drain function, if positive, indicates how
4394351ba27SMatthew D Flemingmany bytes were drained.
4404351ba27SMatthew D FlemingIf negative, the return value indicates the negative error code which
4414351ba27SMatthew D Flemingwill be returned from this or a later call to
4424351ba27SMatthew D Fleming.Fn sbuf_finish .
4437d7db529SConrad MeyerIf the returned drained length is 0, an error of
4447d7db529SConrad Meyer.Er EDEADLK
4457d7db529SConrad Meyeris set.
4464351ba27SMatthew D FlemingTo do unbuffered draining, initialize the sbuf with a two-byte buffer.
4474351ba27SMatthew D FlemingThe drain will be called for every byte added to the sbuf.
4484351ba27SMatthew D FlemingThe
4494351ba27SMatthew D Fleming.Fn sbuf_bcopyin ,
45076cb1112SConrad Meyer.Fn sbuf_bcpy ,
45176cb1112SConrad Meyer.Fn sbuf_clear ,
4524351ba27SMatthew D Fleming.Fn sbuf_copyin ,
45376cb1112SConrad Meyer.Fn sbuf_cpy ,
4544351ba27SMatthew D Fleming.Fn sbuf_trim ,
45576cb1112SConrad Meyer.Fn sbuf_data ,
4564351ba27SMatthew D Flemingand
45776cb1112SConrad Meyer.Fn sbuf_len
4584351ba27SMatthew D Flemingfunctions cannot be used on an sbuf with a drain.
4594351ba27SMatthew D Fleming.Pp
4604351ba27SMatthew D FlemingThe
461b0def2b5SDag-Erling Smørgrav.Fn sbuf_copyin
462b0def2b5SDag-Erling Smørgravfunction copies a NUL-terminated string from the specified userland
463b0def2b5SDag-Erling Smørgravaddress into the
464b0def2b5SDag-Erling Smørgrav.Fa sbuf .
465b0def2b5SDag-Erling SmørgravIf the
466b0def2b5SDag-Erling Smørgrav.Fa len
467b0def2b5SDag-Erling Smørgravargument is non-zero, no more than
468b0def2b5SDag-Erling Smørgrav.Fa len
469b0def2b5SDag-Erling Smørgravcharacters (not counting the terminating NUL) are copied; otherwise
470b0def2b5SDag-Erling Smørgravthe entire string, or as much of it as can fit in the
471b0def2b5SDag-Erling Smørgrav.Fa sbuf ,
472b0def2b5SDag-Erling Smørgravis copied.
473b0def2b5SDag-Erling Smørgrav.Pp
474b0def2b5SDag-Erling SmørgravThe
475863edaecSDag-Erling Smørgrav.Fn sbuf_cpy
476863edaecSDag-Erling Smørgravfunction replaces the contents of the
477863edaecSDag-Erling Smørgrav.Fa sbuf
478b0def2b5SDag-Erling Smørgravwith those of the NUL-terminated string
479863edaecSDag-Erling Smørgrav.Fa str .
480863edaecSDag-Erling SmørgravThis is equivalent to calling
481863edaecSDag-Erling Smørgrav.Fn sbuf_cat
482863edaecSDag-Erling Smørgravwith a fresh
483863edaecSDag-Erling Smørgrav.Fa sbuf
484863edaecSDag-Erling Smørgravor one which position has been reset to zero with
485e499b74dSDag-Erling Smørgrav.Fn sbuf_clear
486e499b74dSDag-Erling Smørgravor
487863edaecSDag-Erling Smørgrav.Fn sbuf_setpos .
488863edaecSDag-Erling Smørgrav.Pp
489863edaecSDag-Erling SmørgravThe
49076cb1112SConrad Meyer.Fn sbuf_nl_terminate
49176cb1112SConrad Meyerfunction appends a trailing newline character, if the current line is non-empty
49276cb1112SConrad Meyerand not already terminated by a newline character.
49376cb1112SConrad Meyer.Pp
49476cb1112SConrad MeyerThe
495863edaecSDag-Erling Smørgrav.Fn sbuf_printf
496863edaecSDag-Erling Smørgravfunction formats its arguments according to the format string pointed
497863edaecSDag-Erling Smørgravto by
498863edaecSDag-Erling Smørgrav.Fa fmt
499863edaecSDag-Erling Smørgravand appends the resulting string to the
500863edaecSDag-Erling Smørgrav.Fa sbuf
501863edaecSDag-Erling Smørgravat the current position.
502863edaecSDag-Erling Smørgrav.Pp
503863edaecSDag-Erling SmørgravThe
504371c0c84SKelly Yancey.Fn sbuf_vprintf
505371c0c84SKelly Yanceyfunction behaves the same as
506371c0c84SKelly Yancey.Fn sbuf_printf
507371c0c84SKelly Yanceyexcept that the arguments are obtained from the variable-length argument list
508371c0c84SKelly Yancey.Fa ap .
509371c0c84SKelly Yancey.Pp
510371c0c84SKelly YanceyThe
511863edaecSDag-Erling Smørgrav.Fn sbuf_putc
512863edaecSDag-Erling Smørgravfunction appends the character
513863edaecSDag-Erling Smørgrav.Fa c
514863edaecSDag-Erling Smørgravto the
515863edaecSDag-Erling Smørgrav.Fa sbuf
516863edaecSDag-Erling Smørgravat the current position.
517863edaecSDag-Erling Smørgrav.Pp
518863edaecSDag-Erling SmørgravThe
519371c0c84SKelly Yancey.Fn sbuf_trim
520371c0c84SKelly Yanceyfunction removes trailing whitespace from the
521371c0c84SKelly Yancey.Fa sbuf .
522371c0c84SKelly Yancey.Pp
523371c0c84SKelly YanceyThe
5244d369413SMatthew D Fleming.Fn sbuf_error
5254d369413SMatthew D Flemingfunction returns any error value that the
5264d369413SMatthew D Fleming.Fa sbuf
5277d7db529SConrad Meyermay have accumulated, either from the drain function, or
5287d7db529SConrad Meyer.Er ENOMEM
5297d7db529SConrad Meyerif the
530e499b74dSDag-Erling Smørgrav.Fa sbuf
531e499b74dSDag-Erling Smørgravoverflowed.
5324d369413SMatthew D FlemingThis function is generally not needed and instead the error code from
5334d369413SMatthew D Fleming.Fn sbuf_finish
5344d369413SMatthew D Flemingis the preferred way to discover whether an sbuf had an error.
535e499b74dSDag-Erling Smørgrav.Pp
536e499b74dSDag-Erling SmørgravThe
537863edaecSDag-Erling Smørgrav.Fn sbuf_finish
5384351ba27SMatthew D Flemingfunction will call the attached drain function if one exists until all
5394351ba27SMatthew D Flemingthe data in the
540863edaecSDag-Erling Smørgrav.Fa sbuf
5414351ba27SMatthew D Flemingis flushed.
5424351ba27SMatthew D FlemingIf there is no attached drain,
5434351ba27SMatthew D Fleming.Fn sbuf_finish
5444351ba27SMatthew D FlemingNUL-terminates the
5454351ba27SMatthew D Fleming.Fa sbuf .
5464351ba27SMatthew D FlemingIn either case it marks the
5474351ba27SMatthew D Fleming.Fa sbuf
5484351ba27SMatthew D Flemingas finished, which means that it may no longer be modified using
549863edaecSDag-Erling Smørgrav.Fn sbuf_setpos ,
550863edaecSDag-Erling Smørgrav.Fn sbuf_cat ,
5513393f8daSKenneth D. Merry.Fn sbuf_cpy ,
552863edaecSDag-Erling Smørgrav.Fn sbuf_printf
553863edaecSDag-Erling Smørgravor
554db960cf0SMatthew D Fleming.Fn sbuf_putc ,
555db960cf0SMatthew D Fleminguntil
556db960cf0SMatthew D Fleming.Fn sbuf_clear
557db960cf0SMatthew D Flemingis used to reset the sbuf.
558863edaecSDag-Erling Smørgrav.Pp
559863edaecSDag-Erling SmørgravThe
560863edaecSDag-Erling Smørgrav.Fn sbuf_data
5614351ba27SMatthew D Flemingfunction returns the actual string;
562e499b74dSDag-Erling Smørgrav.Fn sbuf_data
563e499b74dSDag-Erling Smørgravonly works on a finished
564863edaecSDag-Erling Smørgrav.Fa sbuf .
5654351ba27SMatthew D FlemingThe
566c0825cd5SJaakko Heinonen.Fn sbuf_len
567c0825cd5SJaakko Heinonenfunction returns the length of the string.
5684351ba27SMatthew D FlemingFor an
5694351ba27SMatthew D Fleming.Fa sbuf
5704351ba27SMatthew D Flemingwith an attached drain,
5714351ba27SMatthew D Fleming.Fn sbuf_len
5724351ba27SMatthew D Flemingreturns the length of the un-drained data.
5734351ba27SMatthew D Fleming.Fn sbuf_done
5744351ba27SMatthew D Flemingreturns non-zero if the
5754351ba27SMatthew D Fleming.Fa sbuf
5764351ba27SMatthew D Flemingis finished.
577f02db7b4SMikolaj Golub.Pp
578f02db7b4SMikolaj GolubThe
579f02db7b4SMikolaj Golub.Fn sbuf_start_section
580f02db7b4SMikolaj Goluband
581f02db7b4SMikolaj Golub.Fn sbuf_end_section
582f02db7b4SMikolaj Golubfunctions may be used for automatic section alignment.
583f02db7b4SMikolaj GolubThe arguments
584f02db7b4SMikolaj Golub.Fa pad
585f02db7b4SMikolaj Goluband
586f02db7b4SMikolaj Golub.Fa c
587f02db7b4SMikolaj Golubspecify the padding size and a character used for padding.
588f02db7b4SMikolaj GolubThe arguments
589f02db7b4SMikolaj Golub.Fa old_lenp
590f02db7b4SMikolaj Goluband
591f02db7b4SMikolaj Golub.Fa old_len
592f02db7b4SMikolaj Golubare to save and restore the current section length when nested sections
593f02db7b4SMikolaj Golubare used.
594f02db7b4SMikolaj GolubFor the top level section
595f02db7b4SMikolaj Golub.Dv NULL
596f02db7b4SMikolaj Goluband \-1 can be specified for
597f02db7b4SMikolaj Golub.Fa old_lenp
598f02db7b4SMikolaj Goluband
599f02db7b4SMikolaj Golub.Fa old_len
600f02db7b4SMikolaj Golubrespectively.
6015672fac9SKenneth D. Merry.Pp
6025672fac9SKenneth D. MerryThe
6035672fac9SKenneth D. Merry.Fn sbuf_hexdump
6045672fac9SKenneth D. Merryfunction prints an array of bytes to the supplied sbuf, along with an ASCII
6055672fac9SKenneth D. Merryrepresentation of the bytes if possible.
6065672fac9SKenneth D. MerrySee the
6075672fac9SKenneth D. Merry.Xr hexdump 3
6085672fac9SKenneth D. Merryman page for more details on the interface.
609388f3ce6SScott Long.Pp
610388f3ce6SScott LongThe
6117d7db529SConrad Meyer.Fn sbuf_printf_drain
6127d7db529SConrad Meyerfunction is a drain function that will call printf, or log to the console.
6137d7db529SConrad MeyerThe argument
6147d7db529SConrad Meyer.Fa arg
6157d7db529SConrad Meyermust be either
6167d7db529SConrad Meyer.Dv NULL ,
6177d7db529SConrad Meyeror a valid pointer to a
6187d7db529SConrad Meyer.Vt size_t .
6197d7db529SConrad MeyerIf
6207d7db529SConrad Meyer.Fa arg
6217d7db529SConrad Meyeris not
6227d7db529SConrad Meyer.Dv NULL ,
6237d7db529SConrad Meyerthe total bytes drained will be added to the value pointed to by
6247d7db529SConrad Meyer.Fa arg .
6257d7db529SConrad Meyer.Pp
6267d7db529SConrad MeyerThe
627388f3ce6SScott Long.Fn sbuf_putbuf
628388f3ce6SScott Longfunction printfs the sbuf to stdout if in userland, and to the console
629388f3ce6SScott Longand log if in the kernel.
6307d7db529SConrad MeyerThe
6317d7db529SConrad Meyer.Fa sbuf
6327d7db529SConrad Meyermust be finished before calling
6337d7db529SConrad Meyer.Fn sbuf_putbuf .
634388f3ce6SScott LongIt does not drain the buffer or update any pointers.
635863edaecSDag-Erling Smørgrav.Sh NOTES
636863edaecSDag-Erling SmørgravIf an operation caused an
637863edaecSDag-Erling Smørgrav.Fa sbuf
638e499b74dSDag-Erling Smørgravto overflow, most subsequent operations on it will fail until the
639e499b74dSDag-Erling Smørgrav.Fa sbuf
640e499b74dSDag-Erling Smørgravis finished using
641e499b74dSDag-Erling Smørgrav.Fn sbuf_finish
642e499b74dSDag-Erling Smørgravor reset using
643e499b74dSDag-Erling Smørgrav.Fn sbuf_clear ,
644e499b74dSDag-Erling Smørgravor its position is reset to a value between 0 and one less than the
645e499b74dSDag-Erling Smørgravsize of its storage buffer using
646863edaecSDag-Erling Smørgrav.Fn sbuf_setpos ,
647863edaecSDag-Erling Smørgravor it is reinitialized to a sufficiently short string using
648863edaecSDag-Erling Smørgrav.Fn sbuf_cpy .
6494351ba27SMatthew D Fleming.Pp
6504351ba27SMatthew D FlemingDrains in user-space will not always function as indicated.
6514351ba27SMatthew D FlemingWhile the drain function will be called immediately on overflow from
6524351ba27SMatthew D Flemingthe
6534351ba27SMatthew D Fleming.Fa sbuf_putc ,
6544351ba27SMatthew D Fleming.Fa sbuf_bcat ,
6554351ba27SMatthew D Fleming.Fa sbuf_cat
6564351ba27SMatthew D Flemingfunctions,
6574351ba27SMatthew D Fleming.Fa sbuf_printf
6584351ba27SMatthew D Flemingand
6594351ba27SMatthew D Fleming.Fa sbuf_vprintf
6604351ba27SMatthew D Flemingcurrently have no way to determine whether there will be an overflow
6614351ba27SMatthew D Fleminguntil after it occurs, and cannot do a partial expansion of the format
6624351ba27SMatthew D Flemingstring.
6634351ba27SMatthew D FlemingThus when using libsbuf the buffer may be extended to allow completion
6644351ba27SMatthew D Flemingof a single printf call, even though a drain is attached.
665863edaecSDag-Erling Smørgrav.Sh RETURN VALUES
66681ae4b8dSRuslan ErmilovThe
667863edaecSDag-Erling Smørgrav.Fn sbuf_new
66881ae4b8dSRuslan Ermilovfunction returns
669d6479358SDag-Erling Smørgrav.Dv NULL
670d6479358SDag-Erling Smørgravif it failed to allocate a storage buffer, and a pointer to the new
671d6479358SDag-Erling Smørgrav.Fa sbuf
672863edaecSDag-Erling Smørgravotherwise.
673863edaecSDag-Erling Smørgrav.Pp
67481ae4b8dSRuslan ErmilovThe
675863edaecSDag-Erling Smørgrav.Fn sbuf_setpos
67681ae4b8dSRuslan Ermilovfunction returns \-1 if
677863edaecSDag-Erling Smørgrav.Fa pos
678863edaecSDag-Erling Smørgravwas invalid, and zero otherwise.
679863edaecSDag-Erling Smørgrav.Pp
68081ae4b8dSRuslan ErmilovThe
68164223daeSMark Johnston.Fn sbuf_bcat ,
682863edaecSDag-Erling Smørgrav.Fn sbuf_cat ,
683863edaecSDag-Erling Smørgrav.Fn sbuf_cpy ,
684863edaecSDag-Erling Smørgrav.Fn sbuf_printf ,
685371c0c84SKelly Yancey.Fn sbuf_putc ,
686863edaecSDag-Erling Smørgravand
687371c0c84SKelly Yancey.Fn sbuf_trim
68881ae4b8dSRuslan Ermilovfunctions
689863edaecSDag-Erling Smørgravall return \-1 if the buffer overflowed, and zero otherwise.
690863edaecSDag-Erling Smørgrav.Pp
69181ae4b8dSRuslan ErmilovThe
6924d369413SMatthew D Fleming.Fn sbuf_error
6934d369413SMatthew D Flemingfunction returns a non-zero value if the buffer has an overflow or
6944d369413SMatthew D Flemingdrain error, and zero otherwise.
695e499b74dSDag-Erling Smørgrav.Pp
69681ae4b8dSRuslan ErmilovThe
697863edaecSDag-Erling Smørgrav.Fn sbuf_len
698569dd0f3SJaakko Heinonenfunction returns \-1 if the buffer overflowed.
69949091c48SPoul-Henning Kamp.Pp
70081ae4b8dSRuslan ErmilovThe
70149091c48SPoul-Henning Kamp.Fn sbuf_copyin
70281ae4b8dSRuslan Ermilovfunction
70349091c48SPoul-Henning Kampreturns \-1 if copying string from userland failed, and number of bytes
70449091c48SPoul-Henning Kampcopied otherwise.
7056ab7244aSPoul-Henning Kamp.Pp
7064351ba27SMatthew D FlemingThe
707f02db7b4SMikolaj Golub.Fn sbuf_end_section
708f02db7b4SMikolaj Golubfunction returns the section length or \-1 if the buffer has an error.
709f02db7b4SMikolaj Golub.Pp
710f02db7b4SMikolaj GolubThe
7116ab7244aSPoul-Henning Kamp.Fn sbuf_finish 9
7127d7db529SConrad Meyerfunction (the kernel version) returns
7137d7db529SConrad Meyer.Er ENOMEM
7147d7db529SConrad Meyerif the sbuf overflowed before being finished,
7154351ba27SMatthew D Flemingor returns the error code from the drain if one is attached.
7166ab7244aSPoul-Henning Kamp.Pp
7176ab7244aSPoul-Henning KampThe
7186ab7244aSPoul-Henning Kamp.Fn sbuf_finish 3
7196ab7244aSPoul-Henning Kampfunction (the userland version)
7206ab7244aSPoul-Henning Kampwill return zero for success and \-1 and set errno on error.
7216ab7244aSPoul-Henning Kamp.Sh EXAMPLES
7226ab7244aSPoul-Henning Kamp.Bd -literal -compact
7237beb104dSEnji Cooper#include <sys/types.h>
7246ab7244aSPoul-Henning Kamp#include <sys/sbuf.h>
7256ab7244aSPoul-Henning Kamp
7266ab7244aSPoul-Henning Kampstruct sbuf *sb;
7276ab7244aSPoul-Henning Kamp
7286ab7244aSPoul-Henning Kampsb = sbuf_new_auto();
729c920aa7aSPoul-Henning Kampsbuf_cat(sb, "Customers found:\en");
7306ab7244aSPoul-Henning KampTAILQ_FOREACH(foo, &foolist, list) {
731c920aa7aSPoul-Henning Kamp	sbuf_printf(sb, "   %4d %s\en", foo->index, foo->name);
732c920aa7aSPoul-Henning Kamp	sbuf_printf(sb, "      Address: %s\en", foo->address);
733c920aa7aSPoul-Henning Kamp	sbuf_printf(sb, "      Zip: %s\en", foo->zipcode);
7346ab7244aSPoul-Henning Kamp}
735c5a0813dSJaakko Heinonenif (sbuf_finish(sb) != 0) /* Check for any and all errors */
7366ab7244aSPoul-Henning Kamp	err(1, "Could not generate message");
7376ab7244aSPoul-Henning Kamptransmit_msg(sbuf_data(sb), sbuf_len(sb));
7386ab7244aSPoul-Henning Kampsbuf_delete(sb);
7396ab7244aSPoul-Henning Kamp.Ed
740863edaecSDag-Erling Smørgrav.Sh SEE ALSO
7415672fac9SKenneth D. Merry.Xr hexdump 3 ,
742863edaecSDag-Erling Smørgrav.Xr printf 3 ,
743863edaecSDag-Erling Smørgrav.Xr strcat 3 ,
744d68b700aSRuslan Ermilov.Xr strcpy 3 ,
745d68b700aSRuslan Ermilov.Xr copyin 9 ,
746e05f3134SAndrew R. Reiter.Xr copyinstr 9 ,
747e05f3134SAndrew R. Reiter.Xr printf 9
748863edaecSDag-Erling Smørgrav.Sh HISTORY
749863edaecSDag-Erling SmørgravThe
75081ae4b8dSRuslan Ermilov.Nm
751863edaecSDag-Erling Smørgravfamily of functions first appeared in
75222cbe5e3SDag-Erling Smørgrav.Fx 4.4 .
753863edaecSDag-Erling Smørgrav.Sh AUTHORS
754863edaecSDag-Erling Smørgrav.An -nosplit
755863edaecSDag-Erling SmørgravThe
75681ae4b8dSRuslan Ermilov.Nm
757863edaecSDag-Erling Smørgravfamily of functions was designed by
7588a7314fcSBaptiste Daroussin.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org
759863edaecSDag-Erling Smørgravand implemented by
7608a7314fcSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
761e499b74dSDag-Erling SmørgravAdditional improvements were suggested by
7628a7314fcSBaptiste Daroussin.An Justin T. Gibbs Aq Mt gibbs@FreeBSD.org .
763371c0c84SKelly YanceyAuto-extend support added by
7648a7314fcSBaptiste Daroussin.An Kelly Yancey Aq Mt kbyanc@FreeBSD.org .
7654351ba27SMatthew D FlemingDrain functionality added by
7668a7314fcSBaptiste Daroussin.An Matthew Fleming Aq Mt mdf@FreeBSD.org .
767863edaecSDag-Erling Smørgrav.Pp
768863edaecSDag-Erling SmørgravThis manual page was written by
7698a7314fcSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .
770