Deleted Added
full compact
sbuf.9 (153678) sbuf.9 (162404)
1.\"-
2.\" Copyright (c) 2000 Poul Henning Kamp and Dag-Erling Co�dan Sm�rgrav
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
1.\"-
2.\" Copyright (c) 2000 Poul Henning Kamp and Dag-Erling Co�dan Sm�rgrav
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD: head/share/man/man9/sbuf.9 153678 2005-12-23 11:49:53Z phk $
26.\" $FreeBSD: head/share/man/man9/sbuf.9 162404 2006-09-18 15:24:20Z ru $
27.\"
28.Dd July 9, 2004
29.Dt SBUF 9
30.Os
31.Sh NAME
27.\"
28.Dd July 9, 2004
29.Dt SBUF 9
30.Os
31.Sh NAME
32.Nm sbuf ,
32.Nm sbuf_new ,
33.Nm sbuf_clear ,
34.Nm sbuf_setpos ,
35.Nm sbuf_bcat ,
36.Nm sbuf_bcopyin ,
37.Nm sbuf_bcpy ,
38.Nm sbuf_cat ,
39.Nm sbuf_copyin ,

--- 47 unchanged lines hidden (view full) ---

87.Ft int
88.Fn sbuf_len "struct sbuf *s"
89.Ft int
90.Fn sbuf_done "struct sbuf *s"
91.Ft void
92.Fn sbuf_delete "struct sbuf *s"
93.Sh DESCRIPTION
94The
33.Nm sbuf_new ,
34.Nm sbuf_clear ,
35.Nm sbuf_setpos ,
36.Nm sbuf_bcat ,
37.Nm sbuf_bcopyin ,
38.Nm sbuf_bcpy ,
39.Nm sbuf_cat ,
40.Nm sbuf_copyin ,

--- 47 unchanged lines hidden (view full) ---

88.Ft int
89.Fn sbuf_len "struct sbuf *s"
90.Ft int
91.Fn sbuf_done "struct sbuf *s"
92.Ft void
93.Fn sbuf_delete "struct sbuf *s"
94.Sh DESCRIPTION
95The
95.Nm sbuf
96.Nm
96family of functions allows one to safely allocate, construct and
97release bounded null-terminated strings in kernel space.
98Instead of arrays of characters, these functions operate on structures
99called
100.Fa sbufs ,
101defined in
102.In sys/sbuf.h .
103.Pp

--- 199 unchanged lines hidden (view full) ---

303or reset using
304.Fn sbuf_clear ,
305or its position is reset to a value between 0 and one less than the
306size of its storage buffer using
307.Fn sbuf_setpos ,
308or it is reinitialized to a sufficiently short string using
309.Fn sbuf_cpy .
310.Sh RETURN VALUES
97family of functions allows one to safely allocate, construct and
98release bounded null-terminated strings in kernel space.
99Instead of arrays of characters, these functions operate on structures
100called
101.Fa sbufs ,
102defined in
103.In sys/sbuf.h .
104.Pp

--- 199 unchanged lines hidden (view full) ---

304or reset using
305.Fn sbuf_clear ,
306or its position is reset to a value between 0 and one less than the
307size of its storage buffer using
308.Fn sbuf_setpos ,
309or it is reinitialized to a sufficiently short string using
310.Fn sbuf_cpy .
311.Sh RETURN VALUES
312The
311.Fn sbuf_new
313.Fn sbuf_new
312returns
314function returns
313.Dv NULL
314if it failed to allocate a storage buffer, and a pointer to the new
315.Fa sbuf
316otherwise.
317.Pp
315.Dv NULL
316if it failed to allocate a storage buffer, and a pointer to the new
317.Fa sbuf
318otherwise.
319.Pp
320The
318.Fn sbuf_setpos
321.Fn sbuf_setpos
319returns \-1 if
322function returns \-1 if
320.Fa pos
321was invalid, and zero otherwise.
322.Pp
323.Fa pos
324was invalid, and zero otherwise.
325.Pp
326The
323.Fn sbuf_cat ,
324.Fn sbuf_cpy ,
325.Fn sbuf_printf ,
326.Fn sbuf_putc ,
327and
328.Fn sbuf_trim
327.Fn sbuf_cat ,
328.Fn sbuf_cpy ,
329.Fn sbuf_printf ,
330.Fn sbuf_putc ,
331and
332.Fn sbuf_trim
333functions
329all return \-1 if the buffer overflowed, and zero otherwise.
330.Pp
334all return \-1 if the buffer overflowed, and zero otherwise.
335.Pp
336The
331.Fn sbuf_overflowed
337.Fn sbuf_overflowed
338function
332returns a non-zero value if the buffer overflowed, and zero otherwise.
333.Pp
339returns a non-zero value if the buffer overflowed, and zero otherwise.
340.Pp
341The
334.Fn sbuf_data
335and
336.Fn sbuf_len
342.Fn sbuf_data
343and
344.Fn sbuf_len
337return
345functions return
338.Dv NULL
339and \-1, respectively, if the buffer overflowed.
340.Pp
346.Dv NULL
347and \-1, respectively, if the buffer overflowed.
348.Pp
349The
341.Fn sbuf_copyin
350.Fn sbuf_copyin
351function
342returns \-1 if copying string from userland failed, and number of bytes
343copied otherwise.
344.Sh SEE ALSO
345.Xr printf 3 ,
346.Xr strcat 3 ,
347.Xr strcpy 3 ,
348.Xr copyin 9 ,
349.Xr copyinstr 9 ,
350.Xr printf 9
351.Sh HISTORY
352The
352returns \-1 if copying string from userland failed, and number of bytes
353copied otherwise.
354.Sh SEE ALSO
355.Xr printf 3 ,
356.Xr strcat 3 ,
357.Xr strcpy 3 ,
358.Xr copyin 9 ,
359.Xr copyinstr 9 ,
360.Xr printf 9
361.Sh HISTORY
362The
353.Nm sbuf
363.Nm
354family of functions first appeared in
355.Fx 4.4 .
356.Sh AUTHORS
357.An -nosplit
358The
364family of functions first appeared in
365.Fx 4.4 .
366.Sh AUTHORS
367.An -nosplit
368The
359.Nm sbuf
369.Nm
360family of functions was designed by
361.An Poul-Henning Kamp Aq phk@FreeBSD.org
362and implemented by
363.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
364Additional improvements were suggested by
365.An Justin T. Gibbs Aq gibbs@FreeBSD.org .
366Auto-extend support added by
367.An Kelly Yancey Aq kbyanc@FreeBSD.org .
368.Pp
369This manual page was written by
370.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
370family of functions was designed by
371.An Poul-Henning Kamp Aq phk@FreeBSD.org
372and implemented by
373.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .
374Additional improvements were suggested by
375.An Justin T. Gibbs Aq gibbs@FreeBSD.org .
376Auto-extend support added by
377.An Kelly Yancey Aq kbyanc@FreeBSD.org .
378.Pp
379This manual page was written by
380.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org .