Re: PATCH 9/20: unify the two buffer implemenations

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

 



This patch moves the previously created qemud/buf.c file into the src/
directory and deletes the original implementation in src/xml.c. The
qemud/Makefile.am is hacked to compile the code from src/buf.c directly.
This hack will go away in a later patch.

 a/qemud/buf.c       |  210 ----------------------------------------------------
 a/qemud/buf.h       |   37 ---------
 b/src/buf.c         |  210 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 b/src/buf.h         |   37 +++++++++
 proxy/Makefile.am   |    2 
 qemud/Makefile.am   |    2 
 qemud/conf.c        |   14 ---
 qemud/driver.c      |    2 
 src/Makefile.am     |    1 
 src/conf.c          |    2 
 src/test.c          |    1 
 src/xen_internal.c  |    2 
 src/xend_internal.c |    1 
 src/xm_internal.c   |    1 
 src/xml.c           |  172 ------------------------------------------
 src/xml.h           |   20 ----
 src/xmlrpc.h        |    2 
 tests/xmlrpctest.c  |    2 
 18 files changed, 260 insertions(+), 458 deletions(-)


Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
diff -r a209921f150a proxy/Makefile.am
--- a/proxy/Makefile.am	Thu Jun 21 16:27:37 2007 -0400
+++ b/proxy/Makefile.am	Thu Jun 21 16:27:38 2007 -0400
@@ -10,7 +10,7 @@ libvirt_proxy_SOURCES = libvirt_proxy.c 
 libvirt_proxy_SOURCES = libvirt_proxy.c @top_srcdir@/src/xend_internal.c \
 	    @top_srcdir@/src/xen_internal.c @top_srcdir@/src/virterror.c \
 	    @top_srcdir@/src/sexpr.c @top_srcdir@/src/xml.c \
-            @top_srcdir@/src/xs_internal.c
+            @top_srcdir@/src/xs_internal.c @top_srcdir@/src/buf.c
 libvirt_proxy_LDFLAGS = $(WARN_CFLAGS)
 libvirt_proxy_DEPENDENCIES =
 libvirt_proxy_LDADD =
diff -r a209921f150a qemud/Makefile.am
--- a/qemud/Makefile.am	Thu Jun 21 16:27:37 2007 -0400
+++ b/qemud/Makefile.am	Thu Jun 21 16:28:14 2007 -0400
@@ -13,7 +13,7 @@ libvirt_qemud_SOURCES = \
                 bridge.c bridge.h \
                 iptables.c iptables.h \
                 uuid.c uuid.h \
-		buf.c buf.h \
+		../src/buf.c \
 		protocol.h protocol.c \
 		remote_protocol.h remote_protocol.c \
 		remote.c \
