diff options
author | Benjamin Poirier <bpoirier@cumulusnetworks.com> | 2020-05-01 17:47:18 +0900 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2020-05-04 17:13:53 -0700 |
commit | 5a07a5df5a4793c2ee2bf93ced638268053e5a19 (patch) | |
tree | b628f038e792e13823417817d4f5afd3dd5af171 /include | |
parent | b262a9becbcb9d0816b7953fd223dd9a7add8e12 (diff) |
json_print: Return number of characters printed
When outputting in normal mode, forward the return value from
color_fprintf().
Signed-off-by: Benjamin Poirier <bpoirier@cumulusnetworks.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/json_print.h | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/include/json_print.h b/include/json_print.h index 34444793..50e71de4 100644 --- a/include/json_print.h +++ b/include/json_print.h @@ -44,20 +44,24 @@ void close_json_array(enum output_type type, const char *delim); void print_nl(void); #define _PRINT_FUNC(type_name, type) \ - void print_color_##type_name(enum output_type t, \ - enum color_attr color, \ - const char *key, \ - const char *fmt, \ - type value); \ + int print_color_##type_name(enum output_type t, \ + enum color_attr color, \ + const char *key, \ + const char *fmt, \ + type value); \ \ - static inline void print_##type_name(enum output_type t, \ - const char *key, \ - const char *fmt, \ - type value) \ + static inline int print_##type_name(enum output_type t, \ + const char *key, \ + const char *fmt, \ + type value) \ { \ - print_color_##type_name(t, COLOR_NONE, key, fmt, value); \ + return print_color_##type_name(t, COLOR_NONE, key, fmt, \ + value); \ } +/* These functions return 0 if printing to a JSON context, number of + * characters printed otherwise (as calculated by printf(3)). + */ _PRINT_FUNC(int, int) _PRINT_FUNC(s64, int64_t) _PRINT_FUNC(bool, bool) |