[PATCH 03/28] Rename buf.{c,h} to virbuffer.{c,h}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/Makefile.am                           |   2 +-
 src/conf/capabilities.c                   |   2 +-
 src/conf/capabilities.h                   |   2 +-
 src/conf/cpu_conf.c                       |   2 +-
 src/conf/cpu_conf.h                       |   2 +-
 src/conf/device_conf.c                    |   2 +-
 src/conf/device_conf.h                    |   2 +-
 src/conf/domain_conf.c                    |   2 +-
 src/conf/interface_conf.c                 |   2 +-
 src/conf/netdev_bandwidth_conf.h          |   2 +-
 src/conf/netdev_vlan_conf.h               |   2 +-
 src/conf/netdev_vport_profile_conf.h      |   2 +-
 src/conf/network_conf.c                   |   2 +-
 src/conf/node_device_conf.c               |   2 +-
 src/conf/nwfilter_conf.h                  |   2 +-
 src/conf/nwfilter_params.h                |   2 +-
 src/conf/secret_conf.c                    |   2 +-
 src/conf/snapshot_conf.c                  |   2 +-
 src/conf/storage_conf.c                   |   2 +-
 src/conf/storage_encryption_conf.c        |   2 +-
 src/conf/storage_encryption_conf.h        |   2 +-
 src/cpu/cpu_powerpc.c                     |   2 +-
 src/cpu/cpu_x86.c                         |   2 +-
 src/esx/esx_vi.c                          |   2 +-
 src/esx/esx_vi_methods.c                  |   2 +-
 src/esx/esx_vi_types.c                    |   2 +-
 src/esx/esx_vi_types.h                    |   2 +-
 src/hyperv/hyperv_wmi.c                   |   2 +-
 src/hyperv/hyperv_wmi.h                   |   2 +-
 src/lxc/lxc_fuse.c                        |   2 +-
 src/network/bridge_driver.c               |   2 +-
 src/node_device/node_device_udev.c        |   2 +-
 src/nwfilter/nwfilter_ebiptables_driver.c |   2 +-
 src/nwfilter/nwfilter_learnipaddr.c       |   2 +-
 src/openvz/openvz_conf.c                  |   2 +-
 src/openvz/openvz_driver.c                |   2 +-
 src/phyp/phyp_driver.c                    |   2 +-
 src/qemu/qemu_conf.c                      |   2 +-
 src/qemu/qemu_driver.c                    |   2 +-
 src/qemu/qemu_monitor_text.c              |   2 +-
 src/remote/remote_driver.c                |   2 +-
 src/rpc/virnetsshsession.c                |   2 +-
 src/security/virt-aa-helper.c             |   2 +-
 src/test/test_driver.c                    |   2 +-
 src/uml/uml_conf.c                        |   2 +-
 src/uml/uml_driver.c                      |   2 +-
 src/util/buf.c                            | 682 ------------------------------
 src/util/buf.h                            |  82 ----
 src/util/command.c                        |   2 +-
 src/util/command.h                        |   2 +-
 src/util/conf.c                           |   2 +-
 src/util/logging.c                        |   2 +-
 src/util/logging.h                        |   2 +-
 src/util/sexpr.h                          |   2 +-
 src/util/sysinfo.h                        |   2 +-
 src/util/util.c                           |   2 +-
 src/util/virbitmap.c                      |   2 +-
 src/util/virbuffer.c                      | 682 ++++++++++++++++++++++++++++++
 src/util/virbuffer.h                      |  82 ++++
 src/util/virstring.c                      |   2 +-
 src/util/viruri.c                         |   2 +-
 src/util/xml.c                            |   2 +-
 src/xen/xen_hypervisor.c                  |   2 +-
 src/xen/xend_internal.c                   |   2 +-
 src/xen/xend_internal.h                   |   2 +-
 src/xen/xm_internal.c                     |   2 +-
 src/xenapi/xenapi_driver.c                |   2 +-
 src/xenapi/xenapi_utils.c                 |   2 +-
 tests/cputest.c                           |   2 +-
 tests/testutils.c                         |   2 +-
 tests/virbuftest.c                        |   2 +-
 tools/virsh-domain.c                      |   2 +-
 tools/virsh-host.c                        |   2 +-
 tools/virsh-interface.c                   |   2 +-
 tools/virsh-network.c                     |   2 +-
 tools/virsh-nodedev.c                     |   2 +-
 tools/virsh-nwfilter.c                    |   2 +-
 tools/virsh-pool.c                        |   2 +-
 tools/virsh-secret.c                      |   2 +-
 tools/virsh-snapshot.c                    |   2 +-
 tools/virsh-volume.c                      |   2 +-
 tools/virsh.c                             |   2 +-
 82 files changed, 842 insertions(+), 842 deletions(-)
 delete mode 100644 src/util/buf.c
 delete mode 100644 src/util/buf.h
 create mode 100644 src/util/virbuffer.c
 create mode 100644 src/util/virbuffer.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 25a21e8..fd21aa6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -53,7 +53,6 @@ augeastest_DATA =
 # These files are not related to driver APIs. Simply generic
 # helper APIs for various purposes
 UTIL_SOURCES =							\
-		util/buf.c util/buf.h				\
 		util/command.c util/command.h			\
 		util/conf.c util/conf.h				\
 		util/event.c util/event.h			\
@@ -83,6 +82,7 @@ UTIL_SOURCES =							\
 		util/virauth.c util/virauth.h			\
 		util/virauthconfig.c util/virauthconfig.h	\
 		util/virbitmap.c util/virbitmap.h		\
+		util/virbuffer.c util/virbuffer.h		\
 		util/virfile.c util/virfile.h			\
 		util/virnodesuspend.c util/virnodesuspend.h	\
 		util/virobject.c util/virobject.h		\
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index a8ee2cf..3b8fef1 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -26,7 +26,7 @@
 #include <strings.h>
 
 #include "capabilities.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "uuid.h"
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 641f279..4b6c2e5 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -25,7 +25,7 @@
 # define __VIR_CAPABILITIES_H
 
 # include "internal.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "cpu_conf.h"
 # include "virmacaddr.h"
 
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 8cb54a3..190b088 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -26,7 +26,7 @@
 #include "virterror_internal.h"
 #include "memory.h"
 #include "util.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "cpu_conf.h"
 #include "domain_conf.h"
 
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index 38fc675..357057d 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -25,7 +25,7 @@
 # define __VIR_CPU_CONF_H__
 
 # include "util.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "xml.h"
 # include "virbitmap.h"
 
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 7b97f45..daf57bc 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -27,7 +27,7 @@
 #include "xml.h"
 #include "uuid.h"
 #include "util.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "device_conf.h"
 
 #define VIR_FROM_THIS VIR_FROM_DEVICE
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index 5318738..09d6be9 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -30,7 +30,7 @@
 # include "internal.h"
 # include "util.h"
 # include "threads.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 enum virDeviceAddressPciMulti {
     VIR_DEVICE_ADDRESS_PCI_MULTI_DEFAULT = 0,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c90c6b9..d1fadc3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -39,7 +39,7 @@
 #include "xml.h"
 #include "uuid.h"
 #include "util.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "logging.h"
 #include "nwfilter_conf.h"
 #include "storage_file.h"
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index fc3602a..738ef33 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -31,7 +31,7 @@
 #include "xml.h"
 #include "uuid.h"
 #include "util.h"
-#include "buf.h"
+#include "virbuffer.h"
 
 #define VIR_FROM_THIS VIR_FROM_INTERFACE
 
diff --git a/src/conf/netdev_bandwidth_conf.h b/src/conf/netdev_bandwidth_conf.h
index 0080165..216a540 100644
--- a/src/conf/netdev_bandwidth_conf.h
+++ b/src/conf/netdev_bandwidth_conf.h
@@ -25,7 +25,7 @@
 
 # include "internal.h"
 # include "virnetdevbandwidth.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "xml.h"
 
 virNetDevBandwidthPtr virNetDevBandwidthParse(xmlNodePtr node,
diff --git a/src/conf/netdev_vlan_conf.h b/src/conf/netdev_vlan_conf.h
index 81b0d84..19b50cc 100644
--- a/src/conf/netdev_vlan_conf.h
+++ b/src/conf/netdev_vlan_conf.h
@@ -24,7 +24,7 @@
 
 # include "internal.h"
 # include "virnetdevvlan.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "xml.h"
 
 int virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlanPtr def);
