From b157a5d80c683da26e242eab398109b9b4ef785b Mon Sep 17 00:00:00 2001 From: Jim Young Date: Sun, 19 Mar 2017 00:37:30 -0500 Subject: capinfos: Ensure empty columns are written in -T reports. When using capinfo's -T report insure that proper placeholders are written to the records if any of the optional pcapng SHB block values are missing so as to maintain column alignment with the header record. Augment the comments about the potential silliness regarding the dumping of pcapng comments in capinfos -T reports. Change-Id: I43df4aeed2235f7ed9c67519c249361ab00680f1 Reviewed-on: https://code.wireshark.org/review/20613 Petri-Dish: Jim Young Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- capinfos.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'capinfos.c') diff --git a/capinfos.c b/capinfos.c index 896728aea2..a2b869e2cc 100644 --- a/capinfos.c +++ b/capinfos.c @@ -976,41 +976,56 @@ print_stats_table(const gchar *filename, capture_info *cf_info) /* * this is silly to put into a table format, but oh well * note that there may be *more than one* of each of these types - * of options + * of options. To mitigate some of the potential silliness should + * the if(cap_comment) block be moved AFTER the if(cap_file_more_info) + * block? That would make any comments the last item(s) in each row. + * And/or should we add an cli option to inhibit the cap_comment to + * more easily manage the potential silliness? Potential silliness + * includes multiple comments and/or comments with embeded newlines. */ if (cap_comment) { unsigned int i; char *opt_comment; + gboolean have_cap = FALSE; for (i = 0; wtap_block_get_nth_string_option_value(cf_info->shb, OPT_COMMENT, i, &opt_comment) == WTAP_OPTTYPE_SUCCESS; i++) { + have_cap = TRUE; putsep(); putquote(); printf("%s", opt_comment); putquote(); } + if(!have_cap) { + /* Maintain column alignment when we have no OPT_COMMENT */ + putsep(); + putquote(); + putquote(); + } } if (cap_file_more_info) { char *str; + putsep(); + putquote(); if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS) { - putsep(); - putquote(); printf("%s", str); - putquote(); } + putquote(); + + putsep(); + putquote(); if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS) { - putsep(); - putquote(); printf("%s", str); - putquote(); } + putquote(); + + putsep(); + putquote(); if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS) { - putsep(); - putquote(); printf("%s", str); - putquote(); } + putquote(); } } -- cgit v1.2.1