From owner-svn-src-all@FreeBSD.ORG Thu Apr 11 19:51:54 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 63E79D2A; Thu, 11 Apr 2013 19:51:54 +0000 (UTC) (envelope-from trociny@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 3C17A164E; Thu, 11 Apr 2013 19:51:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3BJpsmB092588; Thu, 11 Apr 2013 19:51:54 GMT (envelope-from trociny@svn.freebsd.org) Received: (from trociny@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3BJpsi0092587; Thu, 11 Apr 2013 19:51:54 GMT (envelope-from trociny@svn.freebsd.org) Message-Id: <201304111951.r3BJpsi0092587@svn.freebsd.org> From: Mikolaj Golub Date: Thu, 11 Apr 2013 19:51:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249379 - head/share/man/man9 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Apr 2013 19:51:54 -0000 Author: trociny Date: Thu Apr 11 19:51:53 2013 New Revision: 249379 URL: http://svnweb.freebsd.org/changeset/base/249379 Log: Document sbuf_start_section() and sbuf_end_section() functions. MFC after: 1 month Modified: head/share/man/man9/sbuf.9 Modified: head/share/man/man9/sbuf.9 ============================================================================== --- head/share/man/man9/sbuf.9 Thu Apr 11 19:50:10 2013 (r249378) +++ head/share/man/man9/sbuf.9 Thu Apr 11 19:51:53 2013 (r249379) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 21, 2011 +.Dd April 11, 2013 .Dt SBUF 9 .Os .Sh NAME @@ -51,7 +51,9 @@ .Nm sbuf_data , .Nm sbuf_len , .Nm sbuf_done , -.Nm sbuf_delete +.Nm sbuf_delete , +.Nm sbuf_start_section , +.Nm sbuf_end_section .Nd safe string composition .Sh SYNOPSIS .In sys/types.h @@ -100,6 +102,10 @@ .Fn sbuf_done "struct sbuf *s" .Ft void .Fn sbuf_delete "struct sbuf *s" +.Ft void +.Fn sbuf_start_section "struct sbuf *s" "ssize_t *old_lenp" +.Ft ssize_t +.Fn sbuf_end_section "struct sbuf *s" "ssize_t old_len" "size_t pad" "int c" .In sys/sysctl.h .Ft struct sbuf * .Fn sbuf_new_for_sysctl "struct sbuf *s" "char *buf" "int length" "struct sysctl_req *req" @@ -402,6 +408,30 @@ returns the length of the un-drained dat returns non-zero if the .Fa sbuf is finished. +.Pp +The +.Fn sbuf_start_section +and +.Fn sbuf_end_section +functions may be used for automatic section alignment. +The arguments +.Fa pad +and +.Fa c +specify the padding size and a character used for padding. +The arguments +.Fa old_lenp +and +.Fa old_len +are to save and restore the current section length when nested sections +are used. +For the top level section +.Dv NULL +and \-1 can be specified for +.Fa old_lenp +and +.Fa old_len +respectively. .Sh NOTES If an operation caused an .Fa sbuf @@ -473,6 +503,10 @@ returns \-1 if copying string from userl copied otherwise. .Pp The +.Fn sbuf_end_section +function returns the section length or \-1 if the buffer has an error. +.Pp +The .Fn sbuf_finish 9 function (the kernel version) returns ENOMEM if the sbuf overflowed before being finished,