]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - lib/json_writer.c
bridge: fdb: add support for src_vni option
[mirror_iproute2.git] / lib / json_writer.c
index 0ad042188ab9406683465270cc351caddf0b18fa..5004c181e6225bb2e4e3aba4859ee7ebce42445d 100644 (file)
@@ -152,6 +152,7 @@ void jsonw_name(json_writer_t *self, const char *name)
                putc(' ', self->out);
 }
 
+__attribute__((format(printf, 2, 3)))
 void jsonw_printf(json_writer_t *self, const char *fmt, ...)
 {
        va_list ap;
@@ -205,14 +206,14 @@ void jsonw_null(json_writer_t *self)
        jsonw_printf(self, "null");
 }
 
-void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num)
+void jsonw_float(json_writer_t *self, double num)
 {
-       jsonw_printf(self, fmt, num);
+       jsonw_printf(self, "%g", num);
 }
 
-void jsonw_float(json_writer_t *self, double num)
+void jsonw_hhu(json_writer_t *self, unsigned char num)
 {
-       jsonw_printf(self, "%g", num);
+       jsonw_printf(self, "%hhu", num);
 }
 
 void jsonw_hu(json_writer_t *self, unsigned short num)
@@ -220,7 +221,12 @@ void jsonw_hu(json_writer_t *self, unsigned short num)
        jsonw_printf(self, "%hu", num);
 }
 
-void jsonw_uint(json_writer_t *self, uint64_t num)
+void jsonw_uint(json_writer_t *self, unsigned int num)
+{
+       jsonw_printf(self, "%u", num);
+}
+
+void jsonw_u64(json_writer_t *self, uint64_t num)
 {
        jsonw_printf(self, "%"PRIu64, num);
 }
@@ -230,12 +236,22 @@ void jsonw_xint(json_writer_t *self, uint64_t num)
        jsonw_printf(self, "%"PRIx64, num);
 }
 
-void jsonw_lluint(json_writer_t *self, unsigned long long int num)
+void jsonw_luint(json_writer_t *self, unsigned long num)
+{
+       jsonw_printf(self, "%lu", num);
+}
+
+void jsonw_lluint(json_writer_t *self, unsigned long long num)
 {
        jsonw_printf(self, "%llu", num);
 }
 
-void jsonw_int(json_writer_t *self, int64_t num)
+void jsonw_int(json_writer_t *self, int num)
+{
+       jsonw_printf(self, "%d", num);
+}
+
+void jsonw_s64(json_writer_t *self, int64_t num)
 {
        jsonw_printf(self, "%"PRId64, num);
 }
@@ -259,19 +275,16 @@ void jsonw_float_field(json_writer_t *self, const char *prop, double val)
        jsonw_float(self, val);
 }
 
-void jsonw_float_field_fmt(json_writer_t *self,
-                          const char *prop,
-                          const char *fmt,
-                          double val)
+void jsonw_uint_field(json_writer_t *self, const char *prop, unsigned int num)
 {
        jsonw_name(self, prop);
-       jsonw_float_fmt(self, fmt, val);
+       jsonw_uint(self, num);
 }
 
-void jsonw_uint_field(json_writer_t *self, const char *prop, uint64_t num)
+void jsonw_u64_field(json_writer_t *self, const char *prop, uint64_t num)
 {
        jsonw_name(self, prop);
-       jsonw_uint(self, num);
+       jsonw_u64(self, num);
 }
 
 void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num)
@@ -280,26 +293,46 @@ void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num)
        jsonw_xint(self, num);
 }
 
+void jsonw_hhu_field(json_writer_t *self, const char *prop, unsigned char num)
+{
+       jsonw_name(self, prop);
+       jsonw_hhu(self, num);
+}
+
 void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num)
 {
        jsonw_name(self, prop);
        jsonw_hu(self, num);
 }
 
+void jsonw_luint_field(json_writer_t *self,
+                       const char *prop,
+                       unsigned long num)
+{
+       jsonw_name(self, prop);
+       jsonw_luint(self, num);
+}
+
 void jsonw_lluint_field(json_writer_t *self,
                        const char *prop,
-                       unsigned long long int num)
+                       unsigned long long num)
 {
        jsonw_name(self, prop);
        jsonw_lluint(self, num);
 }
 
-void jsonw_int_field(json_writer_t *self, const char *prop, int64_t num)
+void jsonw_int_field(json_writer_t *self, const char *prop, int num)
 {
        jsonw_name(self, prop);
        jsonw_int(self, num);
 }
 
+void jsonw_s64_field(json_writer_t *self, const char *prop, int64_t num)
+{
+       jsonw_name(self, prop);
+       jsonw_s64(self, num);
+}
+
 void jsonw_null_field(json_writer_t *self, const char *prop)
 {
        jsonw_name(self, prop);