diff options
author | Pascal Quantin <pascal.quantin@gmail.com> | 2016-10-31 23:02:44 +0100 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-11-02 01:13:57 +0000 |
commit | b0eac84840567f2e535faf01816e3c1a87473213 (patch) | |
tree | 90d7e89245f6cf4baed8abfbc40c84cee04235bc | |
parent | 9ff6bb28d2d0d88d43b53e913cc9b3b6bbecbd3d (diff) |
Small fixes for JSON output
- reinitialize the variable used to insert comma between packets when
performing a new export
- ensure that escaped ASCII characters are code on 4 digits characters
Change-Id: Ib557da4843f6b98f793b60e417260ebb27a38b99
Ping-Bug: 13073
Reviewed-on: https://code.wireshark.org/review/18598
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r-- | epan/print.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/epan/print.c b/epan/print.c index f365f0ed94..5e82740eeb 100644 --- a/epan/print.c +++ b/epan/print.c @@ -109,6 +109,8 @@ static void print_pdml_geninfo(epan_dissect_t *edt, FILE *fh); static void proto_tree_get_node_field_values(proto_node *node, gpointer data); +static gboolean json_is_first; + /* Cache the protocols and field handles that the print functionality needs This helps break explicit dependency on the dissectors. */ static int proto_data = -1; @@ -274,6 +276,7 @@ void write_json_preamble(FILE *fh) { fputs("[\n", fh); + json_is_first = TRUE; } /* Check if the str match the protocolfilter. json_filter is space @@ -335,7 +338,6 @@ write_json_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar * char ts[30]; time_t t = time(NULL); struct tm * timeinfo; - static gboolean is_first = TRUE; g_assert(edt); g_assert(fh); @@ -347,10 +349,10 @@ write_json_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar * else g_strlcpy(ts, "XXXX-XX-XX", sizeof ts); /* XXX - better way of saying "Not representable"? */ - if (!is_first) + if (!json_is_first) fputs(" ,\n", fh); else - is_first = FALSE; + json_is_first = FALSE; fputs(" {\n", fh); fprintf(fh, " \"_index\": \"packets-%s\",\n", ts); @@ -1477,7 +1479,7 @@ print_escaped_bare(FILE *fh, const char *unescaped_string, gboolean change_dot) if (g_ascii_isprint(*p)) fputc(*p, fh); else { - g_snprintf(temp_str, sizeof(temp_str), "\\u00%u", (guint8)*p); + g_snprintf(temp_str, sizeof(temp_str), "\\u00%02x", (guint8)*p); fputs(temp_str, fh); } } |