diff -r a209921f150a qemud/buf.c
--- a/qemud/buf.c	Thu Jun 21 16:27:37 2007 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,210 +0,0 @@
-/*
- * buf.c: buffers for libvirt
- *
- * Copyright (C) 2005-2007 Red Hat, Inc.
- *
- * See COPYING.LIB for the License of this software
- *
- * Daniel Veillard <veillard@xxxxxxxxxx>
- */
-
-#include "libvirt/libvirt.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include "buf.h"
-
-/**
- * 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 the new available space or -1 in case of error
- */
-static int
-virBufferGrow(virBufferPtr buf, unsigned int len)
-{
-    int size;
-    char *newbuf;
-
-    if (buf == NULL)
-        return (-1);
-    if (len + buf->use < buf->size)
-        return (0);
-
-    size = buf->use + len + 1000;
-
-    newbuf = (char *) realloc(buf->content, size);
-    if (newbuf == NULL) return -1;
-    buf->content = newbuf;
-    buf->size = size;
-    return (buf->size - buf->use);
-}
-
-/**
- * virBufferAdd:
- * @buf:  the buffer to dump
- * @str:  the string
- * @len:  the number of bytes to add
- *
- * Add a string range to an XML buffer. if len == -1, the length of
- * str is recomputed to the full string.
- *
- * Returns 0 successful, -1 in case of internal or API error.
- */
-int
-virBufferAdd(virBufferPtr buf, const char *str, int len)
-{
-    unsigned int needSize;
-
-    if ((str == NULL) || (buf == NULL)) {
-        return -1;
-    }
-    if (len == 0)
-        return 0;
-
-    if (len < 0)
-        len = strlen(str);
-
-    needSize = buf->use + len + 2;
-    if (needSize > buf->size) {
-        if (!virBufferGrow(buf, needSize - buf->use)) {
-            return (-1);
-        }
-    }
-    /* XXX: memmove() is 2x slower than memcpy(), do we really need it? */
-    memmove(&buf->content[buf->use], str, len);
-    buf->use += len;
-    buf->content[buf->use] = 0;
-    return (0);
-}
-
-virBufferPtr
-virBufferNew(unsigned int size)
-{
-    virBufferPtr buf;
-
-    if (!(buf = malloc(sizeof(*buf)))) return NULL;
-    if (size && (buf->content = malloc(size))==NULL) {
-        free(buf);
-        return NULL;
-    }
-    buf->size = size;
-    buf->use = 0;
-
-    return buf;
-}
-
-void
-virBufferFree(virBufferPtr buf)
-{
-    if (buf) {
-        if (buf->content)
-            free(buf->content);
-        free(buf);
-    }
-}
-
-/**
- * virBufferContentAndFree:
- * @buf: Buffer
- *
- * Return the content from the buffer and free (only) the buffer structure.
- */
-char *
-virBufferContentAndFree (virBufferPtr buf)
-{
-    char *content = buf->content;
-
-    free (buf);
-    return content;
-}
-
-/**
- * virBufferVSprintf:
- * @buf:  the buffer to dump
- * @format:  the format
- * @argptr:  the variable list of arguments
- *
- * Do a formatted print to an XML buffer.
- *
- * Returns 0 successful, -1 in case of internal or API error.
- */
-int
-virBufferVSprintf(virBufferPtr buf, const char *format, ...)
-{
-    int size, count;
-    va_list locarg, argptr;
-
-    if ((format == NULL) || (buf == NULL)) {
-        return (-1);
-    }
-    size = buf->size - buf->use - 1;
-    va_start(argptr, format);
-    va_copy(locarg, argptr);
-    while (((count = vsnprintf(&buf->content[buf->use], size, format,
-                               locarg)) < 0) || (count >= size - 1)) {
-        buf->content[buf->use] = 0;
-        va_end(locarg);
-        if (virBufferGrow(buf, 1000) < 0) {
-            return (-1);
-        }
-        size = buf->size - buf->use - 1;
-        va_copy(locarg, argptr);
-    }
-    va_end(locarg);
-    buf->use += count;
-    buf->content[buf->use] = 0;
-    return (0);
-}
-
-/**
- * virBufferStrcat:
- * @buf:  the buffer to dump
- * @argptr:  the variable list of strings, the last argument must be NULL
- *
- * Concatenate strings to an XML buffer.
- *
- * Returns 0 successful, -1 in case of internal or API error.
- */
-int
-virBufferStrcat(virBufferPtr buf, ...)
-{
-    va_list ap;
-    char *str;
-
-    va_start(ap, buf);
-
-    while ((str = va_arg(ap, char *)) != NULL) {
-        unsigned int len = strlen(str);
-        unsigned int needSize = buf->use + len + 2;
-
-        if (needSize > buf->size) {
-            if (!virBufferGrow(buf, needSize - buf->use))
-                return -1;
-        }
-        memcpy(&buf->content[buf->use], str, len);
-        buf->use += len;
-        buf->content[buf->use] = 0;
-    }
-    va_end(ap);
-    return 0;
-}
-
-/*
- * vim: set tabstop=4:
- * vim: set shiftwidth=4:
- * vim: set expandtab:
- */
-/*
- * Local variables:
- *  indent-tabs-mode: nil
- *  c-indent-level: 4
- *  c-basic-offset: 4
- *  tab-width: 4
- * End:
- */
diff -r a209921f150a qemud/buf.h
--- a/qemud/buf.h	Thu Jun 21 16:27:37 2007 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * buf.h: buffers for libvirt
- *
- * Copyright (C) 2005-2007 Red Hat, Inc.
- *
- * See COPYING.LIB for the License of this software
- *
- * Daniel Veillard <veillard@xxxxxxxxxx>
- */
-
-#ifndef __VIR_BUFFER_H__
-#define __VIR_BUFFER_H__
-
-#include "internal.h"
-
-/**
- * virBuffer:
- *
- * A buffer structure.
- */
-typedef struct _virBuffer virBuffer;
-typedef virBuffer *virBufferPtr;
-struct _virBuffer {
-    char *content;          /* The buffer content UTF8 */
-    unsigned int use;       /* The buffer size used */
-    unsigned int size;      /* The buffer size */
-};
-
-virBufferPtr virBufferNew(unsigned int size);
-void virBufferFree(virBufferPtr buf);
-char *virBufferContentAndFree(virBufferPtr buf);
-int virBufferAdd(virBufferPtr buf, const char *str, int len);
-int virBufferVSprintf(virBufferPtr buf, const char *format, ...)
-  ATTRIBUTE_FORMAT(printf, 2, 3);
-int virBufferStrcat(virBufferPtr buf, ...);
-
-#endif /* __VIR_BUFFER_H__ */
diff -r a209921f150a qemud/conf.c
--- a/qemud/conf.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/qemud/conf.c	Thu Jun 21 16:29:47 2007 -0400
@@ -45,19 +45,7 @@
 #include "internal.h"
 #include "conf.h"
 #include "uuid.h"
