]> xenbits.xensource.com Git - libvirt.git/commitdiff
Rename buf.{c,h} to virbuffer.{c,h}
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 4 Dec 2012 12:04:07 +0000 (12:04 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 21 Dec 2012 11:17:12 +0000 (11:17 +0000)
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
83 files changed:
src/Makefile.am
src/conf/capabilities.c
src/conf/capabilities.h
src/conf/cpu_conf.c
src/conf/cpu_conf.h
src/conf/device_conf.c
src/conf/device_conf.h
src/conf/domain_conf.c
src/conf/interface_conf.c
src/conf/netdev_bandwidth_conf.h
src/conf/netdev_vlan_conf.h
src/conf/netdev_vport_profile_conf.h
src/conf/network_conf.c
src/conf/node_device_conf.c
src/conf/nwfilter_conf.h
src/conf/nwfilter_params.h
src/conf/secret_conf.c
src/conf/snapshot_conf.c
src/conf/storage_conf.c
src/conf/storage_encryption_conf.c
src/conf/storage_encryption_conf.h
src/cpu/cpu_powerpc.c
src/cpu/cpu_x86.c
src/esx/esx_vi.c
src/esx/esx_vi_methods.c
src/esx/esx_vi_types.c
src/esx/esx_vi_types.h
src/hyperv/hyperv_wmi.c
src/hyperv/hyperv_wmi.h
src/lxc/lxc_fuse.c
src/network/bridge_driver.c
src/node_device/node_device_udev.c
src/nwfilter/nwfilter_ebiptables_driver.c
src/nwfilter/nwfilter_learnipaddr.c
src/openvz/openvz_conf.c
src/openvz/openvz_driver.c
src/phyp/phyp_driver.c
src/qemu/qemu_conf.c
src/qemu/qemu_driver.c
src/qemu/qemu_monitor_text.c
src/remote/remote_driver.c
src/rpc/virnetsshsession.c
src/security/virt-aa-helper.c
src/test/test_driver.c
src/uml/uml_conf.c
src/uml/uml_driver.c
src/util/buf.c [deleted file]
src/util/buf.h [deleted file]
src/util/command.c
src/util/command.h
src/util/conf.c
src/util/logging.c
src/util/logging.h
src/util/sexpr.h
src/util/sysinfo.h
src/util/util.c
src/util/virbitmap.c
src/util/virbuffer.c [new file with mode: 0644]
src/util/virbuffer.h [new file with mode: 0644]
src/util/virstring.c
src/util/viruri.c
src/util/xml.c
src/xen/xen_hypervisor.c
src/xen/xend_internal.c
src/xen/xend_internal.h
src/xen/xm_internal.c
src/xenapi/xenapi_driver.c
src/xenapi/xenapi_utils.c
tests/cputest.c
tests/sysinfotest.c
tests/testutils.c
tests/virbuftest.c
tools/virsh-domain.c
tools/virsh-host.c
tools/virsh-interface.c
tools/virsh-network.c
tools/virsh-nodedev.c
tools/virsh-nwfilter.c
tools/virsh-pool.c
tools/virsh-secret.c
tools/virsh-snapshot.c
tools/virsh-volume.c
tools/virsh.c

index a6cab5857ff7939d68c0b97b348d3d1eb2bd847e..dfda3e79e789bfca0f6dd9fb24ab60d75b9608ee 100644 (file)
@@ -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                       \
@@ -84,6 +83,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               \
index 7cdb5b73e1a05e56b846f0577842354c6ea68c49..76db89a65bac95d08b8378329b886bffc9288500 100644 (file)
@@ -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"
index 3cdbcaae90419e4b6eb4c9b90cb7cee44f2c6822..19b99c66951eb60cb80391820578cee95c6ccf30 100644 (file)
@@ -25,7 +25,7 @@
 # define __VIR_CAPABILITIES_H
 
 # include "internal.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "cpu_conf.h"
 # include "virarch.h"
 # include "virmacaddr.h"
index 3973c8319e8e95ae43bc44a7350013ec28c78438..9b865712643e9ff5bcc67603d87ad5a4c1126e2e 100644 (file)
@@ -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"
 
index bd6dfd96f694a235d901cabfb62024ad974c0170..368c26ba7dfd8e88f60c8579a057cc340f926bb1 100644 (file)
@@ -25,7 +25,7 @@
 # define __VIR_CPU_CONF_H__
 
 # include "util.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "xml.h"
 # include "virbitmap.h"
 # include "virarch.h"
index 7b97f455877d75ea99c0b8ad0853ef39e5784fbb..daf57bc380f8fd35d3f88f5c4c223be2a64be0ca 100644 (file)
@@ -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
index 5318738a1b8157a3848d84adfe818a8134aa7ef3..09d6be976ffbd4ad54558ad3bd171cc7db2aa172 100644 (file)
@@ -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,
index f33d49178aad94bb388a8177fb6a1b8bed4ba4e9..51327bf331cb59b5893104389987aed255ae5f6e 100644 (file)
@@ -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"
index fc3602a36cfc92f8201ce2fb0b4295a9c6ae15c3..738ef336ae32b15fc8fca868187ec9a31994e135 100644 (file)
@@ -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
 
index 00801652329e9ae986442b3a5205d379cdac41ad..216a540c6da6f5c3b624368a1de91e48418879e7 100644 (file)
@@ -25,7 +25,7 @@
 
 # include "internal.h"
 # include "virnetdevbandwidth.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "xml.h"
 
 virNetDevBandwidthPtr virNetDevBandwidthParse(xmlNodePtr node,
index 81b0d8497576b2db4938479a0fd8c2f73b3c2ef3..19b50ccdbccfe4acbd5262e0f7e1a5373755b24c 100644 (file)
@@ -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);
index d6d58ef7fe25ce13879ebddcfb91b06e8db8d307..15ecbd68650daeb453745e2050871587a1d11937 100644 (file)
@@ -25,7 +25,7 @@
 
 # include "internal.h"
 # include "virnetdevvportprofile.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "xml.h"
 
 typedef enum {
index ff7366d11443e285f95f99fa09dc9ac6443019f7..42cb87e4004060db56ade3f1d36d8815efe15c1a 100644 (file)
@@ -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"
 
index 41fa8e45b7c0dc015d36f2372f389a9708c82262..50fcf0b59dadd6412671db9f7d5127ff44fb512e 100644 (file)
@@ -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"
index 805fbe7453acbd7281607f525828a89310415f49..d5970644149aa8eba178a5a6da445711f3026926 100644 (file)
@@ -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"
 
index 6c3ce54352193cc212b696481b3c1f8b4231af33..ac57796aea835e8eaffc7980d22b2ad8545ae62b 100644 (file)
@@ -24,7 +24,7 @@
 # define NWFILTER_PARAMS_H
 
 # include "virhash.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "virmacaddr.h"
 
 enum virNWFilterVarValueType {
index a6b4934089cc06cb449eafbb01c972ecec106834..ec67f57a7b08aa03ef536cb9bc254c56dd1c7527 100644 (file)
@@ -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"
index 95b7943d95054d6feea94f021d303f120321dbfe..38a3e2a36ad900049958e5a64b6a22183190af9e 100644 (file)
@@ -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"
index ad0f0c108f681eca8840b25c3d1deeedf978ced9..b81c08cf974a8bbf30f566a166983d72d8cda8f4 100644 (file)
@@ -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"
index a8b1397e123d2d03f225cea19b99fbe2769d536d..0c2bded1e5f5e4a79d736e25f0f6a625b75b8c7c 100644 (file)
@@ -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"
index e06347847005af1dd78cd4634e2b9e90eff70fe7..40a84973c4274ded5c43402ad36fdcf6e766ec84 100644 (file)
@@ -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>
index ac107892b51d61702b9c37f0ea176b082b82094e..36d601e952afe502c6777073ceaecef2a21bd932 100644 (file)
@@ -32,7 +32,7 @@
 #include "cpu.h"
 
 #include "cpu_map.h"
-#include "buf.h"
+#include "virbuffer.h"
 
 #define VIR_FROM_THIS VIR_FROM_CPU
 
index cb2191025957be23c36ee0fec1e4002001e95ad9..144714155767362912d1644ac127948ea2ef5e04 100644 (file)
@@ -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
index 564b35cfd6ab35f7d8c314d9f718df855ee647e0..d645bfbdcd31443064f3f80d3ac1fc392ef9adf8 100644 (file)
@@ -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"
index 0f9d612ca4bd3bb28a49a556ec6ff260140b7a92..a3c3c8b9784b67211231daa8ac07fbe2ea3e8065 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <config.h>
 
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "logging.h"
 #include "uuid.h"
index 01467285fc9bb59da96f1aaeba1b6d6b5b392a0d..1654e1b1731ab24c4dce0b39c33fd03c5f333c82 100644 (file)
@@ -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"
index a250bf820efd002834e8aaf928920ecf39ec721a..92dc16f73ae493d033d33b70a65bb2eea343a91f 100644 (file)
@@ -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;
index 4023588b3204e0934fdadb1ae15661db1f4c2c51..0a6b1077780069b350cb3b9e8791cb378576af58 100644 (file)
@@ -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"
 
index d9e8578833f8bb2cdb29b1eeccb0eb19415876ef..85a2bbc6fff8ddf9bf183862a87ccc602d9d80f4 100644 (file)
@@ -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"
index e0c51aa1745ee6321bded19d9574d076702247da..4e7df552eaca3fdb7a358d90feca3dcd0ec4b685 100644 (file)
@@ -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
 
index 9740fbd14321540ddbbe8256c863ba77db72073b..48c047e7c9cae37cebde63f570174e11f5557214 100644 (file)
@@ -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"
index c9ca00c9f1344e45902b5a2a0088a2893e24cdc9..b3499fb3049079feea127e726b100f183663a536 100644 (file)
@@ -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
index cdf0efce54266ae2c9073765910359e950bbe5d4..5cfc0367249f2f3895c4ebffa3e583263588adb9 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "internal.h"
 
-#include "buf.h"
+#include "virbuffer.h"
 #include "memory.h"
 #include "logging.h"
 #include "virterror_internal.h"
index 85e0e7e9bda2a9060b9f64e0cededa80d3d864ec..361bdce3b234fd48529340be92e5bfc5ec915d71 100644 (file)
@@ -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"
index 089f63b5c724df3ea8da70911a9833182492ffc5..30fd2e3e86ced24f91fd6ef062ffc93d329473f1 100644 (file)
@@ -46,7 +46,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"
index fd6ecf8aa13c95be56445b4a5203447354bf1c07..1e97448388d9f018e9b0b70e85be412f06d9e549 100644 (file)
@@ -48,7 +48,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"
index c82acb61473df057bf2ba5cef68fe3321e003d70..e81bc090fa9a629525df5ffaf85a17a049725512 100644 (file)
@@ -46,7 +46,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"
index d890ff15327446ecc59787fe82f198947a662b84..a796aa9cbd1ea5aa56bcabac3598eac162bfcb2a 100644 (file)
@@ -40,7 +40,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"
index 7e8a1d8ef5a5deb48ce7adc44da553354840ae48..8c1fa6090495e54e5e05c275f72472f96f68e543 100644 (file)
@@ -61,7 +61,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"
index fa106005de9d6a73fe94aa7ef7b4cf54d3dd490a..a12adb65c6fc7beea9d54973279b86b750ce9c88 100644 (file)
@@ -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"
index 5cc7e32e42f06c4fec84fdf813c3d84c34fe1ea4..f32e88ea2f63bc593fe9d687aee43107db34a584 100644 (file)
@@ -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"
index 286cc4dd5611298487eacad63aab1f703d74e7a0..d89056967b715beb081e619104c089b1e3d758a3 100644 (file)
@@ -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"
index 16ce7f3d8ead59bab89991e615060697ca79e181..9035bbcc785c2bd19f31a3ea2550668d449f1d2e 100644 (file)
@@ -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"
index 256be92ebda80d25d8a0522bfd98567643a6d5ba..63066beab367ca261843e12a629cd4a984b9d766 100644 (file)
@@ -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"
index 7414969df100b2038a77658de01f305a2adab53c..2bc07a999a8e8f320f73a76bdd92233e7ef94df3 100644 (file)
@@ -36,7 +36,7 @@
 
 #include "uml_conf.h"
 #include "uuid.h"
-#include "buf.h"
+#include "virbuffer.h"
 #include "conf.h"
 #include "util.h"
 #include "memory.h"
index 887dca63503458644ec910214e34c3b45fd3c44d..8dece668509e5e99cd1230f9cabd70d490d9a62e 100644 (file)
@@ -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 (file)
index e5406da..0000000
+++ /dev/null
@@ -1,687 +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@redhat.com>
- */
-
-#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);
-}
-
-/* Work around spurious strchr() diagnostics given by -Wlogical-op
- * for gcc < 4.6.  Doing it via a local pragma keeps the damage
- * smaller than disabling it on the package level.  Unfortunately, the
- * affected GCCs don't allow diagnostic push/pop which would have
- * further reduced the impact. */
-#if BROKEN_GCC_WLOGICALOP
-# pragma GCC diagnostic ignored "-Wlogical-op"
-#endif
-
-/**
- * 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) {
-        if (strchr(toescape, *cur))
-            *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 (file)
index c3a498d..0000000
+++ /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@redhat.com>
- */
-
-#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__ */
index ebdd63674042c50d2c565253a852c9ce3100dfb6..fbd9ff8e7df53d2c48f3c4969afd1399c087be54 100644 (file)
@@ -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
 
index 177a0eb13509d341da9e9e446f9f0a212b2a4823..6c8ab49e6c02c0cf4730b7209ca095cc1ef305e6 100644 (file)
@@ -24,7 +24,7 @@
 
 # include "internal.h"
 # include "util.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 typedef struct _virCommand virCommand;
 typedef virCommand *virCommandPtr;
index ba8009770b4fe4508ba4dba5a4ca24888fd53fdd..3b975455c528f92717fd7329eb72e0a5f062bd42 100644 (file)
@@ -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"
index e8fed55deb3fa8167d1c7156f6adbf472ca83d4c..0df354905a1b903f1d21bf3f59d49031ff9dc861 100644 (file)
@@ -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"
index 52feecc371c3ca1738c8a967492c72ca41544ffd..028b791ac930da3d1164b93882f022ab3e101cc3 100644 (file)
@@ -23,7 +23,7 @@
 # define __VIRTLOG_H_
 
 # include "internal.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 /*
  * To be made public
index b4b41edb6433b0e086716be00b55987739d0804e..13ec481f3ba761fdd900b2d8a150e736c0788417 100644 (file)
@@ -13,7 +13,7 @@
 # define _LIBVIR_SEXPR_H_
 
 # include "internal.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 enum sexpr_type {
     SEXPR_NIL,
index 40a100ae619a681e5c882923955fb20c6f1e6f32..0b1f000e9698a8708efe0675db8d7a1b9e40953f 100644 (file)
@@ -26,7 +26,7 @@
 
 # include "internal.h"
 # include "util.h"
-# include "buf.h"
+# include "virbuffer.h"
 
 enum virSysinfoType {
     VIR_SYSINFO_SMBIOS,
index 05e7ca7d2626ec1cc1e73ad8351f36484fcad906..422ee7508a8ce3855e2ba5878afdbbf8c8e27b12 100644 (file)
@@ -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"
index f63dd209c31f99e8b1e24dbc3299c2ebc538ce15..ec1483f104a3b1ef47c6274d57544ca4c8f54d13 100644 (file)
@@ -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 (file)
index 0000000..c856c52
--- /dev/null
@@ -0,0 +1,687 @@
+/*
+ * virbuffer.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@redhat.com>
+ */
+
+#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);
+}
+
+/* Work around spurious strchr() diagnostics given by -Wlogical-op
+ * for gcc < 4.6.  Doing it via a local pragma keeps the damage
+ * smaller than disabling it on the package level.  Unfortunately, the
+ * affected GCCs don't allow diagnostic push/pop which would have
+ * further reduced the impact. */
+#if BROKEN_GCC_WLOGICALOP
+# pragma GCC diagnostic ignored "-Wlogical-op"
+#endif
+
+/**
+ * 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) {
+        if (strchr(toescape, *cur))
+            *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 (file)
index 0000000..7b69c0e
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * virbuffer.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@redhat.com>
+ */
+
+#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__ */
index 1917e9a6bd115df7265df206760480768e230ed5..228c3fb418f6809506fc5408c041b076fe13661f 100644 (file)
@@ -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
index 26dbf2442052261fdb3c46e70285213da06d7105..dd3b87819a89836cdc01b5bb5c6b4c6545c19e22 100644 (file)
@@ -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
 
index 84db8655da160312da30271ab848c7e102741ac5..5b08b1f0973b9b2f93c9c91419a36b7a5f3e0ea7 100644 (file)
@@ -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"
index 1a959cd4ee6f3f75f8e2bef30d5f027d035106e2..f7daaa61083708457eab86298cb6b50b00c4e206 100644 (file)
@@ -73,7 +73,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"
index 922c571e23b97360737667351ad5cf0e4432db69..9407e95ad187aed73ed3d1f85c492595f5fa024d 100644 (file)
@@ -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"
index 59427881036ee1b4ffa5becdf35bd2ca4fd33f35..06c75e168ce5fae1c5803713db7e94edb1dc3faa 100644 (file)
@@ -23,7 +23,7 @@
 # include "capabilities.h"
 # include "domain_conf.h"
 # include "driver.h"
-# include "buf.h"
+# include "virbuffer.h"
 # include "viruri.h"
 
 int
index 9da2974c710f98d2ebb84825242b0bb86c9cfa1b..2cd4b95e0206054736c107d2eddd0d037805df46 100644 (file)
@@ -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"
index 2d26cae11eca6cc89455903952dbfd9653e3c6a5..502c6534e615ae6638fec28e4453d9dea856c056 100644 (file)
@@ -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"
index 8c906f44f9ad2e39b4459ee1141aa3a51cd3fa8b..dbdb22d390c694085b120fb06a301b5e3b9345c3 100644 (file)
@@ -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"
index c789d703e4bd913e792e656d0c91eb684aaf2d8f..4a54c9fce7ccfbc35f1fa6c0238beea42eb2e863 100644 (file)
@@ -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"
index 353bc7659c2880bb60f5b6084742f6b9a035171b..c5133766753dac33d4d8b6e6f4c138b86c692e5d 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "internal.h"
 
-#include "buf.h"
+#include "virbuffer.h"
 #include "sysinfo.h"
 #include "testutils.h"
 #include "util.h"
index 3d2e491df60434e2bb059371ae9732975f98b8b3..e8b48e86ee7f0b837dd59aab423694c51c9415d5 100644 (file)
@@ -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"
index 35ba9978744b2f8366ffe96fc2f3f5b1078e93ca..53b9bbe7493765ae9522e3d793a8225cdeb84c73 100644 (file)
@@ -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(...)                             \
index 765f30c0cc93643c35e2053a9ab8b38501f3f23e..76d9d51c283ae4fd7315e65226be5162b3fdd0ee 100644 (file)
@@ -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"
index 3d13e016edfdc71f4dfeaf9615581ae41f15490d..f687780911014873b7e4c606ebba823060cb8cf8 100644 (file)
@@ -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"
index 3a6285bd20916d01180997867685e66dab831580..956fee8e244e39deee3ea797bdc563593d80918b 100644 (file)
@@ -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"
index fd9d563ffcb483b3eaf21324c7b18092524beae0..c5d494a37ed203af9fb7f12a275e4780d443cdc4 100644 (file)
@@ -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"
index 8cf96bed05f8f6a67a939d7ed1319745fb2cc70a..52cd874cc1f2e6516c8d222357aa096b6ab02299 100644 (file)
@@ -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"
index 5e791917cf5a56ab286548b56d386a4c8f882926..3108d1b082bbff50c44d46f6f542da6290ab6bc6 100644 (file)
@@ -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"
index 5fee2cdedfd8747f64b169c4e7d714d21cde7a98..4a78467f384f104a105d49e8c6244c2ae71fc780 100644 (file)
@@ -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"
index 52879e11c42a0e6375eab3d1edb2e7ce9474edbe..ee79b972ea309d1a7fce2e838562d761e571ab13 100644 (file)
@@ -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"
index 8ec6456ed24bc13ac445672829cfae0a92741ee0..d6a381de883f24cec08b8dca0b78c0df19c8e830 100644 (file)
@@ -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"
index 21a2df08d821326eaf7a26535808acbdbdd58ae8..1bad6b1a3d232a4793f48ac8a6a5629e2d7439a6 100644 (file)
@@ -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"
index 2f7d4a36c7e1ded7480e33388e3a284149b7a5e1..82c03e4a23c1c87d1d32679fdc7e196b93a57930 100644 (file)
@@ -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"