From nobody Wed Feb 11 10:03:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; envelope-from=libvir-list-bounces@redhat.com; helo=mx5-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mx.zohomail.com with SMTPS id 1489595997977468.9625198533255; Wed, 15 Mar 2017 09:39:57 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2FGaoTw016460; Wed, 15 Mar 2017 12:36:50 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2FGajvx024879 for ; Wed, 15 Mar 2017 12:36:45 -0400 Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2FGafIG000870; Wed, 15 Mar 2017 12:36:44 -0400 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Mar 2017 17:37:14 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 02/23] util: buffer: Add API to set indentation level to a given value X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" It will be useful to set indentation level to 0 after formatting a nested structure rather than having to track the depth. --- src/libvirt_private.syms | 1 + src/util/virbuffer.c | 19 +++++++++++++++++++ src/util/virbuffer.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4efea0098..39e2b40c5 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1303,6 +1303,7 @@ virBufferEscapeShell; virBufferEscapeString; virBufferFreeAndReset; virBufferGetIndent; +virBufferSetIndent; virBufferStrcat; virBufferTrim; virBufferURIEncodeString; diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index 41d541b32..8f0f49d7f 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -88,6 +88,25 @@ virBufferAdjustIndent(virBufferPtr buf, int indent) buf->indent +=3D indent; } + +/** + * virBufferAdjustIndent: + * @buf: the buffer + * @indent: new indentation size. + * + * Set the auto-indent value to @indent. See virBufferAdjustIndent on how = auto + * indentation is applied. + */ +void +virBufferSetIndent(virBufferPtr buf, int indent) +{ + if (!buf || buf->error) + return; + + buf->indent =3D indent; +} + + /** * virBufferGetIndent: * @buf: the buffer diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h index 94f14b5b1..d1b64ca3a 100644 --- a/src/util/virbuffer.h +++ b/src/util/virbuffer.h @@ -95,6 +95,8 @@ void virBufferURIEncodeString(virBufferPtr buf, const cha= r *str); virBufferAdd(buf_, "" literal_string_ "", sizeof(literal_string_) - 1) void virBufferAdjustIndent(virBufferPtr buf, int indent); +void virBufferSetIndent(virBufferPtr, int indent); + int virBufferGetIndent(const virBuffer *buf, bool dynamic); void virBufferTrim(virBufferPtr buf, const char *trim, int len); --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list