Revert "Remove virJSONValueNewStringLen"

This reverts commit 8f802c6d86.

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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Ján Tomko 2018-08-13 13:39:56 +02:00
parent 5a58b5ed68
commit 63f6e0e950
3 changed files with 24 additions and 0 deletions

View File

@ -2096,6 +2096,7 @@ virJSONValueNewNumberUint;
virJSONValueNewNumberUlong;
virJSONValueNewObject;
virJSONValueNewString;
virJSONValueNewStringLen;
virJSONValueObjectAdd;
virJSONValueObjectAddVArgs;
virJSONValueObjectAppend;

View File

@ -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)
{

View File

@ -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);