diff --git a/src/conf/netdev_vport_profile_conf.h b/src/conf/netdev_vport_profile_conf.h
index d6d58ef..15ecbd6 100644
--- a/src/conf/netdev_vport_profile_conf.h
+++ b/src/conf/netdev_vport_profile_conf.h
@@ -25,7 +25,7 @@
 
 # include "internal.h"
 # include "virnetdevvportprofile.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "xml.h"
 
 typedef enum {
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index ff7366d..42cb87e 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -41,7 +41,7 @@
 #include "xml.h"
 #include "uuid.h"
 #include "util.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "c-ctype.h"
 #include "virfile.h"
 
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 41fa8e4..50fcf0b 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -34,7 +34,7 @@
 #include "memory.h"
 #include "xml.h"
 #include "util.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "uuid.h"
 #include "pci.h"
 #include "virrandom.h"
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 805fbe7..d597064 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -31,7 +31,7 @@
 # include "util.h"
 # include "virhash.h"
 # include "xml.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "virsocketaddr.h"
 # include "virmacaddr.h"
 
diff --git a/src/conf/nwfilter_params.h b/src/conf/nwfilter_params.h
index 6c3ce54..ac57796 100644
--- a/src/conf/nwfilter_params.h
+++ b/src/conf/nwfilter_params.h
@@ -24,7 +24,7 @@
 # define NWFILTER_PARAMS_H
 
 # include "virhash.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "virmacaddr.h"
 
 enum virNWFilterVarValueType {
diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index a6b4934..ec67f57 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -23,7 +23,7 @@
 #include <config.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "datatypes.h"
 #include "logging.h"
 #include "memory.h"
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 95b7943..38a3e2a 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -30,7 +30,7 @@
 
 #include "internal.h"
 #include "virbitmap.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "count-one-bits.h"
 #include "datatypes.h"
 #include "domain_conf.h"
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index ad0f0c1..b81c08c 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -40,7 +40,7 @@
 
 #include "xml.h"
 #include "uuid.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "memory.h"
 #include "virfile.h"
diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c
index a8b1397..0c2bded 100644
--- a/src/conf/storage_encryption_conf.c
+++ b/src/conf/storage_encryption_conf.c
@@ -27,7 +27,7 @@
 
 #include "internal.h"
 
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "storage_conf.h"
 #include "storage_encryption_conf.h"
diff --git a/src/conf/storage_encryption_conf.h b/src/conf/storage_encryption_conf.h
index e063478..40a8497 100644
--- a/src/conf/storage_encryption_conf.h
+++ b/src/conf/storage_encryption_conf.h
@@ -24,7 +24,7 @@
 # define __VIR_STORAGE_ENCRYPTION_H__
 
 # include "internal.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "util.h"
 
 # include <libxml/tree.h>
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index e420ffb..363d6c1 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -32,7 +32,7 @@
 #include "cpu.h"
 
 #include "cpu_map.h"
-#include "buf.h"
+#include "virbuffer.h"
 
 #define VIR_FROM_THIS VIR_FROM_CPU
 
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index ca8cd92..563cd67 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -31,7 +31,7 @@
 #include "cpu.h"
 #include "cpu_map.h"
 #include "cpu_x86.h"
-#include "buf.h"
+#include "virbuffer.h"
 
 
 #define VIR_FROM_THIS VIR_FROM_CPU
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 564b35c..d645bfb 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -26,7 +26,7 @@
 #include <libxml/parser.h>
 #include <libxml/xpathInternals.h>
 
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "logging.h"
 #include "util.h"
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index 0f9d612..a3c3c8b 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -23,7 +23,7 @@
 
 #include <config.h>
 
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "logging.h"
 #include "uuid.h"
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 0146728..1654e1b 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -27,7 +27,7 @@
 #include <libxml/parser.h>
 #include <libxml/xpathInternals.h>
 
-#include "buf.h"
+#include "virbuffer.h"
 #include "datatypes.h"
 #include "memory.h"
 #include "logging.h"
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index a250bf8..92dc16f 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -23,7 +23,7 @@
 #ifndef __ESX_VI_TYPES_H__
 # define __ESX_VI_TYPES_H__
 
-# include "buf.h"
+# include "virbuffer.h"
 
 typedef enum _esxVI_Type esxVI_Type;
 typedef struct _esxVI_Object esxVI_Object;
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 4023588..0a6b107 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -31,7 +31,7 @@
 #include "memory.h"
 #include "util.h"
 #include "uuid.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "hyperv_private.h"
 #include "hyperv_wmi.h"
 
diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h
index d9e8578..85a2bbc 100644
--- a/src/hyperv/hyperv_wmi.h
+++ b/src/hyperv/hyperv_wmi.h
@@ -25,7 +25,7 @@
 #ifndef __HYPERV_WMI_H__
 # define __HYPERV_WMI_H__
 
-# include "buf.h"
+# include "virbuffer.h"
 # include "hyperv_private.h"
 # include "hyperv_wmi_classes.h"
 # include "openwsman.h"
diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c
index e0c51aa..4e7df55 100644
--- a/src/lxc/lxc_fuse.c
+++ b/src/lxc/lxc_fuse.c
@@ -34,7 +34,7 @@
 #include "virterror_internal.h"
 #include "logging.h"
 #include "virfile.h"
-#include "buf.h"
+#include "virbuffer.h"
 
 #define VIR_FROM_THIS VIR_FROM_LXC
 
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index c62e729..c65f0bb 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -50,7 +50,7 @@
 #include "network_conf.h"
 #include "device_conf.h"
 #include "driver.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "virpidfile.h"
 #include "util.h"
 #include "command.h"
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index c9ca00c..b3499fb 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -36,7 +36,7 @@
 #include "memory.h"
 #include "uuid.h"
 #include "util.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "pci.h"
 
 #define VIR_FROM_THIS VIR_FROM_NODEDEV
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index cdf0efc..5cfc036 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -30,7 +30,7 @@
 
 #include "internal.h"
 
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "logging.h"
 #include "virterror_internal.h"
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 85e0e7e..361bdce 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -41,7 +41,7 @@
 #include "internal.h"
 
 #include "intprops.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "logging.h"
 #include "datatypes.h"
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 2bd9caf..3f89db3 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -47,7 +47,7 @@
 #include "openvz_conf.h"
 #include "openvz_util.h"
 #include "uuid.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "nodeinfo.h"
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index c5f5ca0..1b213c4 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -49,7 +49,7 @@
 #include "datatypes.h"
 #include "openvz_driver.h"
 #include "openvz_util.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "openvz_conf.h"
 #include "nodeinfo.h"
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 63017f4..e54f0f3 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -47,7 +47,7 @@
 #include "virauth.h"
 #include "util.h"
 #include "datatypes.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "logging.h"
 #include "driver.h"
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index a1b1d04..4a8b857 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -41,7 +41,7 @@
 #include "qemu_capabilities.h"
 #include "qemu_bridge_filter.h"
 #include "uuid.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "conf.h"
 #include "util.h"
 #include "memory.h"
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e87397f..0ebbf7d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -62,7 +62,7 @@
 #include "virterror_internal.h"
 #include "logging.h"
 #include "datatypes.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "nodeinfo.h"
 #include "stats_linux.h"
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index fa10600..a12adb6 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -39,7 +39,7 @@
 #include "driver.h"
 #include "datatypes.h"
 #include "virterror_internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 
 #ifdef WITH_DTRACE_PROBES
 # include "libvirt_qemu_probes.h"
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 5cc7e32..f32e88e 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -34,7 +34,7 @@
 #include "datatypes.h"
 #include "domain_event.h"
 #include "driver.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "remote_driver.h"
 #include "remote_protocol.h"
 #include "qemu_protocol.h"
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index 286cc4d..d890569 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -26,7 +26,7 @@
 #include "virnetsshsession.h"
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "logging.h"
 #include "configmake.h"
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 888c416..78ebae3 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -40,7 +40,7 @@
 #include <locale.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "memory.h"
 #include "command.h"
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 6ca59e2..8e57370 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -35,7 +35,7 @@
 #include "virterror_internal.h"
 #include "datatypes.h"
 #include "test_driver.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "uuid.h"
 #include "capabilities.h"
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index 6ef6de3..11c915e 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -37,7 +37,7 @@
 
 #include "uml_conf.h"
 #include "uuid.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "conf.h"
 #include "util.h"
 #include "memory.h"
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 887dca6..8dece66 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -46,7 +46,7 @@
 
 #include "uml_driver.h"
 #include "uml_conf.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "nodeinfo.h"
 #include "stats_linux.h"
diff --git a/src/util/buf.c b/src/util/buf.c
deleted file mode 100644
index 030dc97..0000000
--- a/src/util/buf.c
+++ /dev/null
@@ -1,682 +0,0 @@
-/*
- * buf.c: buffers for libvirt
- *
- * Copyright (C) 2005-2008, 2010-2012 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * Daniel Veillard <veillard@xxxxxxxxxx>
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include "c-ctype.h"
-
-#define __VIR_BUFFER_C__
-
-#include "buf.h"
-#include "memory.h"
-
-
-/* If adding more fields, ensure to edit buf.h to match
-   the number of fields */
-struct _virBuffer {
-    unsigned int size;
-    unsigned int use;
-    unsigned int error; /* errno value, or -1 for usage error */
-    int indent;
-    char *content;
-};
-
-/**
- * virBufferFail
- * @buf: the buffer
- * @error: which error occurred (errno value, or -1 for usage)
- *
- * Mark the buffer as failed, free the content and set the error flag.
- */
-static void
-virBufferSetError(virBufferPtr buf, int error)
-{
-    VIR_FREE(buf->content);
-    buf->size = 0;
-    buf->use = 0;
-    buf->indent = 0;
-    buf->error = error;
-}
-
-/**
- * virBufferAdjustIndent:
- * @buf: the buffer
- * @indent: adjustment to make
- *
- * Alter the auto-indent value by adding indent (positive to increase,
- * negative to decrease).  Automatic indentation is performed by all
- * additive functions when the existing buffer is empty or ends with a
- * newline (however, note that no indentation is added after newlines
- * embedded in an appended string).  If @indent would cause overflow,
- * the buffer error indicator is set.
- */
-void
-virBufferAdjustIndent(virBufferPtr buf, int indent)
-{
-    if (!buf || buf->error)
-        return;
-    if (indent > 0 ? INT_MAX - indent < buf->indent
-        : buf->indent < -indent) {
-        virBufferSetError(buf, -1);
-        return;
-    }
-    buf->indent += indent;
-}
-
-/**
- * virBufferGetIndent:
- * @buf: the buffer
- * @dynamic: if false, return set value; if true, return 0 unless next
- * append would be affected by auto-indent
- *
- * Return the current auto-indent value, or -1 if there has been an error.
- */
-int
-virBufferGetIndent(const virBufferPtr buf, bool dynamic)
-{
-    if (!buf || buf->error)
-        return -1;
-    if (dynamic && buf->use && buf->content[buf->use - 1] != '\n')
-        return 0;
-    return buf->indent;
-}
-
-/**
- * virBufferGrow:
- * @buf:  the buffer
- * @len:  the minimum free size to allocate on top of existing used space
- *
- * Grow the available space of a buffer to at least @len bytes.
- *
- * Returns zero on success or -1 on error
- */
-static int
-virBufferGrow(virBufferPtr buf, unsigned int len)
-{
-    int size;
-
-    if (buf->error)
-        return -1;
-
-    if ((len + buf->use) < buf->size)
-        return 0;
-
-    size = buf->use + len + 1000;
-
-    if (VIR_REALLOC_N(buf->content, size) < 0) {
-        virBufferSetError(buf, errno);
-        return -1;
-    }
-    buf->size = size;
-    return 0;
-}
-
-/**
- * virBufferAdd:
- * @buf: the buffer to append to
- * @str: the string
- * @len: the number of bytes to add, or -1
- *
- * Add a string range to an XML buffer. If @len == -1, the length of
- * str is recomputed to the full string.  Auto indentation may be applied.
- *
- */
-void
-virBufferAdd(virBufferPtr buf, const char *str, int len)
-{
-    unsigned int needSize;
-    int indent;
-
-    if (!str || !buf || (len == 0 && buf->indent == 0))
-        return;
-
-    if (buf->error)
-        return;
-
-    indent = virBufferGetIndent(buf, true);
-
-    if (len < 0)
-        len = strlen(str);
-
-    needSize = buf->use + indent + len + 2;
-    if (needSize > buf->size &&
-        virBufferGrow(buf, needSize - buf->use) < 0)
-        return;
-
-    memset(&buf->content[buf->use], ' ', indent);
-    memcpy(&buf->content[buf->use + indent], str, len);
-    buf->use += indent + len;
-    buf->content[buf->use] = '\0';
-}
-
-/**
- * virBufferAddChar:
- * @buf: the buffer to append to
- * @c: the character to add
- *
- * Add a single character 'c' to a buffer.  Auto indentation may be applied.
- *
- */
-void
-virBufferAddChar(virBufferPtr buf, char c)
-{
-    virBufferAdd(buf, &c, 1);
-}
-
-/**
- * virBufferCurrentContent:
- * @buf: Buffer
- *
- * Get the current content from the buffer.  The content is only valid
- * until the next operation on @buf, and an empty string is returned if
- * no content is present yet.
- *
- * Returns the buffer content or NULL in case of error.
- */
-const char *
-virBufferCurrentContent(virBufferPtr buf)
-{
-    if (!buf || buf->error)
-        return NULL;
-    return buf->use ? buf->content : "";
-}
-
-/**
- * virBufferContentAndReset:
- * @buf: Buffer
- *
- * Get the content from the buffer and free (only) the buffer structure.
- * The caller owns the returned string & should free it when no longer
- * required. The buffer object is reset to its initial state.  This
- * interface intentionally returns NULL instead of an empty string if
- * there is no content.
- *
- * Returns the buffer content or NULL in case of error.
- */
-char *
-virBufferContentAndReset(virBufferPtr buf)
-{
-    char *str;
-    if (buf == NULL)
-        return NULL;
-
-    if (buf->error) {
-        memset(buf, 0, sizeof(*buf));
-        return NULL;
-    }
-
-    str = buf->content;
-    memset(buf, 0, sizeof(*buf));
-    return str;
-}
-
-/**
- * virBufferFreeAndReset:
- * @buf: the buffer to free and reset
- *
- * Frees the buffer content and resets the buffer structure.
- */
-void virBufferFreeAndReset(virBufferPtr buf)
-{
-    char *str = virBufferContentAndReset(buf);
-
-    VIR_FREE(str);
-}
-
-/**
- * virBufferError:
- * @buf: the buffer
- *
- * Check to see if the buffer is in an error state due
- * to failed memory allocation or usage error
- *
- * Return positive errno value or -1 on usage error, 0 if normal
- */
-int
-virBufferError(const virBufferPtr buf)
-{
-    if (buf == NULL)
-        return -1;
-
-    return buf->error;
-}
-
-/**
- * virBufferUse:
- * @buf: the usage of the string in the buffer
- *
- * Return the string usage in bytes
- */
-unsigned int
-virBufferUse(const virBufferPtr buf)
-{
-    if (buf == NULL)
-        return 0;
-
-    return buf->use;
-}
-
-/**
- * virBufferAsprintf:
- * @buf: the buffer to append to
- * @format:  the format
- * @...:  the variable list of arguments
- *
- * Do a formatted print to an XML buffer.  Auto indentation may be applied.
- */
-void
-virBufferAsprintf(virBufferPtr buf, const char *format, ...)
-{
-    va_list argptr;
-    va_start(argptr, format);
-    virBufferVasprintf(buf, format, argptr);
-    va_end(argptr);
-}
-
-/**
- * virBufferVasprintf:
- * @buf: the buffer to append to
- * @format:  the format
- * @argptr:  the variable list of arguments
- *
- * Do a formatted print to an XML buffer.  Auto indentation may be applied.
- */
-void
-virBufferVasprintf(virBufferPtr buf, const char *format, va_list argptr)
-{
-    int size, count, grow_size;
-    va_list copy;
-
-    if ((format == NULL) || (buf == NULL))
-        return;
-
-    if (buf->error)
-        return;
-
-    virBufferAddLit(buf, ""); /* auto-indent */
-
-    if (buf->size == 0 &&
-        virBufferGrow(buf, 100) < 0)
-        return;
-
-    va_copy(copy, argptr);
-
-    size = buf->size - buf->use;
-    if ((count = vsnprintf(&buf->content[buf->use],
-                           size, format, copy)) < 0) {
-        virBufferSetError(buf, errno);
-        va_end(copy);
-        return;
-    }
-    va_end(copy);
-
-    /* Grow buffer if necessary and retry */
-    if (count >= size) {
-        buf->content[buf->use] = 0;
-
-        grow_size = (count + 1 > 1000) ? count + 1 : 1000;
-        if (virBufferGrow(buf, grow_size) < 0) {
-            return;
-        }
-
-        size = buf->size - buf->use;
-        if ((count = vsnprintf(&buf->content[buf->use],
-                               size, format, argptr)) < 0) {
-            virBufferSetError(buf, errno);
-            return;
-        }
-    }
-    buf->use += count;
-}
-
-/**
- * virBufferEscapeString:
- * @buf: the buffer to append to
- * @format: a printf like format string but with only one %s parameter
- * @str: the string argument which needs to be escaped
- *
- * Do a formatted print with a single string to an XML buffer. The
- * string is escaped for use in XML.  If @str is NULL, nothing is
- * added (not even the rest of @format).  Auto indentation may be
- * applied.
- */
-void
-virBufferEscapeString(virBufferPtr buf, const char *format, const char *str)
-{
-    int len;
-    char *escaped, *out;
-    const char *cur;
-
-    if ((format == NULL) || (buf == NULL) || (str == NULL))
-        return;
-
-    if (buf->error)
-        return;
-
-    len = strlen(str);
-    if (strcspn(str, "<>&'\"") == len) {
-        virBufferAsprintf(buf, format, str);
-        return;
-    }
-
-    if (xalloc_oversized(6, len) ||
-        VIR_ALLOC_N(escaped, 6 * len + 1) < 0) {
-        virBufferSetError(buf, errno);
-        return;
-    }
-
-    cur = str;
-    out = escaped;
-    while (*cur != 0) {
-        if (*cur == '<') {
-            *out++ = '&';
-            *out++ = 'l';
-            *out++ = 't';
-            *out++ = ';';
-        } else if (*cur == '>') {
-            *out++ = '&';
-            *out++ = 'g';
-            *out++ = 't';
-            *out++ = ';';
-        } else if (*cur == '&') {
-            *out++ = '&';
-            *out++ = 'a';
-            *out++ = 'm';
-            *out++ = 'p';
-            *out++ = ';';
-        } else if (*cur == '"') {
-            *out++ = '&';
-            *out++ = 'q';
-            *out++ = 'u';
-            *out++ = 'o';
-            *out++ = 't';
-            *out++ = ';';
-        } else if (*cur == '\'') {
-            *out++ = '&';
-            *out++ = 'a';
-            *out++ = 'p';
-            *out++ = 'o';
-            *out++ = 's';
-            *out++ = ';';
-        } else if (((unsigned char)*cur >= 0x20) || (*cur == '\n') || (*cur == '\t') ||
-                   (*cur == '\r')) {
-            /*
-             * default case, just copy !
-             * Note that character over 0x80 are likely to give problem
-             * with UTF-8 XML, but since our string don't have an encoding
-             * it's hard to handle properly we have to assume it's UTF-8 too
-             */
-            *out++ = *cur;
-        }
-        cur++;
-    }
-    *out = 0;
-
-    virBufferAsprintf(buf, format, escaped);
-    VIR_FREE(escaped);
-}
-
-/**
- * virBufferEscapeSexpr:
- * @buf: the buffer to append to
- * @format: a printf like format string but with only one %s parameter
- * @str: the string argument which needs to be escaped
- *
- * Do a formatted print with a single string to an sexpr buffer. The
- * string is escaped to avoid generating a sexpr that xen will choke
- * on. This doesn't fully escape the sexpr, just enough for our code
- * to work.  Auto indentation may be applied.
- */
-void
-virBufferEscapeSexpr(virBufferPtr buf,
-                     const char *format,
-                     const char *str)
-{
-    virBufferEscape(buf, '\\', "\\'", format, str);
-}
-
-/**
- * virBufferEscape:
- * @buf: the buffer to append to
- * @escape: the escape character to inject
- * @toescape: NUL-terminated list of characters to escape
- * @format: a printf like format string but with only one %s parameter
- * @str: the string argument which needs to be escaped
- *
- * Do a formatted print with a single string to a buffer.  Any characters
- * in the provided list are escaped with the given escape.  Auto indentation
- * may be applied.
- */
-void
-virBufferEscape(virBufferPtr buf, char escape, const char *toescape,
-                const char *format, const char *str)
-{
-    int len;
-    char *escaped, *out;
-    const char *cur;
-
-    if ((format == NULL) || (buf == NULL) || (str == NULL))
-        return;
-
-    if (buf->error)
-        return;
-
-    len = strlen(str);
-    if (strcspn(str, toescape) == len) {
-        virBufferAsprintf(buf, format, str);
-        return;
-    }
-
-    if (xalloc_oversized(2, len) ||
-        VIR_ALLOC_N(escaped, 2 * len + 1) < 0) {
-        virBufferSetError(buf, errno);
-        return;
-    }
-
-    cur = str;
-    out = escaped;
-    while (*cur != 0) {
-        /* strchr work-around for gcc 4.3 & 4.4 bug with -Wlogical-op
-         * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36513
-         */
-        char needle[2] = { *cur, 0 };
-        if (strstr(toescape, needle))
-            *out++ = escape;
-        *out++ = *cur;
-        cur++;
-    }
-    *out = 0;
-
-    virBufferAsprintf(buf, format, escaped);
-    VIR_FREE(escaped);
-}
-
-/**
- * virBufferURIEncodeString:
- * @buf: the buffer to append to
- * @str:  the string argument which will be URI-encoded
- *
- * Append the string to the buffer.  The string will be URI-encoded
- * during the append (ie any non alpha-numeric characters are replaced
- * with '%xx' hex sequences).  Auto indentation may be applied.
- */
-void
-virBufferURIEncodeString(virBufferPtr buf, const char *str)
-{
-    int grow_size = 0;
-    const char *p;
-    unsigned char uc;
-    const char *hex = "0123456789abcdef";
-
-    if ((buf == NULL) || (str == NULL))
-        return;
-
-    if (buf->error)
-        return;
-
-    virBufferAddLit(buf, ""); /* auto-indent */
-
-    for (p = str; *p; ++p) {
-        if (c_isalnum(*p))
-            grow_size++;
-        else
-            grow_size += 3; /* %ab */
-    }
-
-    if (virBufferGrow(buf, grow_size) < 0)
-        return;
-
-    for (p = str; *p; ++p) {
-        if (c_isalnum(*p))
-            buf->content[buf->use++] = *p;
-        else {
-            uc = (unsigned char) *p;
-            buf->content[buf->use++] = '%';
-            buf->content[buf->use++] = hex[uc >> 4];
-            buf->content[buf->use++] = hex[uc & 0xf];
-        }
-    }
-
-    buf->content[buf->use] = '\0';
-}
-
-/**
- * virBufferEscapeShell:
- * @buf: the buffer to append to
- * @str: an unquoted string
- *
- * Quotes a string so that the shell (/bin/sh) will interpret the
- * quoted string to mean str.  Auto indentation may be applied.
- */
-void
-virBufferEscapeShell(virBufferPtr buf, const char *str)
-{
-    int len;
-    char *escaped, *out;
-    const char *cur;
-
-    if ((buf == NULL) || (str == NULL))
-        return;
-
-    if (buf->error)
-        return;
-
-    /* Only quote if str includes shell metacharacters. */
-    if (*str && !strpbrk(str, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~")) {
-        virBufferAdd(buf, str, -1);
-        return;
-    }
-
-    if (*str) {
-        len = strlen(str);
-        if (xalloc_oversized(4, len) ||
-            VIR_ALLOC_N(escaped, 4 * len + 3) < 0) {
-            virBufferSetError(buf, errno);
-            return;
-        }
-    } else {
-        virBufferAddLit(buf, "''");
-        return;
-    }
-
-    cur = str;
-    out = escaped;
-
-    *out++ = '\'';
-    while (*cur != 0) {
-        if (*cur == '\'') {
-            *out++ = '\'';
-            /* Replace literal ' with a close ', a \', and a open ' */
-            *out++ = '\\';
-            *out++ = '\'';
-        }
-        *out++ = *cur++;
-    }
-    *out++ = '\'';
-    *out = 0;
-
-    virBufferAdd(buf, escaped, -1);
-    VIR_FREE(escaped);
-}
-
-/**
- * virBufferStrcat:
- * @buf: the buffer to append to
- * @...:  the variable list of strings, the last argument must be NULL
- *
- * Concatenate strings to an XML buffer.  Auto indentation may be applied
- * after each string argument.
- */
-void
-virBufferStrcat(virBufferPtr buf, ...)
-{
-    va_list ap;
-    char *str;
-
-    if (buf->error)
-        return;
-
-    va_start(ap, buf);
-    while ((str = va_arg(ap, char *)) != NULL)
-        virBufferAdd(buf, str, -1);
-    va_end(ap);
-}
-
-/**
- * virBufferTrim:
- * @buf: the buffer to trim
- * @str: the optional string, to force an exact trim
- * @len: the number of bytes to trim, or -1 to use @str
- *
- * Trim the tail of a buffer.  If @str is provided, the trim only occurs
- * if the current tail of the buffer matches @str; a non-negative @len
- * further limits how much of the tail is trimmed.  If @str is NULL, then
- * @len must be non-negative.
- *
- * Returns -1 if @buf has previously encountered an error or if @len is
- * invalid, 0 if there was nothing to trim (@buf was too short or @str
- * didn't match), and 1 if the trim was successful.
- */
-int
-virBufferTrim(virBufferPtr buf, const char *str, int len)
-{
-    size_t len2 = 0;
-
-    if (!buf || buf->error || (!str && len < 0))
-        return -1;
-
-    if (len > 0 && len > buf->use)
-        return 0;
-    if (str) {
-        len2 = strlen(str);
-        if (len2 > buf->use ||
-            memcmp(&buf->content[buf->use - len2], str, len2) != 0)
-            return 0;
-    }
-    buf->use -= len < 0 ? len2 : len;
-    buf->content[buf->use] = '\0';
-    return 1;
-}
diff --git a/src/util/buf.h b/src/util/buf.h
deleted file mode 100644
index c3a498d..0000000
--- a/src/util/buf.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * buf.h: buffers for libvirt
- *
- * Copyright (C) 2005-2008, 2011, 2012 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * Daniel Veillard <veillard@xxxxxxxxxx>
- */
-
-#ifndef __VIR_BUFFER_H__
-# define __VIR_BUFFER_H__
-
-# include "internal.h"
-
-# include <stdarg.h>
-
-/**
- * virBuffer:
- *
- * A buffer structure.
- */
-typedef struct _virBuffer virBuffer;
-typedef virBuffer *virBufferPtr;
-
-# ifndef __VIR_BUFFER_C__
-#  define VIR_BUFFER_INITIALIZER { 0, 0, 0, 0, NULL }
-
-/* This struct must be kept in sync with the real struct
-   in the buf.c impl file */
-struct _virBuffer {
-    unsigned int a;
-    unsigned int b;
-    unsigned int c;
-    int d;
-    char *e;
-};
-# endif
-
-const char *virBufferCurrentContent(virBufferPtr buf);
-char *virBufferContentAndReset(virBufferPtr buf);
-void virBufferFreeAndReset(virBufferPtr buf);
-int virBufferError(const virBufferPtr buf);
-unsigned int virBufferUse(const virBufferPtr buf);
-void virBufferAdd(virBufferPtr buf, const char *str, int len);
-void virBufferAddChar(virBufferPtr buf, char c);
-void virBufferAsprintf(virBufferPtr buf, const char *format, ...)
-  ATTRIBUTE_FMT_PRINTF(2, 3);
-void virBufferVasprintf(virBufferPtr buf, const char *format, va_list ap)
-  ATTRIBUTE_FMT_PRINTF(2, 0);
-void virBufferStrcat(virBufferPtr buf, ...)
-  ATTRIBUTE_SENTINEL;
-void virBufferEscape(virBufferPtr buf, char escape, const char *toescape,
-                     const char *format, const char *str);
-void virBufferEscapeString(virBufferPtr buf, const char *format,
-                           const char *str);
-void virBufferEscapeSexpr(virBufferPtr buf, const char *format,
-                          const char *str);
-void virBufferEscapeShell(virBufferPtr buf, const char *str);
-void virBufferURIEncodeString(virBufferPtr buf, const char *str);
-
-# define virBufferAddLit(buf_, literal_string_) \
-    virBufferAdd(buf_, "" literal_string_ "", sizeof(literal_string_) - 1)
-
-void virBufferAdjustIndent(virBufferPtr buf, int indent);
-int virBufferGetIndent(const virBufferPtr buf, bool dynamic);
-
-int virBufferTrim(virBufferPtr buf, const char *trim, int len);
-
-#endif /* __VIR_BUFFER_H__ */
diff --git a/src/util/command.c b/src/util/command.c
index ebdd636..fbd9ff8 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -41,7 +41,7 @@
 #include "virfile.h"
 #include "virpidfile.h"
 #include "virprocess.h"
-#include "buf.h"
+#include "virbuffer.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
diff --git a/src/util/command.h b/src/util/command.h
index 177a0eb..6c8ab49 100644
--- a/src/util/command.h
+++ b/src/util/command.h
@@ -24,7 +24,7 @@
 
 # include "internal.h"
 # include "util.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 typedef struct _virCommand virCommand;
 typedef virCommand *virCommandPtr;
diff --git a/src/util/conf.c b/src/util/conf.c
index ba80097..3b97545 100644
--- a/src/util/conf.c
+++ b/src/util/conf.c
@@ -31,7 +31,7 @@
 #include <fcntl.h>
 
 #include "virterror_internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "conf.h"
 #include "util.h"
 #include "c-ctype.h"
diff --git a/src/util/logging.c b/src/util/logging.c
index e8fed55..0df3549 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -44,7 +44,7 @@
 #include "logging.h"
 #include "memory.h"
 #include "util.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "threads.h"
 #include "virfile.h"
 #include "virtime.h"
diff --git a/src/util/logging.h b/src/util/logging.h
index 52feecc..028b791 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -23,7 +23,7 @@
 # define __VIRTLOG_H_
 
 # include "internal.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 /*
  * To be made public
diff --git a/src/util/sexpr.h b/src/util/sexpr.h
index b4b41ed..13ec481 100644
--- a/src/util/sexpr.h
+++ b/src/util/sexpr.h
@@ -13,7 +13,7 @@
 # define _LIBVIR_SEXPR_H_
 
 # include "internal.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 enum sexpr_type {
     SEXPR_NIL,
diff --git a/src/util/sysinfo.h b/src/util/sysinfo.h
index 40a100a..0b1f000 100644
--- a/src/util/sysinfo.h
+++ b/src/util/sysinfo.h
@@ -26,7 +26,7 @@
 
 # include "internal.h"
 # include "util.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 enum virSysinfoType {
     VIR_SYSINFO_SMBIOS,
diff --git a/src/util/util.c b/src/util/util.c
index 05e7ca7..422ee75 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -77,7 +77,7 @@
 #include "dirname.h"
 #include "virterror_internal.h"
 #include "logging.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "storage_file.h"
 #include "memory.h"
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 0f13389..41b74d4 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -32,7 +32,7 @@
 
 #include "virbitmap.h"
 #include "memory.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "c-ctype.h"
 #include "count-one-bits.h"
diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c
new file mode 100644
index 0000000..e4409c6
--- /dev/null
+++ b/src/util/virbuffer.c
@@ -0,0 +1,682 @@
+/*
+ * buf.c: buffers for libvirt
+ *
+ * Copyright (C) 2005-2008, 2010-2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Daniel Veillard <veillard@xxxxxxxxxx>
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include "c-ctype.h"
+
+#define __VIR_BUFFER_C__
+
+#include "virbuffer.h"
+#include "memory.h"
+
+
+/* If adding more fields, ensure to edit buf.h to match
+   the number of fields */
+struct _virBuffer {
+    unsigned int size;
+    unsigned int use;
+    unsigned int error; /* errno value, or -1 for usage error */
+    int indent;
+    char *content;
+};
+
+/**
+ * virBufferFail
+ * @buf: the buffer
+ * @error: which error occurred (errno value, or -1 for usage)
+ *
+ * Mark the buffer as failed, free the content and set the error flag.
+ */
+static void
+virBufferSetError(virBufferPtr buf, int error)
+{
+    VIR_FREE(buf->content);
+    buf->size = 0;
+    buf->use = 0;
+    buf->indent = 0;
+    buf->error = error;
+}
+
+/**
+ * virBufferAdjustIndent:
+ * @buf: the buffer
+ * @indent: adjustment to make
+ *
+ * Alter the auto-indent value by adding indent (positive to increase,
+ * negative to decrease).  Automatic indentation is performed by all
+ * additive functions when the existing buffer is empty or ends with a
+ * newline (however, note that no indentation is added after newlines
+ * embedded in an appended string).  If @indent would cause overflow,
+ * the buffer error indicator is set.
+ */
+void
+virBufferAdjustIndent(virBufferPtr buf, int indent)
+{
+    if (!buf || buf->error)
+        return;
+    if (indent > 0 ? INT_MAX - indent < buf->indent
+        : buf->indent < -indent) {
+        virBufferSetError(buf, -1);
+        return;
+    }
+    buf->indent += indent;
+}
+
+/**
+ * virBufferGetIndent:
+ * @buf: the buffer
+ * @dynamic: if false, return set value; if true, return 0 unless next
+ * append would be affected by auto-indent
+ *
+ * Return the current auto-indent value, or -1 if there has been an error.
+ */
+int
+virBufferGetIndent(const virBufferPtr buf, bool dynamic)
+{
+    if (!buf || buf->error)
+        return -1;
+    if (dynamic && buf->use && buf->content[buf->use - 1] != '\n')
+        return 0;
+    return buf->indent;
+}
+
+/**
+ * virBufferGrow:
+ * @buf:  the buffer
+ * @len:  the minimum free size to allocate on top of existing used space
+ *
+ * Grow the available space of a buffer to at least @len bytes.
+ *
+ * Returns zero on success or -1 on error
+ */
+static int
+virBufferGrow(virBufferPtr buf, unsigned int len)
+{
+    int size;
+
+    if (buf->error)
+        return -1;
+
+    if ((len + buf->use) < buf->size)
+        return 0;
+
+    size = buf->use + len + 1000;
+
+    if (VIR_REALLOC_N(buf->content, size) < 0) {
+        virBufferSetError(buf, errno);
+        return -1;
+    }
+    buf->size = size;
+    return 0;
+}
+
+/**
+ * virBufferAdd:
+ * @buf: the buffer to append to
+ * @str: the string
+ * @len: the number of bytes to add, or -1
+ *
+ * Add a string range to an XML buffer. If @len == -1, the length of
+ * str is recomputed to the full string.  Auto indentation may be applied.
+ *
+ */
+void
+virBufferAdd(virBufferPtr buf, const char *str, int len)
+{
+    unsigned int needSize;
+    int indent;
+
+    if (!str || !buf || (len == 0 && buf->indent == 0))
+        return;
+
+    if (buf->error)
+        return;
+
+    indent = virBufferGetIndent(buf, true);
+
+    if (len < 0)
+        len = strlen(str);
+
+    needSize = buf->use + indent + len + 2;
+    if (needSize > buf->size &&
+        virBufferGrow(buf, needSize - buf->use) < 0)
+        return;
+
+    memset(&buf->content[buf->use], ' ', indent);
+    memcpy(&buf->content[buf->use + indent], str, len);
+    buf->use += indent + len;
+    buf->content[buf->use] = '\0';
+}
+
+/**
+ * virBufferAddChar:
+ * @buf: the buffer to append to
+ * @c: the character to add
+ *
+ * Add a single character 'c' to a buffer.  Auto indentation may be applied.
+ *
+ */
+void
+virBufferAddChar(virBufferPtr buf, char c)
+{
+    virBufferAdd(buf, &c, 1);
+}
+
+/**
+ * virBufferCurrentContent:
+ * @buf: Buffer
+ *
+ * Get the current content from the buffer.  The content is only valid
+ * until the next operation on @buf, and an empty string is returned if
+ * no content is present yet.
+ *
+ * Returns the buffer content or NULL in case of error.
+ */
+const char *
+virBufferCurrentContent(virBufferPtr buf)
+{
+    if (!buf || buf->error)
+        return NULL;
+    return buf->use ? buf->content : "";
+}
+
+/**
+ * virBufferContentAndReset:
+ * @buf: Buffer
+ *
+ * Get the content from the buffer and free (only) the buffer structure.
+ * The caller owns the returned string & should free it when no longer
+ * required. The buffer object is reset to its initial state.  This
+ * interface intentionally returns NULL instead of an empty string if
+ * there is no content.
+ *
+ * Returns the buffer content or NULL in case of error.
+ */
+char *
+virBufferContentAndReset(virBufferPtr buf)
+{
+    char *str;
+    if (buf == NULL)
+        return NULL;
+
+    if (buf->error) {
+        memset(buf, 0, sizeof(*buf));
+        return NULL;
+    }
+
+    str = buf->content;
+    memset(buf, 0, sizeof(*buf));
+    return str;
+}
+
+/**
+ * virBufferFreeAndReset:
+ * @buf: the buffer to free and reset
+ *
+ * Frees the buffer content and resets the buffer structure.
+ */
+void virBufferFreeAndReset(virBufferPtr buf)
+{
+    char *str = virBufferContentAndReset(buf);
+
+    VIR_FREE(str);
+}
+
+/**
+ * virBufferError:
+ * @buf: the buffer
+ *
+ * Check to see if the buffer is in an error state due
+ * to failed memory allocation or usage error
+ *
+ * Return positive errno value or -1 on usage error, 0 if normal
+ */
+int
+virBufferError(const virBufferPtr buf)
+{
+    if (buf == NULL)
+        return -1;
+
+    return buf->error;
+}
+
+/**
+ * virBufferUse:
+ * @buf: the usage of the string in the buffer
+ *
+ * Return the string usage in bytes
+ */
+unsigned int
+virBufferUse(const virBufferPtr buf)
+{
+    if (buf == NULL)
+        return 0;
+
+    return buf->use;
+}
+
+/**
+ * virBufferAsprintf:
+ * @buf: the buffer to append to
+ * @format:  the format
+ * @...:  the variable list of arguments
+ *
+ * Do a formatted print to an XML buffer.  Auto indentation may be applied.
+ */
+void
+virBufferAsprintf(virBufferPtr buf, const char *format, ...)
+{
+    va_list argptr;
+    va_start(argptr, format);
+    virBufferVasprintf(buf, format, argptr);
+    va_end(argptr);
+}
+
+/**
+ * virBufferVasprintf:
+ * @buf: the buffer to append to
+ * @format:  the format
+ * @argptr:  the variable list of arguments
+ *
+ * Do a formatted print to an XML buffer.  Auto indentation may be applied.
+ */
+void
+virBufferVasprintf(virBufferPtr buf, const char *format, va_list argptr)
+{
+    int size, count, grow_size;
+    va_list copy;
+
+    if ((format == NULL) || (buf == NULL))
+        return;
+
+    if (buf->error)
+        return;
+
+    virBufferAddLit(buf, ""); /* auto-indent */
+
+    if (buf->size == 0 &&
+        virBufferGrow(buf, 100) < 0)
+        return;
+
+    va_copy(copy, argptr);
+
+    size = buf->size - buf->use;
+    if ((count = vsnprintf(&buf->content[buf->use],
+                           size, format, copy)) < 0) {
+        virBufferSetError(buf, errno);
+        va_end(copy);
+        return;
+    }
+    va_end(copy);
+
+    /* Grow buffer if necessary and retry */
+    if (count >= size) {
+        buf->content[buf->use] = 0;
+
+        grow_size = (count + 1 > 1000) ? count + 1 : 1000;
+        if (virBufferGrow(buf, grow_size) < 0) {
+            return;
+        }
+
+        size = buf->size - buf->use;
+        if ((count = vsnprintf(&buf->content[buf->use],
+                               size, format, argptr)) < 0) {
+            virBufferSetError(buf, errno);
+            return;
+        }
+    }
+    buf->use += count;
+}
+
+/**
+ * virBufferEscapeString:
+ * @buf: the buffer to append to
+ * @format: a printf like format string but with only one %s parameter
+ * @str: the string argument which needs to be escaped
+ *
+ * Do a formatted print with a single string to an XML buffer. The
+ * string is escaped for use in XML.  If @str is NULL, nothing is
+ * added (not even the rest of @format).  Auto indentation may be
+ * applied.
+ */
+void
+virBufferEscapeString(virBufferPtr buf, const char *format, const char *str)
+{
+    int len;
+    char *escaped, *out;
+    const char *cur;
+
+    if ((format == NULL) || (buf == NULL) || (str == NULL))
+        return;
+
+    if (buf->error)
+        return;
+
+    len = strlen(str);
+    if (strcspn(str, "<>&'\"") == len) {
+        virBufferAsprintf(buf, format, str);
+        return;
+    }
+
+    if (xalloc_oversized(6, len) ||
+        VIR_ALLOC_N(escaped, 6 * len + 1) < 0) {
+        virBufferSetError(buf, errno);
+        return;
+    }
+
+    cur = str;
+    out = escaped;
+    while (*cur != 0) {
+        if (*cur == '<') {
+            *out++ = '&';
+            *out++ = 'l';
+            *out++ = 't';
+            *out++ = ';';
+        } else if (*cur == '>') {
+            *out++ = '&';
+            *out++ = 'g';
+            *out++ = 't';
+            *out++ = ';';
+        } else if (*cur == '&') {
+            *out++ = '&';
+            *out++ = 'a';
+            *out++ = 'm';
+            *out++ = 'p';
+            *out++ = ';';
+        } else if (*cur == '"') {
+            *out++ = '&';
+            *out++ = 'q';
+            *out++ = 'u';
+            *out++ = 'o';
+            *out++ = 't';
+            *out++ = ';';
+        } else if (*cur == '\'') {
+            *out++ = '&';
+            *out++ = 'a';
+            *out++ = 'p';
+            *out++ = 'o';
+            *out++ = 's';
+            *out++ = ';';
+        } else if (((unsigned char)*cur >= 0x20) || (*cur == '\n') || (*cur == '\t') ||
+                   (*cur == '\r')) {
+            /*
+             * default case, just copy !
+             * Note that character over 0x80 are likely to give problem
+             * with UTF-8 XML, but since our string don't have an encoding
+             * it's hard to handle properly we have to assume it's UTF-8 too
+             */
+            *out++ = *cur;
+        }
+        cur++;
+    }
+    *out = 0;
+
+    virBufferAsprintf(buf, format, escaped);
+    VIR_FREE(escaped);
+}
+
+/**
+ * virBufferEscapeSexpr:
+ * @buf: the buffer to append to
+ * @format: a printf like format string but with only one %s parameter
+ * @str: the string argument which needs to be escaped
+ *
+ * Do a formatted print with a single string to an sexpr buffer. The
+ * string is escaped to avoid generating a sexpr that xen will choke
+ * on. This doesn't fully escape the sexpr, just enough for our code
+ * to work.  Auto indentation may be applied.
+ */
+void
+virBufferEscapeSexpr(virBufferPtr buf,
+                     const char *format,
+                     const char *str)
+{
+    virBufferEscape(buf, '\\', "\\'", format, str);
+}
+
+/**
+ * virBufferEscape:
+ * @buf: the buffer to append to
+ * @escape: the escape character to inject
+ * @toescape: NUL-terminated list of characters to escape
+ * @format: a printf like format string but with only one %s parameter
+ * @str: the string argument which needs to be escaped
+ *
+ * Do a formatted print with a single string to a buffer.  Any characters
+ * in the provided list are escaped with the given escape.  Auto indentation
+ * may be applied.
+ */
+void
+virBufferEscape(virBufferPtr buf, char escape, const char *toescape,
+                const char *format, const char *str)
+{
+    int len;
+    char *escaped, *out;
+    const char *cur;
+
+    if ((format == NULL) || (buf == NULL) || (str == NULL))
+        return;
+
+    if (buf->error)
+        return;
+
+    len = strlen(str);
+    if (strcspn(str, toescape) == len) {
+        virBufferAsprintf(buf, format, str);
+        return;
+    }
+
+    if (xalloc_oversized(2, len) ||
+        VIR_ALLOC_N(escaped, 2 * len + 1) < 0) {
+        virBufferSetError(buf, errno);
+        return;
+    }
+
+    cur = str;
+    out = escaped;
+    while (*cur != 0) {
+        /* strchr work-around for gcc 4.3 & 4.4 bug with -Wlogical-op
+         * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36513
+         */
+        char needle[2] = { *cur, 0 };
+        if (strstr(toescape, needle))
+            *out++ = escape;
+        *out++ = *cur;
+        cur++;
+    }
+    *out = 0;
+
+    virBufferAsprintf(buf, format, escaped);
+    VIR_FREE(escaped);
+}
+
+/**
+ * virBufferURIEncodeString:
+ * @buf: the buffer to append to
+ * @str:  the string argument which will be URI-encoded
+ *
+ * Append the string to the buffer.  The string will be URI-encoded
+ * during the append (ie any non alpha-numeric characters are replaced
+ * with '%xx' hex sequences).  Auto indentation may be applied.
+ */
+void
+virBufferURIEncodeString(virBufferPtr buf, const char *str)
+{
+    int grow_size = 0;
+    const char *p;
+    unsigned char uc;
+    const char *hex = "0123456789abcdef";
+
+    if ((buf == NULL) || (str == NULL))
+        return;
+
+    if (buf->error)
+        return;
+
+    virBufferAddLit(buf, ""); /* auto-indent */
+
+    for (p = str; *p; ++p) {
+        if (c_isalnum(*p))
+            grow_size++;
+        else
+            grow_size += 3; /* %ab */
+    }
+
+    if (virBufferGrow(buf, grow_size) < 0)
+        return;
+
+    for (p = str; *p; ++p) {
+        if (c_isalnum(*p))
+            buf->content[buf->use++] = *p;
+        else {
+            uc = (unsigned char) *p;
+            buf->content[buf->use++] = '%';
+            buf->content[buf->use++] = hex[uc >> 4];
+            buf->content[buf->use++] = hex[uc & 0xf];
+        }
+    }
+
+    buf->content[buf->use] = '\0';
+}
+
+/**
+ * virBufferEscapeShell:
+ * @buf: the buffer to append to
+ * @str: an unquoted string
+ *
+ * Quotes a string so that the shell (/bin/sh) will interpret the
+ * quoted string to mean str.  Auto indentation may be applied.
+ */
+void
+virBufferEscapeShell(virBufferPtr buf, const char *str)
+{
+    int len;
+    char *escaped, *out;
+    const char *cur;
+
+    if ((buf == NULL) || (str == NULL))
+        return;
+
+    if (buf->error)
+        return;
+
+    /* Only quote if str includes shell metacharacters. */
+    if (*str && !strpbrk(str, "\r\t\n !\"#$&'()*;<>?[\\]^`{|}~")) {
+        virBufferAdd(buf, str, -1);
+        return;
+    }
+
+    if (*str) {
+        len = strlen(str);
+        if (xalloc_oversized(4, len) ||
+            VIR_ALLOC_N(escaped, 4 * len + 3) < 0) {
+            virBufferSetError(buf, errno);
+            return;
+        }
+    } else {
+        virBufferAddLit(buf, "''");
+        return;
+    }
+
+    cur = str;
+    out = escaped;
+
+    *out++ = '\'';
+    while (*cur != 0) {
+        if (*cur == '\'') {
+            *out++ = '\'';
+            /* Replace literal ' with a close ', a \', and a open ' */
+            *out++ = '\\';
+            *out++ = '\'';
+        }
+        *out++ = *cur++;
+    }
+    *out++ = '\'';
+    *out = 0;
+
+    virBufferAdd(buf, escaped, -1);
+    VIR_FREE(escaped);
+}
+
+/**
+ * virBufferStrcat:
+ * @buf: the buffer to append to
+ * @...:  the variable list of strings, the last argument must be NULL
+ *
+ * Concatenate strings to an XML buffer.  Auto indentation may be applied
+ * after each string argument.
+ */
+void
+virBufferStrcat(virBufferPtr buf, ...)
+{
+    va_list ap;
+    char *str;
+
+    if (buf->error)
+        return;
+
+    va_start(ap, buf);
+    while ((str = va_arg(ap, char *)) != NULL)
+        virBufferAdd(buf, str, -1);
+    va_end(ap);
+}
+
+/**
+ * virBufferTrim:
+ * @buf: the buffer to trim
+ * @str: the optional string, to force an exact trim
+ * @len: the number of bytes to trim, or -1 to use @str
+ *
+ * Trim the tail of a buffer.  If @str is provided, the trim only occurs
+ * if the current tail of the buffer matches @str; a non-negative @len
+ * further limits how much of the tail is trimmed.  If @str is NULL, then
+ * @len must be non-negative.
+ *
+ * Returns -1 if @buf has previously encountered an error or if @len is
+ * invalid, 0 if there was nothing to trim (@buf was too short or @str
+ * didn't match), and 1 if the trim was successful.
+ */
+int
+virBufferTrim(virBufferPtr buf, const char *str, int len)
+{
+    size_t len2 = 0;
+
+    if (!buf || buf->error || (!str && len < 0))
+        return -1;
+
+    if (len > 0 && len > buf->use)
+        return 0;
+    if (str) {
+        len2 = strlen(str);
+        if (len2 > buf->use ||
+            memcmp(&buf->content[buf->use - len2], str, len2) != 0)
+            return 0;
+    }
+    buf->use -= len < 0 ? len2 : len;
+    buf->content[buf->use] = '\0';
+    return 1;
+}
diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h
new file mode 100644
index 0000000..c3a498d
--- /dev/null
+++ b/src/util/virbuffer.h
@@ -0,0 +1,82 @@
+/*
+ * buf.h: buffers for libvirt
+ *
+ * Copyright (C) 2005-2008, 2011, 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Daniel Veillard <veillard@xxxxxxxxxx>
+ */
+
+#ifndef __VIR_BUFFER_H__
+# define __VIR_BUFFER_H__
+
+# include "internal.h"
+
+# include <stdarg.h>
+
+/**
+ * virBuffer:
+ *
+ * A buffer structure.
+ */
+typedef struct _virBuffer virBuffer;
+typedef virBuffer *virBufferPtr;
+
+# ifndef __VIR_BUFFER_C__
+#  define VIR_BUFFER_INITIALIZER { 0, 0, 0, 0, NULL }
+
+/* This struct must be kept in sync with the real struct
+   in the buf.c impl file */
+struct _virBuffer {
+    unsigned int a;
+    unsigned int b;
+    unsigned int c;
+    int d;
+    char *e;
+};
+# endif
+
+const char *virBufferCurrentContent(virBufferPtr buf);
+char *virBufferContentAndReset(virBufferPtr buf);
+void virBufferFreeAndReset(virBufferPtr buf);
+int virBufferError(const virBufferPtr buf);
+unsigned int virBufferUse(const virBufferPtr buf);
+void virBufferAdd(virBufferPtr buf, const char *str, int len);
+void virBufferAddChar(virBufferPtr buf, char c);
+void virBufferAsprintf(virBufferPtr buf, const char *format, ...)
+  ATTRIBUTE_FMT_PRINTF(2, 3);
+void virBufferVasprintf(virBufferPtr buf, const char *format, va_list ap)
+  ATTRIBUTE_FMT_PRINTF(2, 0);
+void virBufferStrcat(virBufferPtr buf, ...)
+  ATTRIBUTE_SENTINEL;
+void virBufferEscape(virBufferPtr buf, char escape, const char *toescape,
+                     const char *format, const char *str);
+void virBufferEscapeString(virBufferPtr buf, const char *format,
+                           const char *str);
+void virBufferEscapeSexpr(virBufferPtr buf, const char *format,
+                          const char *str);
+void virBufferEscapeShell(virBufferPtr buf, const char *str);
+void virBufferURIEncodeString(virBufferPtr buf, const char *str);
+
+# define virBufferAddLit(buf_, literal_string_) \
+    virBufferAdd(buf_, "" literal_string_ "", sizeof(literal_string_) - 1)
+
+void virBufferAdjustIndent(virBufferPtr buf, int indent);
+int virBufferGetIndent(const virBufferPtr buf, bool dynamic);
+
+int virBufferTrim(virBufferPtr buf, const char *trim, int len);
+
+#endif /* __VIR_BUFFER_H__ */
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 1917e9a..228c3fb 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -23,7 +23,7 @@
 
 #include "virstring.h"
 #include "memory.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "virterror_internal.h"
 
 #define VIR_FROM_THIS VIR_FROM_NONE
diff --git a/src/util/viruri.c b/src/util/viruri.c
index 26dbf24..dd3b878 100644
--- a/src/util/viruri.c
+++ b/src/util/viruri.c
@@ -25,7 +25,7 @@
 #include "memory.h"
 #include "util.h"
 #include "virterror_internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 
 #define VIR_FROM_THIS VIR_FROM_URI
 
diff --git a/src/util/xml.c b/src/util/xml.c
index 84db865..5b08b1f 100644
--- a/src/util/xml.c
+++ b/src/util/xml.c
@@ -32,7 +32,7 @@
 
 #include "virterror_internal.h"
 #include "xml.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "util.h"
 #include "memory.h"
 #include "virfile.h"
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 237a6ab..1aa2b73 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -74,7 +74,7 @@
 #include "stats_linux.h"
 #include "block_stats.h"
 #include "xend_internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "capabilities.h"
 #include "memory.h"
 #include "threads.h"
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 922c571..9407e95 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -37,7 +37,7 @@
 #include "util.h"
 #include "sexpr.h"
 #include "xen_sxpr.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "uuid.h"
 #include "xen_driver.h"
 #include "xen_hypervisor.h"
diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h
index 5942788..06c75e1 100644
--- a/src/xen/xend_internal.h
+++ b/src/xen/xend_internal.h
@@ -23,7 +23,7 @@
 # include "capabilities.h"
 # include "domain_conf.h"
 # include "driver.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "viruri.h"
 
 int
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 9da2974..2cd4b95 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -43,7 +43,7 @@
 #include "xen_sxpr.h"
 #include "xen_xm.h"
 #include "virhash.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "uuid.h"
 #include "util.h"
 #include "memory.h"
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 5a93aea..f00dcfd 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -34,7 +34,7 @@
 #include "util.h"
 #include "uuid.h"
 #include "memory.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "viruri.h"
 #include "xenapi_driver.h"
 #include "xenapi_driver_private.h"
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 8c906f4..dbdb22d 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -32,7 +32,7 @@
 #include "util.h"
 #include "uuid.h"
 #include "memory.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "logging.h"
 #include "viruri.h"
 #include "xenapi_driver_private.h"
diff --git a/tests/cputest.c b/tests/cputest.c
index 3cdc769..f6110c1 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -33,7 +33,7 @@
 #include "internal.h"
 #include "xml.h"
 #include "memory.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "testutils.h"
 #include "cpu_conf.h"
 #include "cpu/cpu.h"
diff --git a/tests/testutils.c b/tests/testutils.c
index 3d2e491..e8b48e8 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -43,7 +43,7 @@
 #include "util.h"
 #include "threads.h"
 #include "virterror_internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "logging.h"
 #include "command.h"
 #include "virrandom.h"
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index 35ba997..53b9bbe 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -7,7 +7,7 @@
 #include "internal.h"
 #include "util.h"
 #include "testutils.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 
 #define TEST_ERROR(...)                             \
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 765f30c..76d9d51 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -38,7 +38,7 @@
 
 #include "internal.h"
 #include "virbitmap.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "c-ctype.h"
 #include "conf/domain_conf.h"
 #include "console.h"
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 3d13e01..f687780 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -32,7 +32,7 @@
 #include <libxml/xmlsave.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "virsh-domain.h"
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 3a6285b..956fee8 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -32,7 +32,7 @@
 #include <libxml/xmlsave.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "xml.h"
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index fd9d563..c5d494a 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -32,7 +32,7 @@
 #include <libxml/xmlsave.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "xml.h"
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 8cf96be..52cd874 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -32,7 +32,7 @@
 #include <libxml/xmlsave.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "xml.h"
diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c
index 5e79191..3108d1b 100644
--- a/tools/virsh-nwfilter.c
+++ b/tools/virsh-nwfilter.c
@@ -32,7 +32,7 @@
 #include <libxml/xmlsave.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "xml.h"
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 5fee2cd..4a78467 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -32,7 +32,7 @@
 #include <libxml/xmlsave.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "xml.h"
diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c
index 52879e1..ee79b97 100644
--- a/tools/virsh-secret.c
+++ b/tools/virsh-secret.c
@@ -33,7 +33,7 @@
 
 #include "internal.h"
 #include "base64.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "xml.h"
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index 8ec6456..d6a381d 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -34,7 +34,7 @@
 #include <libxml/xmlsave.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "virsh-domain.h"
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 21a2df0..1bad6b1 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -34,7 +34,7 @@
 #include <libxml/xmlsave.h>
 
 #include "internal.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "util.h"
 #include "virfile.h"
diff --git a/tools/virsh.c b/tools/virsh.c
index 2f7d4a3..82c03e4 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -56,7 +56,7 @@
 #include "internal.h"
 #include "virterror_internal.h"
 #include "base64.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "console.h"
 #include "util.h"
 #include "memory.h"
-- 
1.7.11.7

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]