-#include "buf.h"
-
-extern void __virRaiseError(virConnectPtr conn,
-                            virDomainPtr dom,
-                            virNetworkPtr net,
-                            int domain,
-                            int code,
-                            virErrorLevel level,
-                            const char *str1,
-                            const char *str2,
-                            const char *str3,
-                            int int1, int int2, const char *msg, ...)
-  ATTRIBUTE_FORMAT(printf, 12, 13);
+#include "../src/buf.h"
 
 void qemudReportError(virConnectPtr conn,
                       virDomainPtr dom,
diff -r a209921f150a qemud/driver.c
--- a/qemud/driver.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/qemud/driver.c	Thu Jun 21 16:28:54 2007 -0400
@@ -49,7 +49,7 @@
 #include <libvirt/virterror.h>
 
 #include "event.h"
-#include "buf.h"
+#include "../src/buf.h"
 #include "driver.h"
 
 static int qemudSetCloseExec(int fd) {
diff -r a209921f150a src/Makefile.am
--- a/src/Makefile.am	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/Makefile.am	Thu Jun 21 16:27:38 2007 -0400
@@ -29,6 +29,7 @@ CLIENT_SOURCES =						\
 		libvirt.c internal.h				\
 		hash.c hash.h					\
 		test.c test.h                                   \
+                buf.c buf.h					\
 		xml.c xml.h					\
 		xen_unified.c xen_unified.h			\
 		xen_internal.c xen_internal.h			\
diff -r a209921f150a src/buf.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/buf.c	Thu Jun 21 16:27:38 2007 -0400
@@ -0,0 +1,210 @@
+/*
+ * buf.c: buffers for libvirt
+ *
+ * Copyright (C) 2005-2007 Red Hat, Inc.
+ *
+ * See COPYING.LIB for the License of this software
+ *
+ * Daniel Veillard <veillard@xxxxxxxxxx>
+ */
+
+#include "libvirt/libvirt.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include "buf.h"
+
+/**
+ * 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 the new available space or -1 in case of error
+ */
+static int
+virBufferGrow(virBufferPtr buf, unsigned int len)
+{
+    int size;
+    char *newbuf;
+
+    if (buf == NULL)
+        return (-1);
+    if (len + buf->use < buf->size)
+        return (0);
+
+    size = buf->use + len + 1000;
+
+    newbuf = (char *) realloc(buf->content, size);
+    if (newbuf == NULL) return -1;
+    buf->content = newbuf;
+    buf->size = size;
+    return (buf->size - buf->use);
+}
+
+/**
+ * virBufferAdd:
+ * @buf:  the buffer to dump
+ * @str:  the string
+ * @len:  the number of bytes to add
+ *
+ * Add a string range to an XML buffer. if len == -1, the length of
+ * str is recomputed to the full string.
+ *
+ * Returns 0 successful, -1 in case of internal or API error.
+ */
+int
+virBufferAdd(virBufferPtr buf, const char *str, int len)
+{
+    unsigned int needSize;
+
+    if ((str == NULL) || (buf == NULL)) {
+        return -1;
+    }
+    if (len == 0)
+        return 0;
+
+    if (len < 0)
+        len = strlen(str);
+
+    needSize = buf->use + len + 2;
+    if (needSize > buf->size) {
+        if (!virBufferGrow(buf, needSize - buf->use)) {
+            return (-1);
+        }
+    }
+    /* XXX: memmove() is 2x slower than memcpy(), do we really need it? */
+    memmove(&buf->content[buf->use], str, len);
+    buf->use += len;
+    buf->content[buf->use] = 0;
+    return (0);
+}
+
+virBufferPtr
+virBufferNew(unsigned int size)
+{
+    virBufferPtr buf;
+
+    if (!(buf = malloc(sizeof(*buf)))) return NULL;
+    if (size && (buf->content = malloc(size))==NULL) {
+        free(buf);
+        return NULL;
+    }
+    buf->size = size;
+    buf->use = 0;
+
+    return buf;
+}
+
+void
+virBufferFree(virBufferPtr buf)
+{
+    if (buf) {
+        if (buf->content)
+            free(buf->content);
+        free(buf);
+    }
+}
+
+/**
+ * virBufferContentAndFree:
+ * @buf: Buffer
+ *
+ * Return the content from the buffer and free (only) the buffer structure.
+ */
+char *
+virBufferContentAndFree (virBufferPtr buf)
+{
+    char *content = buf->content;
+
+    free (buf);
+    return content;
+}
+
+/**
+ * virBufferVSprintf:
+ * @buf:  the buffer to dump
+ * @format:  the format
+ * @argptr:  the variable list of arguments
+ *
+ * Do a formatted print to an XML buffer.
+ *
+ * Returns 0 successful, -1 in case of internal or API error.
+ */
+int
+virBufferVSprintf(virBufferPtr buf, const char *format, ...)
+{
+    int size, count;
+    va_list locarg, argptr;
+
+    if ((format == NULL) || (buf == NULL)) {
+        return (-1);
+    }
+    size = buf->size - buf->use - 1;
+    va_start(argptr, format);
+    va_copy(locarg, argptr);
+    while (((count = vsnprintf(&buf->content[buf->use], size, format,
+                               locarg)) < 0) || (count >= size - 1)) {
+        buf->content[buf->use] = 0;
+        va_end(locarg);
+        if (virBufferGrow(buf, 1000) < 0) {
+            return (-1);
+        }
+        size = buf->size - buf->use - 1;
+        va_copy(locarg, argptr);
+    }
+    va_end(locarg);
+    buf->use += count;
+    buf->content[buf->use] = 0;
+    return (0);
+}
+
+/**
+ * virBufferStrcat:
+ * @buf:  the buffer to dump
+ * @argptr:  the variable list of strings, the last argument must be NULL
+ *
+ * Concatenate strings to an XML buffer.
+ *
+ * Returns 0 successful, -1 in case of internal or API error.
+ */
+int
+virBufferStrcat(virBufferPtr buf, ...)
+{
+    va_list ap;
+    char *str;
+
+    va_start(ap, buf);
+
+    while ((str = va_arg(ap, char *)) != NULL) {
+        unsigned int len = strlen(str);
+        unsigned int needSize = buf->use + len + 2;
+
+        if (needSize > buf->size) {
+            if (!virBufferGrow(buf, needSize - buf->use))
+                return -1;
+        }
+        memcpy(&buf->content[buf->use], str, len);
+        buf->use += len;
+        buf->content[buf->use] = 0;
+    }
+    va_end(ap);
+    return 0;
+}
+
+/*
+ * vim: set tabstop=4:
+ * vim: set shiftwidth=4:
+ * vim: set expandtab:
+ */
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff -r a209921f150a src/buf.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/buf.h	Thu Jun 21 16:27:38 2007 -0400
@@ -0,0 +1,37 @@
+/*
+ * buf.h: buffers for libvirt
+ *
+ * Copyright (C) 2005-2007 Red Hat, Inc.
+ *
+ * See COPYING.LIB for the License of this software
+ *
+ * Daniel Veillard <veillard@xxxxxxxxxx>
+ */
+
+#ifndef __VIR_BUFFER_H__
+#define __VIR_BUFFER_H__
+
+#include "internal.h"
+
+/**
+ * virBuffer:
+ *
+ * A buffer structure.
+ */
+typedef struct _virBuffer virBuffer;
+typedef virBuffer *virBufferPtr;
+struct _virBuffer {
+    char *content;          /* The buffer content UTF8 */
+    unsigned int use;       /* The buffer size used */
+    unsigned int size;      /* The buffer size */
+};
+
+virBufferPtr virBufferNew(unsigned int size);
+void virBufferFree(virBufferPtr buf);
+char *virBufferContentAndFree(virBufferPtr buf);
+int virBufferAdd(virBufferPtr buf, const char *str, int len);
+int virBufferVSprintf(virBufferPtr buf, const char *format, ...)
+  ATTRIBUTE_FORMAT(printf, 2, 3);
+int virBufferStrcat(virBufferPtr buf, ...);
+
+#endif /* __VIR_BUFFER_H__ */
diff -r a209921f150a src/conf.c
--- a/src/conf.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/conf.c	Thu Jun 21 16:27:38 2007 -0400
@@ -18,7 +18,7 @@
 #include <fcntl.h>
 
 #include "internal.h"
-#include "xml.h"
+#include "buf.h"
 #include "conf.h"
 
 /************************************************************************
diff -r a209921f150a src/test.c
--- a/src/test.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/test.c	Thu Jun 21 16:27:38 2007 -0400
@@ -35,6 +35,7 @@
 #include "internal.h"
 #include "test.h"
 #include "xml.h"
+#include "buf.h"
 
 int testOpen(virConnectPtr conn,
              const char *name,
diff -r a209921f150a src/xen_internal.c
--- a/src/xen_internal.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/xen_internal.c	Thu Jun 21 16:27:38 2007 -0400
@@ -35,7 +35,7 @@
 /* required for shutdown flags */
 #include <xen/sched.h>
 
-#include "xml.h"
+#include "buf.h"
 
 /* #define DEBUG */
 /*
diff -r a209921f150a src/xend_internal.c
--- a/src/xend_internal.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/xend_internal.c	Thu Jun 21 16:27:38 2007 -0400
@@ -35,6 +35,7 @@
 #include "internal.h"
 #include "sexpr.h"
 #include "xml.h"
+#include "buf.h"
 #include "xen_unified.h"
 #include "xend_internal.h"
 #include "xen_internal.h" /* for DOM0_INTERFACE_VERSION */
diff -r a209921f150a src/xm_internal.c
--- a/src/xm_internal.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/xm_internal.c	Thu Jun 21 16:27:38 2007 -0400
@@ -47,6 +47,7 @@
 #include "hash.h"
 #include "internal.h"
 #include "xml.h"
+#include "buf.h"
 
 typedef struct xenXMConfCache *xenXMConfCachePtr;
 typedef struct xenXMConfCache {
diff -r a209921f150a src/xml.c
--- a/src/xml.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/xml.c	Thu Jun 21 16:27:38 2007 -0400
@@ -22,6 +22,7 @@
 #include "hash.h"
 #include "sexpr.h"
 #include "xml.h"
+#include "buf.h"
 #include "xs_internal.h" /* for xenStoreDomainGetNetworkID */
 
 /**
@@ -267,177 +268,6 @@ virXPathNodeSet(const char *xpath, xmlXP
     return(ret);
 }
 #endif /* !PROXY */
-
-/**
- * virBufferGrow:
- * @buf:  the buffer
- * @len:  the minimum free size to allocate on top of existing used space
- *
- * Grow the available space of an XML buffer to at least @len bytes.
- *
- * Returns the new available space or -1 in case of error
- */
-static int
-virBufferGrow(virBufferPtr buf, unsigned int len)
-{
-    int size;
-    char *newbuf;
-
-    if (buf == NULL)
-        return (-1);
-    if (len + buf->use < buf->size)
-        return (0);
-
-    size = buf->use + len + 1000;
-
-    newbuf = (char *) realloc(buf->content, size);
-    if (newbuf == NULL) {
-        virXMLError(NULL, VIR_ERR_NO_MEMORY, _("growing buffer"), size);
-        return (-1);
-    }
-    buf->content = newbuf;
-    buf->size = size;
-    return (buf->size - buf->use);
-}
-
-/**
- * virBufferAdd:
- * @buf:  the buffer to dump
- * @str:  the string
- * @len:  the number of bytes to add
- *
- * Add a string range to an XML buffer. if len == -1, the length of
- * str is recomputed to the full string.
- *
- * Returns 0 successful, -1 in case of internal or API error.
- */
-int
-virBufferAdd(virBufferPtr buf, const char *str, int len)
-{
-    unsigned int needSize;
-
-    if ((str == NULL) || (buf == NULL)) {
-        return -1;
-    }
-    if (len == 0)
-        return 0;
-
-    if (len < 0)
-        len = strlen(str);
-
-    needSize = buf->use + len + 2;
-    if (needSize > buf->size) {
-        if (!virBufferGrow(buf, needSize - buf->use)) {
-            return (-1);
-        }
-    }
-    /* XXX: memmove() is 2x slower than memcpy(), do we really need it? */
-    memmove(&buf->content[buf->use], str, len);
-    buf->use += len;
-    buf->content[buf->use] = 0;
-    return (0);
-}
-
-virBufferPtr
-virBufferNew(unsigned int size)
-{
-    virBufferPtr buf;
-
-    if (!(buf = malloc(sizeof(*buf)))) {
-        virXMLError(NULL, VIR_ERR_NO_MEMORY, _("allocate new buffer"), sizeof(*buf));
-        return NULL;
-    }
-    if (size && (buf->content = malloc(size))==NULL) {
-        virXMLError(NULL, VIR_ERR_NO_MEMORY, _("allocate buffer content"), size);
-        free(buf);
-        return NULL;
-    }
-    buf->size = size;
-    buf->use = 0;
-
-    return buf;
-}
-
-void
-virBufferFree(virBufferPtr buf)
-{
-    if (buf) {
-        if (buf->content)
-            free(buf->content);
-        free(buf);
-    }
-}
-
-/**
- * virBufferVSprintf:
- * @buf:  the buffer to dump
- * @format:  the format
- * @argptr:  the variable list of arguments
- *
- * Do a formatted print to an XML buffer.
- *
- * Returns 0 successful, -1 in case of internal or API error.
- */
-int
-virBufferVSprintf(virBufferPtr buf, const char *format, ...)
-{
-    int size, count;
-    va_list locarg, argptr;
-
-    if ((format == NULL) || (buf == NULL)) {
-        return (-1);
-    }
-    size = buf->size - buf->use - 1;
-    va_start(argptr, format);
-    va_copy(locarg, argptr);
-    while (((count = vsnprintf(&buf->content[buf->use], size, format,
-                               locarg)) < 0) || (count >= size - 1)) {
-        buf->content[buf->use] = 0;
-        va_end(locarg);
-        if (virBufferGrow(buf, 1000) < 0) {
-            return (-1);
-        }
-        size = buf->size - buf->use - 1;
-        va_copy(locarg, argptr);
-    }
-    va_end(locarg);
-    buf->use += count;
-    buf->content[buf->use] = 0;
-    return (0);
-}
-
-/**
- * virBufferStrcat:
- * @buf:  the buffer to dump
- * @argptr:  the variable list of strings, the last argument must be NULL
- *
- * Concatenate strings to an XML buffer.
- *
- * Returns 0 successful, -1 in case of internal or API error.
- */
-int
-virBufferStrcat(virBufferPtr buf, ...)
-{
-    va_list ap;
-    char *str;
-
-    va_start(ap, buf);
-
-    while ((str = va_arg(ap, char *)) != NULL) {
-        unsigned int len = strlen(str);
-        unsigned int needSize = buf->use + len + 2;
-
-        if (needSize > buf->size) {
-            if (!virBufferGrow(buf, needSize - buf->use))
-                return -1;
-        }
-        memcpy(&buf->content[buf->use], str, len);
-        buf->use += len;
-        buf->content[buf->use] = 0;
-    }
-    va_end(ap);
-    return 0;
-}
 
 
 #ifndef PROXY
diff -r a209921f150a src/xml.h
--- a/src/xml.h	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/xml.h	Thu Jun 21 16:27:38 2007 -0400
@@ -14,26 +14,6 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-
-/**
- * virBuffer:
- *
- * A buffer structure.
- */
-typedef struct _virBuffer virBuffer;
-typedef virBuffer *virBufferPtr;
-struct _virBuffer {
-    char *content;          /* The buffer content UTF8 */
-    unsigned int use;       /* The buffer size used */
-    unsigned int size;      /* The buffer size */
-};
-
-virBufferPtr virBufferNew(unsigned int size);
-void virBufferFree(virBufferPtr buf);
-int virBufferAdd(virBufferPtr buf, const char *str, int len);
-int virBufferVSprintf(virBufferPtr buf, const char *format, ...)
-  ATTRIBUTE_FORMAT(printf, 2, 3);
-int virBufferStrcat(virBufferPtr buf, ...);
 
 int		virXPathBoolean	(const char *xpath,
 				 xmlXPathContextPtr ctxt);
diff -r a209921f150a src/xmlrpc.h
--- a/src/xmlrpc.h	Thu Jun 21 16:27:37 2007 -0400
+++ b/src/xmlrpc.h	Thu Jun 21 16:27:38 2007 -0400
@@ -19,7 +19,7 @@
 #include <time.h>
 #include <stdarg.h>
 
-#include "xml.h"
+#include "buf.h"
 
 typedef enum _xmlRpcValueType xmlRpcValueType;
 
diff -r a209921f150a tests/xmlrpctest.c
--- a/tests/xmlrpctest.c	Thu Jun 21 16:27:37 2007 -0400
+++ b/tests/xmlrpctest.c	Thu Jun 21 16:27:38 2007 -0400
@@ -20,7 +20,7 @@
 #include <libxml/xpath.h>
 
 #include "libvirt/libvirt.h"
-#include "xml.h"
+#include "buf.h"
 #include "xmlrpc.h"
 
 #include "testutils.h"

[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]