From d35efba99d9221d9fe1715a23247ad9b703544ec Mon Sep 17 00:00:00 2001 From: Quentin Monnet Date: Mon, 23 Oct 2017 09:24:07 -0700 Subject: tools: bpftool: introduce --json and --pretty options These two options can be used to ask for a JSON output (--j or -json), and to make this JSON human-readable (-p or --pretty). A json_writer object is created when JSON is required, and will be used in follow-up commits to produce JSON output. Note that --pretty implies --json. Update for the manual pages and interactive help messages comes in a later patch of the series. Signed-off-by: Quentin Monnet Acked-by: Daniel Borkmann Signed-off-by: David S. Miller --- tools/bpf/bpftool/main.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tools/bpf/bpftool/main.h') diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h index 41e6c7d3fcad..15927fc9fb31 100644 --- a/tools/bpf/bpftool/main.h +++ b/tools/bpf/bpftool/main.h @@ -43,6 +43,8 @@ #include #include +#include "json_writer.h" + #define err(msg...) fprintf(stderr, "Error: " msg) #define warn(msg...) fprintf(stderr, "Warning: " msg) #define info(msg...) fprintf(stderr, msg) @@ -66,6 +68,9 @@ enum bpf_obj_type { extern const char *bin_name; +extern json_writer_t *json_wtr; +extern bool json_output; + bool is_prefix(const char *pfx, const char *str); void fprint_hex(FILE *f, void *arg, unsigned int n, const char *sep); void usage(void) __attribute__((noreturn)); -- cgit v1.2.1