Blame SOURCES/0065-json_writer-add-new-json-handlers-null-float-with-fo.patch

99be8f
From b4b11394d071810d694b66962e8d48cb866af473 Mon Sep 17 00:00:00 2001
99be8f
From: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date: Mon, 25 Mar 2019 13:30:53 +0100
99be8f
Subject: [PATCH] json_writer: add new json handlers (null, float with format,
99be8f
 lluint, hu)
99be8f
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1642479
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1641914
99be8f
Upstream Status: iproute2.git commit 7252f16b2d191
99be8f
99be8f
commit 7252f16b2d1919b31f0a2ec094dd3516b1e33a55
99be8f
Author: Julien Fortin <julien@cumulusnetworks.com>
99be8f
Date:   Thu Aug 17 10:35:50 2017 -0700
99be8f
99be8f
    json_writer: add new json handlers (null, float with format, lluint, hu)
99be8f
99be8f
    Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
99be8f
---
99be8f
 include/json_writer.h |  9 +++++++++
99be8f
 lib/json_writer.c     | 44 +++++++++++++++++++++++++++++++++++++++----
99be8f
 2 files changed, 49 insertions(+), 4 deletions(-)
99be8f
99be8f
diff --git a/include/json_writer.h b/include/json_writer.h
99be8f
index ab9a008a67994..1516aafba59df 100644
99be8f
--- a/include/json_writer.h
99be8f
+++ b/include/json_writer.h
99be8f
@@ -33,20 +33,29 @@ void jsonw_pretty(json_writer_t *self, bool on);
99be8f
 void jsonw_name(json_writer_t *self, const char *name);
99be8f
 
99be8f
 /* Add value  */
99be8f
+void jsonw_printf(json_writer_t *self, const char *fmt, ...);
99be8f
 void jsonw_string(json_writer_t *self, const char *value);
99be8f
 void jsonw_bool(json_writer_t *self, bool value);
99be8f
 void jsonw_float(json_writer_t *self, double number);
99be8f
+void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num);
99be8f
 void jsonw_uint(json_writer_t *self, uint64_t number);
99be8f
+void jsonw_hu(json_writer_t *self, unsigned short number);
99be8f
 void jsonw_int(json_writer_t *self, int64_t number);
99be8f
 void jsonw_null(json_writer_t *self);
99be8f
+void jsonw_lluint(json_writer_t *self, unsigned long long int num);
99be8f
 
99be8f
 /* Useful Combinations of name and value */
99be8f
 void jsonw_string_field(json_writer_t *self, const char *prop, const char *val);
99be8f
 void jsonw_bool_field(json_writer_t *self, const char *prop, bool value);
99be8f
 void jsonw_float_field(json_writer_t *self, const char *prop, double num);
99be8f
 void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num);
99be8f
+void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num);
99be8f
 void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num);
99be8f
 void jsonw_null_field(json_writer_t *self, const char *prop);
99be8f
+void jsonw_lluint_field(json_writer_t *self, const char *prop,
99be8f
+			unsigned long long int num);
99be8f
+void jsonw_float_field_fmt(json_writer_t *self, const char *prop,
99be8f
+			   const char *fmt, double val);
99be8f
 
99be8f
 /* Collections */
99be8f
 void jsonw_start_object(json_writer_t *self);
99be8f
diff --git a/lib/json_writer.c b/lib/json_writer.c
99be8f
index 9fc05e96b605f..6b77d288cce2b 100644
99be8f
--- a/lib/json_writer.c
99be8f
+++ b/lib/json_writer.c
99be8f
@@ -156,7 +156,7 @@ void jsonw_name(json_writer_t *self, const char *name)
99be8f
 		putc(' ', self->out);
99be8f
 }
99be8f
 
99be8f
-static void jsonw_printf(json_writer_t *self, const char *fmt, ...)
99be8f
+void jsonw_printf(json_writer_t *self, const char *fmt, ...)
99be8f
 {
99be8f
 	va_list ap;
99be8f
 
99be8f
@@ -199,23 +199,38 @@ void jsonw_bool(json_writer_t *self, bool val)
99be8f
 	jsonw_printf(self, "%s", val ? "true" : "false");
99be8f
 }
99be8f
 
99be8f
-#ifdef notused
99be8f
 void jsonw_null(json_writer_t *self)
99be8f
 {
99be8f
 	jsonw_printf(self, "null");
99be8f
 }
99be8f
 
99be8f
+void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num)
99be8f
+{
99be8f
+	jsonw_printf(self, fmt, num);
99be8f
+}
99be8f
+
99be8f
+#ifdef notused
99be8f
 void jsonw_float(json_writer_t *self, double num)
99be8f
 {
99be8f
 	jsonw_printf(self, "%g", num);
99be8f
 }
99be8f
 #endif
99be8f
 
99be8f
+void jsonw_hu(json_writer_t *self, unsigned short num)
99be8f
+{
99be8f
+	jsonw_printf(self, "%hu", num);
99be8f
+}
99be8f
+
99be8f
 void jsonw_uint(json_writer_t *self, uint64_t num)
99be8f
 {
99be8f
 	jsonw_printf(self, "%"PRIu64, num);
99be8f
 }
99be8f
 
99be8f
+void jsonw_lluint(json_writer_t *self, unsigned long long int num)
99be8f
+{
99be8f
+	jsonw_printf(self, "%llu", num);
99be8f
+}
99be8f
+
99be8f
 void jsonw_int(json_writer_t *self, int64_t num)
99be8f
 {
99be8f
 	jsonw_printf(self, "%"PRId64, num);
99be8f
@@ -242,25 +257,46 @@ void jsonw_float_field(json_writer_t *self, const char *prop, double val)
99be8f
 }
99be8f
 #endif
99be8f
 
99be8f
+void jsonw_float_field_fmt(json_writer_t *self,
99be8f
+			   const char *prop,
99be8f
+			   const char *fmt,
99be8f
+			   double val)
99be8f
+{
99be8f
+	jsonw_name(self, prop);
99be8f
+	jsonw_float_fmt(self, fmt, val);
99be8f
+}
99be8f
+
99be8f
 void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num)
99be8f
 {
99be8f
 	jsonw_name(self, prop);
99be8f
 	jsonw_uint(self, num);
99be8f
 }
99be8f
 
99be8f
+void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num)
99be8f
+{
99be8f
+	jsonw_name(self, prop);
99be8f
+	jsonw_hu(self, num);
99be8f
+}
99be8f
+
99be8f
+void jsonw_lluint_field(json_writer_t *self,
99be8f
+			const char *prop,
99be8f
+			unsigned long long int num)
99be8f
+{
99be8f
+	jsonw_name(self, prop);
99be8f
+	jsonw_lluint(self, num);
99be8f
+}
99be8f
+
99be8f
 void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num)
99be8f
 {
99be8f
 	jsonw_name(self, prop);
99be8f
 	jsonw_int(self, num);
99be8f
 }
99be8f
 
99be8f
-#ifdef notused
99be8f
 void jsonw_null_field(json_writer_t *self, const char *prop)
99be8f
 {
99be8f
 	jsonw_name(self, prop);
99be8f
 	jsonw_null(self);
99be8f
 }
99be8f
-#endif
99be8f
 
99be8f
 #ifdef TEST
99be8f
 int main(int argc, char **argv)
99be8f
-- 
d30c09
2.21.0
99be8f