Deleted Added
full compact
sbuf.9 (212367) sbuf.9 (212425)
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 212367 2010-09-09 17:49:18Z mdf $
26.\" $FreeBSD: head/share/man/man9/sbuf.9 212425 2010-09-10 16:42:16Z mdf $
27.\"
28.Dd May 17, 2009
29.Dt SBUF 9
30.Os
31.Sh NAME
32.Nm sbuf ,
33.Nm sbuf_new ,
34.Nm sbuf_new_auto ,

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

40.Nm sbuf_cat ,
41.Nm sbuf_copyin ,
42.Nm sbuf_cpy ,
43.Nm sbuf_printf ,
44.Nm sbuf_vprintf ,
45.Nm sbuf_putc ,
46.Nm sbuf_set_drain ,
47.Nm sbuf_trim ,
27.\"
28.Dd May 17, 2009
29.Dt SBUF 9
30.Os
31.Sh NAME
32.Nm sbuf ,
33.Nm sbuf_new ,
34.Nm sbuf_new_auto ,

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

40.Nm sbuf_cat ,
41.Nm sbuf_copyin ,
42.Nm sbuf_cpy ,
43.Nm sbuf_printf ,
44.Nm sbuf_vprintf ,
45.Nm sbuf_putc ,
46.Nm sbuf_set_drain ,
47.Nm sbuf_trim ,
48.Nm sbuf_overflowed ,
48.Nm sbuf_error ,
49.Nm sbuf_finish ,
50.Nm sbuf_data ,
51.Nm sbuf_len ,
52.Nm sbuf_done ,
53.Nm sbuf_delete
54.Nd safe string formatting
55.Sh SYNOPSIS
56.In sys/types.h

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

83.Fn sbuf_vprintf "struct sbuf *s" "const char *fmt" "va_list ap"
84.Ft int
85.Fn sbuf_putc "struct sbuf *s" "int c"
86.Ft void
87.Fn sbuf_set_drain "struct sbuf *s" "sbuf_drain_func *func" "void *arg"
88.Ft int
89.Fn sbuf_trim "struct sbuf *s"
90.Ft int
49.Nm sbuf_finish ,
50.Nm sbuf_data ,
51.Nm sbuf_len ,
52.Nm sbuf_done ,
53.Nm sbuf_delete
54.Nd safe string formatting
55.Sh SYNOPSIS
56.In sys/types.h

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

83.Fn sbuf_vprintf "struct sbuf *s" "const char *fmt" "va_list ap"
84.Ft int
85.Fn sbuf_putc "struct sbuf *s" "int c"
86.Ft void
87.Fn sbuf_set_drain "struct sbuf *s" "sbuf_drain_func *func" "void *arg"
88.Ft int
89.Fn sbuf_trim "struct sbuf *s"
90.Ft int
91.Fn sbuf_overflowed "struct sbuf *s"
91.Fn sbuf_error "struct sbuf *s"
92.Ft int
93.Fn sbuf_finish "struct sbuf *s"
94.Ft char *
95.Fn sbuf_data "struct sbuf *s"
96.Ft int
97.Fn sbuf_len "struct sbuf *s"
98.Ft int
99.Fn sbuf_done "struct sbuf *s"

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

327at the current position.
328.Pp
329The
330.Fn sbuf_trim
331function removes trailing whitespace from the
332.Fa sbuf .
333.Pp
334The
92.Ft int
93.Fn sbuf_finish "struct sbuf *s"
94.Ft char *
95.Fn sbuf_data "struct sbuf *s"
96.Ft int
97.Fn sbuf_len "struct sbuf *s"
98.Ft int
99.Fn sbuf_done "struct sbuf *s"

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

327at the current position.
328.Pp
329The
330.Fn sbuf_trim
331function removes trailing whitespace from the
332.Fa sbuf .
333.Pp
334The
335.Fn sbuf_overflowed
336function returns a non-zero value if the
335.Fn sbuf_error
336function returns any error value that the
337.Fa sbuf
337.Fa sbuf
338may have accumulated, either from the drain function, or ENOMEM if the
339.Fa sbuf
338overflowed.
340overflowed.
341This function is generally not needed and instead the error code from
342.Fn sbuf_finish
343is the preferred way to discover whether an sbuf had an error.
339.Pp
340The
341.Fn sbuf_finish
342function will call the attached drain function if one exists until all
343the data in the
344.Fa sbuf
345is flushed.
346If there is no attached drain,

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

432.Fn sbuf_printf ,
433.Fn sbuf_putc ,
434and
435.Fn sbuf_trim
436functions
437all return \-1 if the buffer overflowed, and zero otherwise.
438.Pp
439The
344.Pp
345The
346.Fn sbuf_finish
347function will call the attached drain function if one exists until all
348the data in the
349.Fa sbuf
350is flushed.
351If there is no attached drain,

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

437.Fn sbuf_printf ,
438.Fn sbuf_putc ,
439and
440.Fn sbuf_trim
441functions
442all return \-1 if the buffer overflowed, and zero otherwise.
443.Pp
444The
440.Fn sbuf_overflowed
441function
442returns a non-zero value if the buffer overflowed, and zero otherwise.
445.Fn sbuf_error
446function returns a non-zero value if the buffer has an overflow or
447drain error, and zero otherwise.
443.Pp
444The
445.Fn sbuf_data
446and
447.Fn sbuf_len
448functions return
449.Dv NULL
450and \-1, respectively, if the buffer overflowed.

--- 43 unchanged lines hidden ---
448.Pp
449The
450.Fn sbuf_data
451and
452.Fn sbuf_len
453functions return
454.Dv NULL
455and \-1, respectively, if the buffer overflowed.

--- 43 unchanged lines hidden ---