[PATCH 11/16] Revert "Remove virJSONValueNewStringLen"

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

 



This reverts commit 8f802c6d8659beb9eb3cab96ba2553e251728337.

Jansson cannot parse QEMU's quirky JSON.
Revert back to yajl.

https://bugzilla.redhat.com/show_bug.cgi?id=1614569

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virjson.c       | 22 ++++++++++++++++++++++
 src/util/virjson.h       |  1 +
 3 files changed, 24 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 496de11168..f555b1d5b1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2096,6 +2096,7 @@ virJSONValueNewNumberUint;
 virJSONValueNewNumberUlong;
 virJSONValueNewObject;
 virJSONValueNewString;
+virJSONValueNewStringLen;
 virJSONValueObjectAdd;
 virJSONValueObjectAddVArgs;
 virJSONValueObjectAppend;
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 01a387b2f7..80274bc6c5 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -420,6 +420,28 @@ virJSONValueNewString(const char *data)
 }
 
 
+virJSONValuePtr
+virJSONValueNewStringLen(const char *data,
+                         size_t length)
+{
+    virJSONValuePtr val;
+
+    if (!data)
+        return virJSONValueNewNull();
+
+    if (VIR_ALLOC(val) < 0)
+        return NULL;
+
+    val->type = VIR_JSON_TYPE_STRING;
+    if (VIR_STRNDUP(val->data.string, data, length) < 0) {
+        VIR_FREE(val);
+        return NULL;
+    }
+
+    return val;
+}
+
+
 static virJSONValuePtr
 virJSONValueNewNumber(const char *data)
 {
diff --git a/src/util/virjson.h b/src/util/virjson.h
index 0d5a7ef753..75f7f17b44 100644
--- a/src/util/virjson.h
+++ b/src/util/virjson.h
@@ -59,6 +59,7 @@ int virJSONValueObjectAddVArgs(virJSONValuePtr obj, va_list args)
 
 
 virJSONValuePtr virJSONValueNewString(const char *data);
+virJSONValuePtr virJSONValueNewStringLen(const char *data, size_t length);
 virJSONValuePtr virJSONValueNewNumberInt(int data);
 virJSONValuePtr virJSONValueNewNumberUint(unsigned int data);
 virJSONValuePtr virJSONValueNewNumberLong(long long data);
-- 
2.16.1

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




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

  Powered by Linux