]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - lib/json_print.c
Tree wide: Drop sockaddr_nl arg
[mirror_iproute2.git] / lib / json_print.c
index bda7293350c33907c64ce3ad8fcbbf4d0f73e5ee..f7ef41c1570f2a72eacd213e278193036b3dc561 100644 (file)
@@ -100,6 +100,7 @@ void close_json_array(enum output_type type, const char *str)
  * functions handling different types
  */
 #define _PRINT_FUNC(type_name, type)                                   \
+       __attribute__((format(printf, 4, 0)))                           \
        void print_color_##type_name(enum output_type t,                \
                                     enum color_attr color,             \
                                     const char *key,                   \
@@ -116,8 +117,11 @@ void close_json_array(enum output_type type, const char *str)
                }                                                       \
        }
 _PRINT_FUNC(int, int);
+_PRINT_FUNC(s64, int64_t);
 _PRINT_FUNC(hu, unsigned short);
-_PRINT_FUNC(uint, uint64_t);
+_PRINT_FUNC(uint, unsigned int);
+_PRINT_FUNC(u64, uint64_t);
+_PRINT_FUNC(luint, unsigned long int);
 _PRINT_FUNC(lluint, unsigned long long int);
 _PRINT_FUNC(float, double);
 #undef _PRINT_FUNC
@@ -168,12 +172,12 @@ void print_color_0xhex(enum output_type type,
                       enum color_attr color,
                       const char *key,
                       const char *fmt,
-                      unsigned int hex)
+                      unsigned long long hex)
 {
        if (_IS_JSON_CONTEXT(type)) {
                SPRINT_BUF(b1);
 
-               snprintf(b1, sizeof(b1), "%#x", hex);
+               snprintf(b1, sizeof(b1), "%#llx", hex);
                print_string(PRINT_JSON, key, NULL, b1);
        } else if (_IS_FP_CONTEXT(type)) {
                color_fprintf(stdout, color, fmt, hex);
@@ -218,3 +222,10 @@ void print_color_null(enum output_type type,
                color_fprintf(stdout, color, fmt, value);
        }
 }
+
+/* Print line seperator (if not in JSON mode) */
+void print_nl(void)
+{
+       if (!_jw)
+               printf("%s", _SL_);
+}