1 Star 0 Fork 72

Jiangjiacheng/src_libvirt

forked from src-openEuler/libvirt 
Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
util-json-Introduce-virJSONValueObjectAppendStringPr.patch 2.62 KB
Copy Edit Raw Blame History
imxcc authored 2022-02-22 00:16 +08:00 . update patch with openeuler !54
From 0924902c3814677f9f328f521a95d4a79635d81a Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 14 May 2020 08:09:56 +0200
Subject: [PATCH 04/18] util: json: Introduce
virJSONValueObjectAppendStringPrintf
Add a variant similar to virJSONValueObjectAppendString which also
formats more complex value strings with printf syntax.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
src/libvirt_private.syms | 1 +
src/util/virjson.c | 17 +++++++++++++++++
src/util/virjson.h | 2 ++
3 files changed, 20 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 84f3bd57ca..726e7a21f9 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2349,6 +2349,7 @@ virJSONValueObjectAppendNumberLong;
virJSONValueObjectAppendNumberUint;
virJSONValueObjectAppendNumberUlong;
virJSONValueObjectAppendString;
+virJSONValueObjectAppendStringPrintf;
virJSONValueObjectCreate;
virJSONValueObjectCreateVArgs;
virJSONValueObjectDeflatten;
diff --git a/src/util/virjson.c b/src/util/virjson.c
index dc662bf8e9..6921eccb60 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -649,6 +649,23 @@ virJSONValueObjectAppendString(virJSONValuePtr object,
}
+int
+virJSONValueObjectAppendStringPrintf(virJSONValuePtr object,
+ const char *key,
+ const char *fmt,
+ ...)
+{
+ va_list ap;
+ g_autofree char *str = NULL;
+
+ va_start(ap, fmt);
+ str = g_strdup_vprintf(fmt, ap);
+ va_end(ap);
+
+ return virJSONValueObjectInsertString(object, key, str, false);
+}
+
+
int
virJSONValueObjectPrependString(virJSONValuePtr object,
const char *key,
diff --git a/src/util/virjson.h b/src/util/virjson.h
index 0894e91b59..588c977650 100644
--- a/src/util/virjson.h
+++ b/src/util/virjson.h
@@ -127,6 +127,8 @@ int virJSONValueObjectGetBoolean(virJSONValuePtr object, const char *key, bool *
int virJSONValueObjectIsNull(virJSONValuePtr object, const char *key);
int virJSONValueObjectAppendString(virJSONValuePtr object, const char *key, const char *value);
+int virJSONValueObjectAppendStringPrintf(virJSONValuePtr object, const char *key, const char *fmt, ...)
+ G_GNUC_PRINTF(3, 4);
int virJSONValueObjectPrependString(virJSONValuePtr object, const char *key, const char *value);
int virJSONValueObjectAppendNumberInt(virJSONValuePtr object, const char *key, int number);
int virJSONValueObjectAppendNumberUint(virJSONValuePtr object, const char *key, unsigned int number);
--
2.23.0.windows.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jjiacheng/src_libvirt.git
git@gitee.com:jjiacheng/src_libvirt.git
jjiacheng
src_libvirt
src_libvirt
master

Search