]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Move virBuffer functions into src/buf.c,h
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 26 Jun 2007 22:33:22 +0000 (22:33 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 26 Jun 2007 22:33:22 +0000 (22:33 +0000)
17 files changed:
ChangeLog
proxy/Makefile.am
qemud/Makefile.am
qemud/conf.c
qemud/driver.c
src/Makefile.am
src/buf.c [moved from qemud/buf.c with 100% similarity]
src/buf.h [moved from qemud/buf.h with 100% similarity]
src/conf.c
src/test.c
src/xen_internal.c
src/xend_internal.c
src/xm_internal.c
src/xml.c
src/xml.h
src/xmlrpc.h
tests/xmlrpctest.c

index f2ca72c5ee96541aefede317b27109fc9beb221e..5056634c3140f53d8cf7882fc9ae16a10749616a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Tue Jun 26 18:30:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
+
+       * qemud/buf.c, qemud/buf.h: Remove obsolete files
+       * src/xml.c: remove virBuffer functions
+       * src/buf.c, src/buf.c, src/Makefile.am: Re-add virBuffer functions
+       * proxy/Makefile.am, qemud/Makefile.am, qemud/conf.c,
+       qemud/driver.c, src/conf.c, src/test.c, src/xen_internal.c,
+       src/xend_internal.c, src/xm_internal.c, src/xmlrpc.h,
+       tests/xmlrpc.test: Adapt to deal with new location of headers
+       for virBuffer functions.
+
 Tue Jun 26 18:21:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
 
        * qemud/conf.c, qemud/driver.c, qemud/buf.c, qemud/buf.h:
index c32e7b17d4f0ba5672b949b700486aee6d460c80..487458de352b10fc34fce5cac30c1363a0c45f7b 100644 (file)
@@ -10,7 +10,7 @@ libexec_PROGRAMS = libvirt_proxy
 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 =
index d9867eb825670fce5fb79186cd0c61db475782a0..7d6f1a818470abcc539aaa4ccb2aa3bf2ad15796 100644 (file)
@@ -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 \
index fdbb2d81e924b6369334e9559eaacb5313e852a4..98168a1f15909a8c987224a4f9f6bcffe742c329 100644 (file)
 #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,
index 3971a0f7156f5355cd5978cf3a6a0fe40c254e20..071558f044b0198088d34da4ee69bc320859a086 100644 (file)
@@ -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) {
index fd596ae009866d621df5efcb22cfb6c7bcd55574..c86736c84875af22b3fa0f6a6f79ffd378704339 100644 (file)
@@ -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                   \
similarity index 100%
rename from qemud/buf.c
rename to src/buf.c
similarity index 100%
rename from qemud/buf.h
rename to src/buf.h
index 7aad6529956d690715631a913f2c4cc3a0e611c6..8f4fc64cc722e5297cfbdd1747f97adf49d57e78 100644 (file)
@@ -18,7 +18,7 @@
 #include <fcntl.h>
 
 #include "internal.h"
-#include "xml.h"
+#include "buf.h"
 #include "conf.h"
 
 /************************************************************************
index 2a1cc58ba2213b77c05c684f5e9f46e16565a07f..922826b4e7eb266db8cbff2917e806461df35101 100644 (file)
@@ -39,6 +39,7 @@
 #include "internal.h"
 #include "test.h"
 #include "xml.h"
+#include "buf.h"
 
 int testOpen(virConnectPtr conn,
              const char *name,
index 75a6c4d43d6d65a4eca32a36cc14fc0ac60f078f..4221be356e7c6b17bc6e48cadc8d1f30578e2dbf 100644 (file)
@@ -35,7 +35,7 @@
 /* required for shutdown flags */
 #include <xen/sched.h>
 
-#include "xml.h"
+#include "buf.h"
 
 /* #define DEBUG */
 /*
index 27abafa03fb622c14ba32d3e7e828ce5c9f4f792..e1974e36f707d3ed4f8cf0d9a089fe6752a1a995 100644 (file)
@@ -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 */
index 04fd6611a76cbbd4ad7963168d953f3634665b72..261350537f5e3797d0d4786c1049b982522c3383 100644 (file)
@@ -47,6 +47,7 @@
 #include "hash.h"
 #include "internal.h"
 #include "xml.h"
+#include "buf.h"
 
 typedef struct xenXMConfCache *xenXMConfCachePtr;
 typedef struct xenXMConfCache {
index dc58b19a68dee17f35ac870e9166f41fe3e7bf5c..e5c59716b589a1629c2135b9999a21b7f539c01e 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
@@ -22,6 +22,7 @@
 #include "hash.h"
 #include "sexpr.h"
 #include "xml.h"
+#include "buf.h"
 #include "xs_internal.h" /* for xenStoreDomainGetNetworkID */
 
 /**
@@ -268,177 +269,6 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt, xmlNodePtr **list) {
 }
 #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
 /**
index 74e2cdfbbda2b07840ec442e1f0b6adc5b471ce3..a8c7b3cebcf6439903f75ff4584e9a9fd15d6d48 100644 (file)
--- a/src/xml.h
+++ b/src/xml.h
 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);
 char *         virXPathString  (const char *xpath,
index 3a8b750f624de76ea46bc78d8d72809ab56f8d6a..7ecace105d13b1cbf055e1230298a7a90b02194f 100644 (file)
@@ -19,7 +19,7 @@
 #include <time.h>
 #include <stdarg.h>
 
-#include "xml.h"
+#include "buf.h"
 
 typedef enum _xmlRpcValueType xmlRpcValueType;
 
index 2c180680afbf0dc0821832740d2fbcd9c1c4a19f..c15798969ef761145d8728b69703f641e0045ded 100644 (file)
@@ -20,7 +20,7 @@
 #include <libxml/xpath.h>
 
 #include "libvirt/libvirt.h"
-#include "xml.h"
+#include "buf.h"
 #include "xmlrpc.h"
 
 #include "testutils.h"