]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
json: add %hhu helpers
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 19 Nov 2018 23:03:29 +0000 (15:03 -0800)
committerDavid Ahern <dsahern@gmail.com>
Sat, 24 Nov 2018 15:09:53 +0000 (07:09 -0800)
Add helpers for printing char-size values.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
include/json_print.h
include/json_writer.h
lib/json_print.c
lib/json_writer.c

index 218da31a73fe876321b2a9aac7a5f741d3fb586d..25954070db27117f88d4f1e8533ff1b4ba768a45 100644 (file)
@@ -64,6 +64,7 @@ _PRINT_FUNC(null, const char*);
 _PRINT_FUNC(string, const char*);
 _PRINT_FUNC(uint, unsigned int);
 _PRINT_FUNC(u64, uint64_t);
+_PRINT_FUNC(hhu, unsigned char);
 _PRINT_FUNC(hu, unsigned short);
 _PRINT_FUNC(hex, unsigned int);
 _PRINT_FUNC(0xhex, unsigned long long int);
index 0c8831c1136df2bcefca9febcc31ceeb5b672c89..354c27541e896128978ca8f2fa9ea16bb2f341a1 100644 (file)
@@ -38,6 +38,7 @@ void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num);
 void jsonw_uint(json_writer_t *self, unsigned int number);
 void jsonw_u64(json_writer_t *self, uint64_t number);
 void jsonw_xint(json_writer_t *self, uint64_t number);
+void jsonw_hhu(json_writer_t *self, unsigned char num);
 void jsonw_hu(json_writer_t *self, unsigned short number);
 void jsonw_int(json_writer_t *self, int number);
 void jsonw_s64(json_writer_t *self, int64_t number);
@@ -52,6 +53,7 @@ void jsonw_float_field(json_writer_t *self, const char *prop, double num);
 void jsonw_uint_field(json_writer_t *self, const char *prop, unsigned int num);
 void jsonw_u64_field(json_writer_t *self, const char *prop, uint64_t num);
 void jsonw_xint_field(json_writer_t *self, const char *prop, uint64_t num);
+void jsonw_hhu_field(json_writer_t *self, const char *prop, unsigned char num);
 void jsonw_hu_field(json_writer_t *self, const char *prop, unsigned short num);
 void jsonw_int_field(json_writer_t *self, const char *prop, int num);
 void jsonw_s64_field(json_writer_t *self, const char *prop, int64_t num);
index f7ef41c1570f2a72eacd213e278193036b3dc561..4f5fef195fdede3dced6254b0267bc82bd0df6ec 100644 (file)
@@ -118,6 +118,7 @@ void close_json_array(enum output_type type, const char *str)
        }
 _PRINT_FUNC(int, int);
 _PRINT_FUNC(s64, int64_t);
+_PRINT_FUNC(hhu, unsigned char);
 _PRINT_FUNC(hu, unsigned short);
 _PRINT_FUNC(uint, unsigned int);
 _PRINT_FUNC(u64, uint64_t);
index 68890b34ee92f583ee9eb8497bcb7156adf14748..46eff6ad98289edfe716bdabe2d1f9fad61fee6d 100644 (file)
@@ -211,6 +211,11 @@ void jsonw_float(json_writer_t *self, double num)
        jsonw_printf(self, "%g", num);
 }
 
+void jsonw_hhu(json_writer_t *self, unsigned char num)
+{
+       jsonw_printf(self, "%hhu", num);
+}
+
 void jsonw_hu(json_writer_t *self, unsigned short num)
 {
        jsonw_printf(self, "%hu", num);
@@ -288,6 +293,12 @@ 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);