1863edaecSDag-Erling Smørgrav.\"- 26e18fca1SUlrich Spörlein.\" 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.\" 2871db411eSConrad Meyer.Dd August 7, 2019 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 , 3472fba9d7SChristian Brueffer.Nm sbuf_new_auto , 357c2dd57bSMatthew D Fleming.Nm sbuf_new_for_sysctl , 36e499b74dSDag-Erling Smørgrav.Nm sbuf_clear , 37f4d28142SIan Lepore.Nm sbuf_get_flags , 38f4d28142SIan Lepore.Nm sbuf_set_flags , 39f4d28142SIan Lepore.Nm sbuf_clear_flags , 40863edaecSDag-Erling Smørgrav.Nm sbuf_setpos , 41b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcat , 42b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcopyin , 43b0def2b5SDag-Erling Smørgrav.Nm sbuf_bcpy , 44863edaecSDag-Erling Smørgrav.Nm sbuf_cat , 45b0def2b5SDag-Erling Smørgrav.Nm sbuf_copyin , 46863edaecSDag-Erling Smørgrav.Nm sbuf_cpy , 47*76cb1112SConrad Meyer.Nm sbuf_nl_terminate , 48863edaecSDag-Erling Smørgrav.Nm sbuf_printf , 49371c0c84SKelly Yancey.Nm sbuf_vprintf , 50863edaecSDag-Erling Smørgrav.Nm sbuf_putc , 514351ba27SMatthew D Fleming.Nm sbuf_set_drain , 52371c0c84SKelly Yancey.Nm sbuf_trim , 534d369413SMatthew D Fleming.Nm sbuf_error , 54863edaecSDag-Erling Smørgrav.Nm sbuf_finish , 55863edaecSDag-Erling Smørgrav.Nm sbuf_data , 56863edaecSDag-Erling Smørgrav.Nm sbuf_len , 57c5f9218bSPoul-Henning Kamp.Nm sbuf_done , 58f02db7b4SMikolaj Golub.Nm sbuf_delete , 59f02db7b4SMikolaj Golub.Nm sbuf_start_section , 605672fac9SKenneth D. Merry.Nm sbuf_end_section , 61388f3ce6SScott Long.Nm sbuf_hexdump , 627d7db529SConrad Meyer.Nm sbuf_printf_drain , 63388f3ce6SScott Long.Nm sbuf_putbuf 646ab7244aSPoul-Henning Kamp.Nd safe string composition 65863edaecSDag-Erling Smørgrav.Sh SYNOPSIS 6632eef9aeSRuslan Ermilov.In sys/types.h 6732eef9aeSRuslan Ermilov.In sys/sbuf.h 684351ba27SMatthew D Fleming.Ft typedef\ int ( sbuf_drain_func ) ( void\ *arg, const\ char\ *data, int\ len ) ; 694351ba27SMatthew D Fleming.Pp 708a5bc771SBruce Evans.Ft struct sbuf * 71a6848fd5SEnji Cooper.Fo sbuf_new 72a6848fd5SEnji Cooper.Fa "struct sbuf *s" 73a6848fd5SEnji Cooper.Fa "char *buf" 74a6848fd5SEnji Cooper.Fa "int length" 75a6848fd5SEnji Cooper.Fa "int flags" 76a6848fd5SEnji Cooper.Fc 7772fba9d7SChristian Brueffer.Ft struct sbuf * 78a6848fd5SEnji Cooper.Fo sbuf_new_auto 79a6848fd5SEnji Cooper.Fa "void" 80a6848fd5SEnji Cooper.Fc 81e499b74dSDag-Erling Smørgrav.Ft void 82a6848fd5SEnji Cooper.Fo sbuf_clear 83a6848fd5SEnji Cooper.Fa "struct sbuf *s" 84a6848fd5SEnji Cooper.Fc 85863edaecSDag-Erling Smørgrav.Ft int 86a6848fd5SEnji Cooper.Fo sbuf_get_flags 87a6848fd5SEnji Cooper.Fa "struct sbuf *s" 88a6848fd5SEnji Cooper.Fc 89f4d28142SIan Lepore.Ft void 90a6848fd5SEnji Cooper.Fo sbuf_set_flags 91a6848fd5SEnji Cooper.Fa "struct sbuf *s" 92a6848fd5SEnji Cooper.Fa "int flags" 93a6848fd5SEnji Cooper.Fc 94f4d28142SIan Lepore.Ft void 95a6848fd5SEnji Cooper.Fo sbuf_clear_flags 96a6848fd5SEnji Cooper.Fa "struct sbuf *s" 97a6848fd5SEnji Cooper.Fa "int flags" 98a6848fd5SEnji Cooper.Fc 99f4d28142SIan Lepore.Ft int 100a6848fd5SEnji Cooper.Fo sbuf_setpos 101a6848fd5SEnji Cooper.Fa "struct sbuf *s" 102a6848fd5SEnji Cooper.Fa "int pos" 103a6848fd5SEnji Cooper.Fc 104863edaecSDag-Erling Smørgrav.Ft int 105a6848fd5SEnji Cooper.Fo sbuf_bcat 106a6848fd5SEnji Cooper.Fa "struct sbuf *s" 107a6848fd5SEnji Cooper.Fa "const void *buf" 108a6848fd5SEnji Cooper.Fa "size_t len" 109a6848fd5SEnji Cooper.Fc 110b0def2b5SDag-Erling Smørgrav.Ft int 111a6848fd5SEnji Cooper.Fo sbuf_bcpy 112a6848fd5SEnji Cooper.Fa "struct sbuf *s" 113a6848fd5SEnji Cooper.Fa "const void *buf" 114a6848fd5SEnji Cooper.Fa "size_t len" 115a6848fd5SEnji Cooper.Fc 116b0def2b5SDag-Erling Smørgrav.Ft int 117a6848fd5SEnji Cooper.Fo sbuf_cat 118a6848fd5SEnji Cooper.Fa "struct sbuf *s" 119a6848fd5SEnji Cooper.Fa "const char *str" 120a6848fd5SEnji Cooper.Fc 121863edaecSDag-Erling Smørgrav.Ft int 122a6848fd5SEnji Cooper.Fo sbuf_cpy 123a6848fd5SEnji Cooper.Fa "struct sbuf *s" 124a6848fd5SEnji Cooper.Fa "const char *str" 125a6848fd5SEnji Cooper.Fc 126b0def2b5SDag-Erling Smørgrav.Ft int 127*76cb1112SConrad Meyer.Fn sbuf_nl_terminate "struct sbuf *" 128*76cb1112SConrad Meyer.Ft int 129a6848fd5SEnji Cooper.Fo sbuf_printf 130a6848fd5SEnji Cooper.Fa "struct sbuf *s" 131a6848fd5SEnji Cooper.Fa "const char *fmt" "..." 132a6848fd5SEnji Cooper.Fc 133863edaecSDag-Erling Smørgrav.Ft int 134a6848fd5SEnji Cooper.Fo sbuf_vprintf 135a6848fd5SEnji Cooper.Fa "struct sbuf *s" 136a6848fd5SEnji Cooper.Fa "const char *fmt" 137a6848fd5SEnji Cooper.Fa "va_list ap" 138a6848fd5SEnji Cooper.Fc 139371c0c84SKelly Yancey.Ft int 140a6848fd5SEnji Cooper.Fo sbuf_putc 141a6848fd5SEnji Cooper.Fa "struct sbuf *s" 142a6848fd5SEnji Cooper.Fa "int c" 143a6848fd5SEnji Cooper.Fc 1444351ba27SMatthew D Fleming.Ft void 145a6848fd5SEnji Cooper.Fo sbuf_set_drain 146a6848fd5SEnji Cooper.Fa "struct sbuf *s" 147a6848fd5SEnji Cooper.Fa "sbuf_drain_func *func" 148a6848fd5SEnji Cooper.Fa "void *arg" 149a6848fd5SEnji Cooper.Fc 150863edaecSDag-Erling Smørgrav.Ft int 151a6848fd5SEnji Cooper.Fo sbuf_trim 152a6848fd5SEnji Cooper.Fa "struct sbuf *s" 153a6848fd5SEnji Cooper.Fc 154371c0c84SKelly Yancey.Ft int 155a6848fd5SEnji Cooper.Fo sbuf_error 156a6848fd5SEnji Cooper.Fa "struct sbuf *s" 157a6848fd5SEnji Cooper.Fc 1584351ba27SMatthew D Fleming.Ft int 159a6848fd5SEnji Cooper.Fo sbuf_finish 160a6848fd5SEnji Cooper.Fa "struct sbuf *s" 161a6848fd5SEnji Cooper.Fc 162863edaecSDag-Erling Smørgrav.Ft char * 163a6848fd5SEnji Cooper.Fo sbuf_data 164a6848fd5SEnji Cooper.Fa "struct sbuf *s" 165a6848fd5SEnji Cooper.Fc 166b397b9b7SMikolaj Golub.Ft ssize_t 167a6848fd5SEnji Cooper.Fo sbuf_len 168a6848fd5SEnji Cooper.Fa "struct sbuf *s" 169a6848fd5SEnji Cooper.Fc 170c5f9218bSPoul-Henning Kamp.Ft int 171a6848fd5SEnji Cooper.Fo sbuf_done 172a6848fd5SEnji Cooper.Fa "struct sbuf *s" 173a6848fd5SEnji Cooper.Fc 174863edaecSDag-Erling Smørgrav.Ft void 175a6848fd5SEnji Cooper.Fo sbuf_delete 176a6848fd5SEnji Cooper.Fa "struct sbuf *s" 177a6848fd5SEnji Cooper.Fc 178f02db7b4SMikolaj Golub.Ft void 179a6848fd5SEnji Cooper.Fo sbuf_start_section 180a6848fd5SEnji Cooper.Fa "struct sbuf *s" 181a6848fd5SEnji Cooper.Fa "ssize_t *old_lenp" 182a6848fd5SEnji Cooper.Fc 183f02db7b4SMikolaj Golub.Ft ssize_t 184a6848fd5SEnji Cooper.Fo sbuf_end_section 185a6848fd5SEnji Cooper.Fa "struct sbuf *s" 186a6848fd5SEnji Cooper.Fa "ssize_t old_len" 187a6848fd5SEnji Cooper.Fa "size_t pad" 188a6848fd5SEnji Cooper.Fa "int c" 189a6848fd5SEnji Cooper.Fc 1905672fac9SKenneth D. Merry.Ft void 1915672fac9SKenneth D. Merry.Fo sbuf_hexdump 1925672fac9SKenneth D. Merry.Fa "struct sbuf *sb" 1935672fac9SKenneth D. Merry.Fa "void *ptr" 1945672fac9SKenneth D. Merry.Fa "int length" 1955672fac9SKenneth D. Merry.Fa "const char *hdr" 1965672fac9SKenneth D. Merry.Fa "int flags" 1975672fac9SKenneth D. Merry.Fc 1987d7db529SConrad Meyer.Ft int 1997d7db529SConrad Meyer.Fo sbuf_printf_drain 2007d7db529SConrad Meyer.Fa "void *arg" 2017d7db529SConrad Meyer.Fa "const char *data" 2027d7db529SConrad Meyer.Fa "int len" 2037d7db529SConrad Meyer.Fc 204388f3ce6SScott Long.Ft void 205a6848fd5SEnji Cooper.Fo sbuf_putbuf 206a6848fd5SEnji Cooper.Fa "struct sbuf *s" 207a6848fd5SEnji Cooper.Fc 208e90ede1cSEnji Cooper.Fd #ifdef _KERNEL 209e90ede1cSEnji Cooper.In sys/types.h 210e90ede1cSEnji Cooper.In sys/sbuf.h 211e90ede1cSEnji Cooper.Ft int 212e90ede1cSEnji Cooper.Fo sbuf_bcopyin 213e90ede1cSEnji Cooper.Fa "struct sbuf *s" 214e90ede1cSEnji Cooper.Fa "const void *uaddr" 215e90ede1cSEnji Cooper.Fa "size_t len" 216e90ede1cSEnji Cooper.Fc 217e90ede1cSEnji Cooper.Ft int 218e90ede1cSEnji Cooper.Fo sbuf_copyin 219e90ede1cSEnji Cooper.Fa "struct sbuf *s" 220e90ede1cSEnji Cooper.Fa "const void *uaddr" 221e90ede1cSEnji Cooper.Fa "size_t len" 222e90ede1cSEnji Cooper.Fc 2237c2dd57bSMatthew D Fleming.In sys/sysctl.h 2247c2dd57bSMatthew D Fleming.Ft struct sbuf * 225a6848fd5SEnji Cooper.Fo sbuf_new_for_sysctl 226a6848fd5SEnji Cooper.Fa "struct sbuf *s" 227a6848fd5SEnji Cooper.Fa "char *buf" 228a6848fd5SEnji Cooper.Fa "int length" 229a6848fd5SEnji Cooper.Fa "struct sysctl_req *req" 230a6848fd5SEnji Cooper.Fc 231e90ede1cSEnji Cooper.Fd #endif /* _KERNEL */ 232863edaecSDag-Erling Smørgrav.Sh DESCRIPTION 233863edaecSDag-Erling SmørgravThe 23481ae4b8dSRuslan Ermilov.Nm 2356ab7244aSPoul-Henning Kampfamily of functions allows one to safely allocate, compose and 2366ab7244aSPoul-Henning Kamprelease strings in kernel or user space. 2376ab7244aSPoul-Henning Kamp.Pp 238863edaecSDag-Erling SmørgravInstead of arrays of characters, these functions operate on structures 239863edaecSDag-Erling Smørgravcalled 240863edaecSDag-Erling Smørgrav.Fa sbufs , 241863edaecSDag-Erling Smørgravdefined in 242fe08efe6SRuslan Ermilov.In sys/sbuf.h . 243863edaecSDag-Erling Smørgrav.Pp 2446ab7244aSPoul-Henning KampAny errors encountered during the allocation or composition of the 2456ab7244aSPoul-Henning Kampstring will be latched in the data structure, 2466ab7244aSPoul-Henning Kampmaking a single error test at the end of the composition 2476ab7244aSPoul-Henning Kampsufficient to determine success or failure of the entire process. 2486ab7244aSPoul-Henning Kamp.Pp 249863edaecSDag-Erling SmørgravThe 250863edaecSDag-Erling Smørgrav.Fn sbuf_new 251863edaecSDag-Erling Smørgravfunction initializes the 252863edaecSDag-Erling Smørgrav.Fa sbuf 253863edaecSDag-Erling Smørgravpointed to by its first argument. 254d6479358SDag-Erling SmørgravIf that pointer is 255d6479358SDag-Erling Smørgrav.Dv NULL , 256d6479358SDag-Erling Smørgrav.Fn sbuf_new 257d6479358SDag-Erling Smørgravallocates a 258d68b700aSRuslan Ermilov.Vt struct sbuf 259d6479358SDag-Erling Smørgravusing 260d6479358SDag-Erling Smørgrav.Xr malloc 9 . 261863edaecSDag-Erling SmørgravThe 262863edaecSDag-Erling Smørgrav.Fa buf 263863edaecSDag-Erling Smørgravargument is a pointer to a buffer in which to store the actual string; 264863edaecSDag-Erling Smørgravif it is 265863edaecSDag-Erling Smørgrav.Dv NULL , 266863edaecSDag-Erling Smørgrav.Fn sbuf_new 267863edaecSDag-Erling Smørgravwill allocate one using 268863edaecSDag-Erling Smørgrav.Xr malloc 9 . 269863edaecSDag-Erling SmørgravThe 270863edaecSDag-Erling Smørgrav.Fa length 271371c0c84SKelly Yanceyis the initial size of the storage buffer. 272863edaecSDag-Erling SmørgravThe fourth argument, 273863edaecSDag-Erling Smørgrav.Fa flags , 274371c0c84SKelly Yanceymay be comprised of the following flags: 2753b0536faSRuslan Ermilov.Bl -tag -width ".Dv SBUF_AUTOEXTEND" 276371c0c84SKelly Yancey.It Dv SBUF_FIXEDLEN 2773b0536faSRuslan ErmilovThe storage buffer is fixed at its initial size. 278371c0c84SKelly YanceyAttempting to extend the sbuf beyond this size results in an overflow condition. 279371c0c84SKelly Yancey.It Dv SBUF_AUTOEXTEND 280371c0c84SKelly YanceyThis indicates that the storage buffer may be extended as necessary, so long 281371c0c84SKelly Yanceyas resources allow, to hold additional data. 282f4d28142SIan Lepore.It Dv SBUF_INCLUDENUL 283f4d28142SIan LeporeThis causes the final nulterm byte to be counted in the length of the data. 284a8ec96afSLawrence Stewart.It Dv SBUF_DRAINTOEOR 285a8ec96afSLawrence StewartTreat top-level sections started with 286a8ec96afSLawrence Stewart.Fn sbuf_start_section 287a8ec96afSLawrence Stewartas a record boundary marker that will be used during drain operations to avoid 288a8ec96afSLawrence Stewartrecords being split. 289a8ec96afSLawrence StewartIf a record grows sufficiently large such that it fills the 290a8ec96afSLawrence Stewart.Fa sbuf 2917d7db529SConrad Meyerand therefore cannot be drained without being split, an error of 2927d7db529SConrad Meyer.Er EDEADLK 2937d7db529SConrad Meyeris set. 29471db411eSConrad Meyer.It Dv SBUF_NOWAIT 29571db411eSConrad MeyerIndicates that attempts to extend the storage buffer should fail in low memory 29671db411eSConrad Meyerconditions, like 29771db411eSConrad Meyer.Xr malloc 9 29871db411eSConrad Meyer.Dv M_NOWAIT . 299371c0c84SKelly Yancey.El 300863edaecSDag-Erling Smørgrav.Pp 301863edaecSDag-Erling SmørgravNote that if 302863edaecSDag-Erling Smørgrav.Fa buf 303863edaecSDag-Erling Smørgravis not 304863edaecSDag-Erling Smørgrav.Dv NULL , 305863edaecSDag-Erling Smørgravit must point to an array of at least 306863edaecSDag-Erling Smørgrav.Fa length 307863edaecSDag-Erling Smørgravcharacters. 30891c9d24eSDag-Erling SmørgravThe result of accessing that array directly while it is in use by the 30991c9d24eSDag-Erling Smørgravsbuf is undefined. 31091c9d24eSDag-Erling Smørgrav.Pp 31191c9d24eSDag-Erling SmørgravThe 31272fba9d7SChristian Brueffer.Fn sbuf_new_auto 31372fba9d7SChristian Bruefferfunction is a shortcut for creating a completely dynamic 31472fba9d7SChristian Brueffer.Nm . 31572fba9d7SChristian BruefferIt is the equivalent of calling 31672fba9d7SChristian Brueffer.Fn sbuf_new 31772fba9d7SChristian Bruefferwith values 31872fba9d7SChristian Brueffer.Dv NULL , 31972fba9d7SChristian Brueffer.Dv NULL , 32072fba9d7SChristian Brueffer.Dv 0 , 32172fba9d7SChristian Bruefferand 32272fba9d7SChristian Brueffer.Dv SBUF_AUTOEXTEND . 32372fba9d7SChristian Brueffer.Pp 32472fba9d7SChristian BruefferThe 3257c2dd57bSMatthew D Fleming.Fn sbuf_new_for_sysctl 3267c2dd57bSMatthew D Flemingfunction will set up an sbuf with a drain function to use 3277c2dd57bSMatthew D Fleming.Fn SYSCTL_OUT 3287c2dd57bSMatthew D Flemingwhen the internal buffer fills. 32900f0e671SMatthew D FlemingNote that if the various functions which append to an sbuf are used while 33000f0e671SMatthew D Fleminga non-sleepable lock is held, the user buffer should be wired using 33100f0e671SMatthew D Fleming.Fn sysctl_wire_old_buffer . 3327c2dd57bSMatthew D Fleming.Pp 3337c2dd57bSMatthew D FlemingThe 33491c9d24eSDag-Erling Smørgrav.Fn sbuf_delete 33591c9d24eSDag-Erling Smørgravfunction clears the 33691c9d24eSDag-Erling Smørgrav.Fa sbuf 33791c9d24eSDag-Erling Smørgravand frees any memory allocated for it. 33891c9d24eSDag-Erling SmørgravThere must be a call to 33991c9d24eSDag-Erling Smørgrav.Fn sbuf_delete 34091c9d24eSDag-Erling Smørgravfor every call to 34191c9d24eSDag-Erling Smørgrav.Fn sbuf_new . 34291c9d24eSDag-Erling SmørgravAny attempt to access the sbuf after it has been deleted will fail. 343863edaecSDag-Erling Smørgrav.Pp 344863edaecSDag-Erling SmørgravThe 345e499b74dSDag-Erling Smørgrav.Fn sbuf_clear 346e499b74dSDag-Erling Smørgravfunction invalidates the contents of the 347e499b74dSDag-Erling Smørgrav.Fa sbuf 348e499b74dSDag-Erling Smørgravand resets its position to zero. 349e499b74dSDag-Erling Smørgrav.Pp 350e499b74dSDag-Erling SmørgravThe 351f4d28142SIan Lepore.Fn sbuf_get_flags 352f4d28142SIan Leporefunction returns the current user flags. 353f4d28142SIan LeporeThe 354f4d28142SIan Lepore.Fn sbuf_set_flags 355f4d28142SIan Leporeand 356f4d28142SIan Lepore.Fn sbuf_get_flags 357f4d28142SIan Leporefunctions set or clear one or more user flags, respectively. 358f4d28142SIan LeporeThe user flags are described under the 359f4d28142SIan Lepore.Fn sbuf_new 360f4d28142SIan Leporefunction. 361f4d28142SIan Lepore.Pp 362f4d28142SIan LeporeThe 363863edaecSDag-Erling Smørgrav.Fn sbuf_setpos 364863edaecSDag-Erling Smørgravfunction sets the 365863edaecSDag-Erling Smørgrav.Fa sbuf Ns 's 366371c0c84SKelly Yanceyend position to 367863edaecSDag-Erling Smørgrav.Fa pos , 368863edaecSDag-Erling Smørgravwhich is a value between zero and one less than the size of the 369863edaecSDag-Erling Smørgravstorage buffer. 370371c0c84SKelly YanceyThis effectively truncates the sbuf at the new position. 371863edaecSDag-Erling Smørgrav.Pp 372863edaecSDag-Erling SmørgravThe 373b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcat 374b0def2b5SDag-Erling Smørgravfunction appends the first 375b0def2b5SDag-Erling Smørgrav.Fa len 3764aa90de3SDag-Erling Smørgravbytes from the buffer 3774aa90de3SDag-Erling Smørgrav.Fa buf 378b0def2b5SDag-Erling Smørgravto the 379b0def2b5SDag-Erling Smørgrav.Fa sbuf . 380b0def2b5SDag-Erling Smørgrav.Pp 381b0def2b5SDag-Erling SmørgravThe 382b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcopyin 383b0def2b5SDag-Erling Smørgravfunction copies 384b0def2b5SDag-Erling Smørgrav.Fa len 385b0def2b5SDag-Erling Smørgravbytes from the specified userland address into the 386b0def2b5SDag-Erling Smørgrav.Fa sbuf . 387b0def2b5SDag-Erling Smørgrav.Pp 388b0def2b5SDag-Erling SmørgravThe 389b0def2b5SDag-Erling Smørgrav.Fn sbuf_bcpy 390b0def2b5SDag-Erling Smørgravfunction replaces the contents of the 391b0def2b5SDag-Erling Smørgrav.Fa sbuf 392b0def2b5SDag-Erling Smørgravwith the first 393b0def2b5SDag-Erling Smørgrav.Fa len 3944aa90de3SDag-Erling Smørgravbytes from the buffer 3954aa90de3SDag-Erling Smørgrav.Fa buf . 396b0def2b5SDag-Erling Smørgrav.Pp 397b0def2b5SDag-Erling SmørgravThe 398863edaecSDag-Erling Smørgrav.Fn sbuf_cat 399b0def2b5SDag-Erling Smørgravfunction appends the NUL-terminated string 400863edaecSDag-Erling Smørgrav.Fa str 401863edaecSDag-Erling Smørgravto the 402863edaecSDag-Erling Smørgrav.Fa sbuf 403863edaecSDag-Erling Smørgravat the current position. 404863edaecSDag-Erling Smørgrav.Pp 405863edaecSDag-Erling SmørgravThe 4064351ba27SMatthew D Fleming.Fn sbuf_set_drain 4074351ba27SMatthew D Flemingfunction sets a drain function 4084351ba27SMatthew D Fleming.Fa func 4094351ba27SMatthew D Flemingfor the 4104351ba27SMatthew D Fleming.Fa sbuf , 4114351ba27SMatthew D Flemingand records a pointer 4124351ba27SMatthew D Fleming.Fa arg 4134351ba27SMatthew D Flemingto be passed to the drain on callback. 4144351ba27SMatthew D FlemingThe drain function cannot be changed while 4154351ba27SMatthew D Fleming.Fa sbuf_len 4164351ba27SMatthew D Flemingis non-zero. 4174351ba27SMatthew D Fleming.Pp 4184351ba27SMatthew D FlemingThe registered drain function 4194351ba27SMatthew D Fleming.Vt sbuf_drain_func 4204351ba27SMatthew D Flemingwill be called with the argument 4214351ba27SMatthew D Fleming.Fa arg 4224351ba27SMatthew D Flemingprovided to 4234351ba27SMatthew D Fleming.Fn sbuf_set_drain , 4244351ba27SMatthew D Fleminga pointer 4254351ba27SMatthew D Fleming.Fa data 4264351ba27SMatthew D Flemingto a byte string that is the contents of the sbuf, and the length 4274351ba27SMatthew D Fleming.Fa len 4284351ba27SMatthew D Flemingof the data. 4294351ba27SMatthew D FlemingIf the drain function exists, it will be called when the sbuf internal 4304351ba27SMatthew D Flemingbuffer is full, or on behalf of 4314351ba27SMatthew D Fleming.Fn sbuf_finish . 4324351ba27SMatthew D FlemingThe drain function may drain some or all of the data, but must drain 4334351ba27SMatthew D Flemingat least 1 byte. 4344351ba27SMatthew D FlemingThe return value from the drain function, if positive, indicates how 4354351ba27SMatthew D Flemingmany bytes were drained. 4364351ba27SMatthew D FlemingIf negative, the return value indicates the negative error code which 4374351ba27SMatthew D Flemingwill be returned from this or a later call to 4384351ba27SMatthew D Fleming.Fn sbuf_finish . 4397d7db529SConrad MeyerIf the returned drained length is 0, an error of 4407d7db529SConrad Meyer.Er EDEADLK 4417d7db529SConrad Meyeris set. 4424351ba27SMatthew D FlemingTo do unbuffered draining, initialize the sbuf with a two-byte buffer. 4434351ba27SMatthew D FlemingThe drain will be called for every byte added to the sbuf. 4444351ba27SMatthew D FlemingThe 4454351ba27SMatthew D Fleming.Fn sbuf_bcopyin , 446*76cb1112SConrad Meyer.Fn sbuf_bcpy , 447*76cb1112SConrad Meyer.Fn sbuf_clear , 4484351ba27SMatthew D Fleming.Fn sbuf_copyin , 449*76cb1112SConrad Meyer.Fn sbuf_cpy , 4504351ba27SMatthew D Fleming.Fn sbuf_trim , 451*76cb1112SConrad Meyer.Fn sbuf_data , 4524351ba27SMatthew D Flemingand 453*76cb1112SConrad Meyer.Fn sbuf_len 4544351ba27SMatthew D Flemingfunctions cannot be used on an sbuf with a drain. 4554351ba27SMatthew D Fleming.Pp 4564351ba27SMatthew D FlemingThe 457b0def2b5SDag-Erling Smørgrav.Fn sbuf_copyin 458b0def2b5SDag-Erling Smørgravfunction copies a NUL-terminated string from the specified userland 459b0def2b5SDag-Erling Smørgravaddress into the 460b0def2b5SDag-Erling Smørgrav.Fa sbuf . 461b0def2b5SDag-Erling SmørgravIf the 462b0def2b5SDag-Erling Smørgrav.Fa len 463b0def2b5SDag-Erling Smørgravargument is non-zero, no more than 464b0def2b5SDag-Erling Smørgrav.Fa len 465b0def2b5SDag-Erling Smørgravcharacters (not counting the terminating NUL) are copied; otherwise 466b0def2b5SDag-Erling Smørgravthe entire string, or as much of it as can fit in the 467b0def2b5SDag-Erling Smørgrav.Fa sbuf , 468b0def2b5SDag-Erling Smørgravis copied. 469b0def2b5SDag-Erling Smørgrav.Pp 470b0def2b5SDag-Erling SmørgravThe 471863edaecSDag-Erling Smørgrav.Fn sbuf_cpy 472863edaecSDag-Erling Smørgravfunction replaces the contents of the 473863edaecSDag-Erling Smørgrav.Fa sbuf 474b0def2b5SDag-Erling Smørgravwith those of the NUL-terminated string 475863edaecSDag-Erling Smørgrav.Fa str . 476863edaecSDag-Erling SmørgravThis is equivalent to calling 477863edaecSDag-Erling Smørgrav.Fn sbuf_cat 478863edaecSDag-Erling Smørgravwith a fresh 479863edaecSDag-Erling Smørgrav.Fa sbuf 480863edaecSDag-Erling Smørgravor one which position has been reset to zero with 481e499b74dSDag-Erling Smørgrav.Fn sbuf_clear 482e499b74dSDag-Erling Smørgravor 483863edaecSDag-Erling Smørgrav.Fn sbuf_setpos . 484863edaecSDag-Erling Smørgrav.Pp 485863edaecSDag-Erling SmørgravThe 486*76cb1112SConrad Meyer.Fn sbuf_nl_terminate 487*76cb1112SConrad Meyerfunction appends a trailing newline character, if the current line is non-empty 488*76cb1112SConrad Meyerand not already terminated by a newline character. 489*76cb1112SConrad Meyer.Pp 490*76cb1112SConrad MeyerThe 491863edaecSDag-Erling Smørgrav.Fn sbuf_printf 492863edaecSDag-Erling Smørgravfunction formats its arguments according to the format string pointed 493863edaecSDag-Erling Smørgravto by 494863edaecSDag-Erling Smørgrav.Fa fmt 495863edaecSDag-Erling Smørgravand appends the resulting string to the 496863edaecSDag-Erling Smørgrav.Fa sbuf 497863edaecSDag-Erling Smørgravat the current position. 498863edaecSDag-Erling Smørgrav.Pp 499863edaecSDag-Erling SmørgravThe 500371c0c84SKelly Yancey.Fn sbuf_vprintf 501371c0c84SKelly Yanceyfunction behaves the same as 502371c0c84SKelly Yancey.Fn sbuf_printf 503371c0c84SKelly Yanceyexcept that the arguments are obtained from the variable-length argument list 504371c0c84SKelly Yancey.Fa ap . 505371c0c84SKelly Yancey.Pp 506371c0c84SKelly YanceyThe 507863edaecSDag-Erling Smørgrav.Fn sbuf_putc 508863edaecSDag-Erling Smørgravfunction appends the character 509863edaecSDag-Erling Smørgrav.Fa c 510863edaecSDag-Erling Smørgravto the 511863edaecSDag-Erling Smørgrav.Fa sbuf 512863edaecSDag-Erling Smørgravat the current position. 513863edaecSDag-Erling Smørgrav.Pp 514863edaecSDag-Erling SmørgravThe 515371c0c84SKelly Yancey.Fn sbuf_trim 516371c0c84SKelly Yanceyfunction removes trailing whitespace from the 517371c0c84SKelly Yancey.Fa sbuf . 518371c0c84SKelly Yancey.Pp 519371c0c84SKelly YanceyThe 5204d369413SMatthew D Fleming.Fn sbuf_error 5214d369413SMatthew D Flemingfunction returns any error value that the 5224d369413SMatthew D Fleming.Fa sbuf 5237d7db529SConrad Meyermay have accumulated, either from the drain function, or 5247d7db529SConrad Meyer.Er ENOMEM 5257d7db529SConrad Meyerif the 526e499b74dSDag-Erling Smørgrav.Fa sbuf 527e499b74dSDag-Erling Smørgravoverflowed. 5284d369413SMatthew D FlemingThis function is generally not needed and instead the error code from 5294d369413SMatthew D Fleming.Fn sbuf_finish 5304d369413SMatthew D Flemingis the preferred way to discover whether an sbuf had an error. 531e499b74dSDag-Erling Smørgrav.Pp 532e499b74dSDag-Erling SmørgravThe 533863edaecSDag-Erling Smørgrav.Fn sbuf_finish 5344351ba27SMatthew D Flemingfunction will call the attached drain function if one exists until all 5354351ba27SMatthew D Flemingthe data in the 536863edaecSDag-Erling Smørgrav.Fa sbuf 5374351ba27SMatthew D Flemingis flushed. 5384351ba27SMatthew D FlemingIf there is no attached drain, 5394351ba27SMatthew D Fleming.Fn sbuf_finish 5404351ba27SMatthew D FlemingNUL-terminates the 5414351ba27SMatthew D Fleming.Fa sbuf . 5424351ba27SMatthew D FlemingIn either case it marks the 5434351ba27SMatthew D Fleming.Fa sbuf 5444351ba27SMatthew D Flemingas finished, which means that it may no longer be modified using 545863edaecSDag-Erling Smørgrav.Fn sbuf_setpos , 546863edaecSDag-Erling Smørgrav.Fn sbuf_cat , 5473393f8daSKenneth D. Merry.Fn sbuf_cpy , 548863edaecSDag-Erling Smørgrav.Fn sbuf_printf 549863edaecSDag-Erling Smørgravor 550db960cf0SMatthew D Fleming.Fn sbuf_putc , 551db960cf0SMatthew D Fleminguntil 552db960cf0SMatthew D Fleming.Fn sbuf_clear 553db960cf0SMatthew D Flemingis used to reset the sbuf. 554863edaecSDag-Erling Smørgrav.Pp 555863edaecSDag-Erling SmørgravThe 556863edaecSDag-Erling Smørgrav.Fn sbuf_data 5574351ba27SMatthew D Flemingfunction returns the actual string; 558e499b74dSDag-Erling Smørgrav.Fn sbuf_data 559e499b74dSDag-Erling Smørgravonly works on a finished 560863edaecSDag-Erling Smørgrav.Fa sbuf . 5614351ba27SMatthew D FlemingThe 562c0825cd5SJaakko Heinonen.Fn sbuf_len 563c0825cd5SJaakko Heinonenfunction returns the length of the string. 5644351ba27SMatthew D FlemingFor an 5654351ba27SMatthew D Fleming.Fa sbuf 5664351ba27SMatthew D Flemingwith an attached drain, 5674351ba27SMatthew D Fleming.Fn sbuf_len 5684351ba27SMatthew D Flemingreturns the length of the un-drained data. 5694351ba27SMatthew D Fleming.Fn sbuf_done 5704351ba27SMatthew D Flemingreturns non-zero if the 5714351ba27SMatthew D Fleming.Fa sbuf 5724351ba27SMatthew D Flemingis finished. 573f02db7b4SMikolaj Golub.Pp 574f02db7b4SMikolaj GolubThe 575f02db7b4SMikolaj Golub.Fn sbuf_start_section 576f02db7b4SMikolaj Goluband 577f02db7b4SMikolaj Golub.Fn sbuf_end_section 578f02db7b4SMikolaj Golubfunctions may be used for automatic section alignment. 579f02db7b4SMikolaj GolubThe arguments 580f02db7b4SMikolaj Golub.Fa pad 581f02db7b4SMikolaj Goluband 582f02db7b4SMikolaj Golub.Fa c 583f02db7b4SMikolaj Golubspecify the padding size and a character used for padding. 584f02db7b4SMikolaj GolubThe arguments 585f02db7b4SMikolaj Golub.Fa old_lenp 586f02db7b4SMikolaj Goluband 587f02db7b4SMikolaj Golub.Fa old_len 588f02db7b4SMikolaj Golubare to save and restore the current section length when nested sections 589f02db7b4SMikolaj Golubare used. 590f02db7b4SMikolaj GolubFor the top level section 591f02db7b4SMikolaj Golub.Dv NULL 592f02db7b4SMikolaj Goluband \-1 can be specified for 593f02db7b4SMikolaj Golub.Fa old_lenp 594f02db7b4SMikolaj Goluband 595f02db7b4SMikolaj Golub.Fa old_len 596f02db7b4SMikolaj Golubrespectively. 5975672fac9SKenneth D. Merry.Pp 5985672fac9SKenneth D. MerryThe 5995672fac9SKenneth D. Merry.Fn sbuf_hexdump 6005672fac9SKenneth D. Merryfunction prints an array of bytes to the supplied sbuf, along with an ASCII 6015672fac9SKenneth D. Merryrepresentation of the bytes if possible. 6025672fac9SKenneth D. MerrySee the 6035672fac9SKenneth D. Merry.Xr hexdump 3 6045672fac9SKenneth D. Merryman page for more details on the interface. 605388f3ce6SScott Long.Pp 606388f3ce6SScott LongThe 6077d7db529SConrad Meyer.Fn sbuf_printf_drain 6087d7db529SConrad Meyerfunction is a drain function that will call printf, or log to the console. 6097d7db529SConrad MeyerThe argument 6107d7db529SConrad Meyer.Fa arg 6117d7db529SConrad Meyermust be either 6127d7db529SConrad Meyer.Dv NULL , 6137d7db529SConrad Meyeror a valid pointer to a 6147d7db529SConrad Meyer.Vt size_t . 6157d7db529SConrad MeyerIf 6167d7db529SConrad Meyer.Fa arg 6177d7db529SConrad Meyeris not 6187d7db529SConrad Meyer.Dv NULL , 6197d7db529SConrad Meyerthe total bytes drained will be added to the value pointed to by 6207d7db529SConrad Meyer.Fa arg . 6217d7db529SConrad Meyer.Pp 6227d7db529SConrad MeyerThe 623388f3ce6SScott Long.Fn sbuf_putbuf 624388f3ce6SScott Longfunction printfs the sbuf to stdout if in userland, and to the console 625388f3ce6SScott Longand log if in the kernel. 6267d7db529SConrad MeyerThe 6277d7db529SConrad Meyer.Fa sbuf 6287d7db529SConrad Meyermust be finished before calling 6297d7db529SConrad Meyer.Fn sbuf_putbuf . 630388f3ce6SScott LongIt does not drain the buffer or update any pointers. 631863edaecSDag-Erling Smørgrav.Sh NOTES 632863edaecSDag-Erling SmørgravIf an operation caused an 633863edaecSDag-Erling Smørgrav.Fa sbuf 634e499b74dSDag-Erling Smørgravto overflow, most subsequent operations on it will fail until the 635e499b74dSDag-Erling Smørgrav.Fa sbuf 636e499b74dSDag-Erling Smørgravis finished using 637e499b74dSDag-Erling Smørgrav.Fn sbuf_finish 638e499b74dSDag-Erling Smørgravor reset using 639e499b74dSDag-Erling Smørgrav.Fn sbuf_clear , 640e499b74dSDag-Erling Smørgravor its position is reset to a value between 0 and one less than the 641e499b74dSDag-Erling Smørgravsize of its storage buffer using 642863edaecSDag-Erling Smørgrav.Fn sbuf_setpos , 643863edaecSDag-Erling Smørgravor it is reinitialized to a sufficiently short string using 644863edaecSDag-Erling Smørgrav.Fn sbuf_cpy . 6454351ba27SMatthew D Fleming.Pp 6464351ba27SMatthew D FlemingDrains in user-space will not always function as indicated. 6474351ba27SMatthew D FlemingWhile the drain function will be called immediately on overflow from 6484351ba27SMatthew D Flemingthe 6494351ba27SMatthew D Fleming.Fa sbuf_putc , 6504351ba27SMatthew D Fleming.Fa sbuf_bcat , 6514351ba27SMatthew D Fleming.Fa sbuf_cat 6524351ba27SMatthew D Flemingfunctions, 6534351ba27SMatthew D Fleming.Fa sbuf_printf 6544351ba27SMatthew D Flemingand 6554351ba27SMatthew D Fleming.Fa sbuf_vprintf 6564351ba27SMatthew D Flemingcurrently have no way to determine whether there will be an overflow 6574351ba27SMatthew D Fleminguntil after it occurs, and cannot do a partial expansion of the format 6584351ba27SMatthew D Flemingstring. 6594351ba27SMatthew D FlemingThus when using libsbuf the buffer may be extended to allow completion 6604351ba27SMatthew D Flemingof a single printf call, even though a drain is attached. 661863edaecSDag-Erling Smørgrav.Sh RETURN VALUES 66281ae4b8dSRuslan ErmilovThe 663863edaecSDag-Erling Smørgrav.Fn sbuf_new 66481ae4b8dSRuslan Ermilovfunction returns 665d6479358SDag-Erling Smørgrav.Dv NULL 666d6479358SDag-Erling Smørgravif it failed to allocate a storage buffer, and a pointer to the new 667d6479358SDag-Erling Smørgrav.Fa sbuf 668863edaecSDag-Erling Smørgravotherwise. 669863edaecSDag-Erling Smørgrav.Pp 67081ae4b8dSRuslan ErmilovThe 671863edaecSDag-Erling Smørgrav.Fn sbuf_setpos 67281ae4b8dSRuslan Ermilovfunction returns \-1 if 673863edaecSDag-Erling Smørgrav.Fa pos 674863edaecSDag-Erling Smørgravwas invalid, and zero otherwise. 675863edaecSDag-Erling Smørgrav.Pp 67681ae4b8dSRuslan ErmilovThe 67764223daeSMark Johnston.Fn sbuf_bcat , 678863edaecSDag-Erling Smørgrav.Fn sbuf_cat , 679863edaecSDag-Erling Smørgrav.Fn sbuf_cpy , 680863edaecSDag-Erling Smørgrav.Fn sbuf_printf , 681371c0c84SKelly Yancey.Fn sbuf_putc , 682863edaecSDag-Erling Smørgravand 683371c0c84SKelly Yancey.Fn sbuf_trim 68481ae4b8dSRuslan Ermilovfunctions 685863edaecSDag-Erling Smørgravall return \-1 if the buffer overflowed, and zero otherwise. 686863edaecSDag-Erling Smørgrav.Pp 68781ae4b8dSRuslan ErmilovThe 6884d369413SMatthew D Fleming.Fn sbuf_error 6894d369413SMatthew D Flemingfunction returns a non-zero value if the buffer has an overflow or 6904d369413SMatthew D Flemingdrain error, and zero otherwise. 691e499b74dSDag-Erling Smørgrav.Pp 69281ae4b8dSRuslan ErmilovThe 693863edaecSDag-Erling Smørgrav.Fn sbuf_len 694569dd0f3SJaakko Heinonenfunction returns \-1 if the buffer overflowed. 69549091c48SPoul-Henning Kamp.Pp 69681ae4b8dSRuslan ErmilovThe 69749091c48SPoul-Henning Kamp.Fn sbuf_copyin 69881ae4b8dSRuslan Ermilovfunction 69949091c48SPoul-Henning Kampreturns \-1 if copying string from userland failed, and number of bytes 70049091c48SPoul-Henning Kampcopied otherwise. 7016ab7244aSPoul-Henning Kamp.Pp 7024351ba27SMatthew D FlemingThe 703f02db7b4SMikolaj Golub.Fn sbuf_end_section 704f02db7b4SMikolaj Golubfunction returns the section length or \-1 if the buffer has an error. 705f02db7b4SMikolaj Golub.Pp 706f02db7b4SMikolaj GolubThe 7076ab7244aSPoul-Henning Kamp.Fn sbuf_finish 9 7087d7db529SConrad Meyerfunction (the kernel version) returns 7097d7db529SConrad Meyer.Er ENOMEM 7107d7db529SConrad Meyerif the sbuf overflowed before being finished, 7114351ba27SMatthew D Flemingor returns the error code from the drain if one is attached. 7126ab7244aSPoul-Henning Kamp.Pp 7136ab7244aSPoul-Henning KampThe 7146ab7244aSPoul-Henning Kamp.Fn sbuf_finish 3 7156ab7244aSPoul-Henning Kampfunction (the userland version) 7166ab7244aSPoul-Henning Kampwill return zero for success and \-1 and set errno on error. 7176ab7244aSPoul-Henning Kamp.Sh EXAMPLES 7186ab7244aSPoul-Henning Kamp.Bd -literal -compact 7197beb104dSEnji Cooper#include <sys/types.h> 7206ab7244aSPoul-Henning Kamp#include <sys/sbuf.h> 7216ab7244aSPoul-Henning Kamp 7226ab7244aSPoul-Henning Kampstruct sbuf *sb; 7236ab7244aSPoul-Henning Kamp 7246ab7244aSPoul-Henning Kampsb = sbuf_new_auto(); 725c920aa7aSPoul-Henning Kampsbuf_cat(sb, "Customers found:\en"); 7266ab7244aSPoul-Henning KampTAILQ_FOREACH(foo, &foolist, list) { 727c920aa7aSPoul-Henning Kamp sbuf_printf(sb, " %4d %s\en", foo->index, foo->name); 728c920aa7aSPoul-Henning Kamp sbuf_printf(sb, " Address: %s\en", foo->address); 729c920aa7aSPoul-Henning Kamp sbuf_printf(sb, " Zip: %s\en", foo->zipcode); 7306ab7244aSPoul-Henning Kamp} 731c5a0813dSJaakko Heinonenif (sbuf_finish(sb) != 0) /* Check for any and all errors */ 7326ab7244aSPoul-Henning Kamp err(1, "Could not generate message"); 7336ab7244aSPoul-Henning Kamptransmit_msg(sbuf_data(sb), sbuf_len(sb)); 7346ab7244aSPoul-Henning Kampsbuf_delete(sb); 7356ab7244aSPoul-Henning Kamp.Ed 736863edaecSDag-Erling Smørgrav.Sh SEE ALSO 7375672fac9SKenneth D. Merry.Xr hexdump 3 , 738863edaecSDag-Erling Smørgrav.Xr printf 3 , 739863edaecSDag-Erling Smørgrav.Xr strcat 3 , 740d68b700aSRuslan Ermilov.Xr strcpy 3 , 741d68b700aSRuslan Ermilov.Xr copyin 9 , 742e05f3134SAndrew R. Reiter.Xr copyinstr 9 , 743e05f3134SAndrew R. Reiter.Xr printf 9 744863edaecSDag-Erling Smørgrav.Sh HISTORY 745863edaecSDag-Erling SmørgravThe 74681ae4b8dSRuslan Ermilov.Nm 747863edaecSDag-Erling Smørgravfamily of functions first appeared in 74822cbe5e3SDag-Erling Smørgrav.Fx 4.4 . 749863edaecSDag-Erling Smørgrav.Sh AUTHORS 750863edaecSDag-Erling Smørgrav.An -nosplit 751863edaecSDag-Erling SmørgravThe 75281ae4b8dSRuslan Ermilov.Nm 753863edaecSDag-Erling Smørgravfamily of functions was designed by 7548a7314fcSBaptiste Daroussin.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org 755863edaecSDag-Erling Smørgravand implemented by 7568a7314fcSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org . 757e499b74dSDag-Erling SmørgravAdditional improvements were suggested by 7588a7314fcSBaptiste Daroussin.An Justin T. Gibbs Aq Mt gibbs@FreeBSD.org . 759371c0c84SKelly YanceyAuto-extend support added by 7608a7314fcSBaptiste Daroussin.An Kelly Yancey Aq Mt kbyanc@FreeBSD.org . 7614351ba27SMatthew D FlemingDrain functionality added by 7628a7314fcSBaptiste Daroussin.An Matthew Fleming Aq Mt mdf@FreeBSD.org . 763863edaecSDag-Erling Smørgrav.Pp 764863edaecSDag-Erling SmørgravThis manual page was written by 7658a7314fcSBaptiste Daroussin.An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org . 766