0001
0002
0003
0004 #ifndef _NETLINK_DUMPER_H_
0005 #define _NETLINK_DUMPER_H_
0006
0007 #define NET_START_OBJECT \
0008 { \
0009 if (json_output) \
0010 jsonw_start_object(json_wtr); \
0011 }
0012
0013 #define NET_START_OBJECT_NESTED(name) \
0014 { \
0015 if (json_output) { \
0016 jsonw_name(json_wtr, name); \
0017 jsonw_start_object(json_wtr); \
0018 } else { \
0019 fprintf(stdout, "%s {", name); \
0020 } \
0021 }
0022
0023 #define NET_START_OBJECT_NESTED2 \
0024 { \
0025 if (json_output) \
0026 jsonw_start_object(json_wtr); \
0027 else \
0028 fprintf(stdout, "{"); \
0029 }
0030
0031 #define NET_END_OBJECT_NESTED \
0032 { \
0033 if (json_output) \
0034 jsonw_end_object(json_wtr); \
0035 else \
0036 fprintf(stdout, "}"); \
0037 }
0038
0039 #define NET_END_OBJECT \
0040 { \
0041 if (json_output) \
0042 jsonw_end_object(json_wtr); \
0043 }
0044
0045 #define NET_END_OBJECT_FINAL \
0046 { \
0047 if (json_output) \
0048 jsonw_end_object(json_wtr); \
0049 else \
0050 fprintf(stdout, "\n"); \
0051 }
0052
0053 #define NET_START_ARRAY(name, fmt_str) \
0054 { \
0055 if (json_output) { \
0056 jsonw_name(json_wtr, name); \
0057 jsonw_start_array(json_wtr); \
0058 } else { \
0059 fprintf(stdout, fmt_str, name); \
0060 } \
0061 }
0062
0063 #define NET_END_ARRAY(endstr) \
0064 { \
0065 if (json_output) \
0066 jsonw_end_array(json_wtr); \
0067 else \
0068 fprintf(stdout, "%s", endstr); \
0069 }
0070
0071 #define NET_DUMP_UINT(name, fmt_str, val) \
0072 { \
0073 if (json_output) \
0074 jsonw_uint_field(json_wtr, name, val); \
0075 else \
0076 fprintf(stdout, fmt_str, val); \
0077 }
0078
0079 #define NET_DUMP_STR(name, fmt_str, str) \
0080 { \
0081 if (json_output) \
0082 jsonw_string_field(json_wtr, name, str);\
0083 else \
0084 fprintf(stdout, fmt_str, str); \
0085 }
0086
0087 #define NET_DUMP_STR_ONLY(str) \
0088 { \
0089 if (json_output) \
0090 jsonw_string(json_wtr, str); \
0091 else \
0092 fprintf(stdout, "%s ", str); \
0093 }
0094
0095 #endif