aboutsummaryrefslogtreecommitdiffstats
path: root/capinfos.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-05-28 12:33:50 -0700
committerGuy Harris <guy@alum.mit.edu>2016-05-28 19:35:26 +0000
commit6f31a042783576f814ddfcbc79ab84f4ff5ed7c7 (patch)
treea9f2fda2833dd33eacd64010783b421fbfd912f3 /capinfos.c
parentda8a6691e31b37c88f9cd658e27cafa1b6c5d92c (diff)
More use of wtap_optionblock_foreach_option().
Change-Id: I5c0eb9f399e00580d8fc25c5e164b7b67353655f Reviewed-on: https://code.wireshark.org/review/15602 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'capinfos.c')
-rw-r--r--capinfos.c109
1 files changed, 86 insertions, 23 deletions
diff --git a/capinfos.c b/capinfos.c
index 708b4ab038..c42de61022 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -765,7 +765,7 @@ print_stats(const gchar *filename, capture_info *cf_info)
}
#endif /* HAVE_LIBGCRYPT */
if (cap_order) printf ("Strict time order: %s\n", order_string(cf_info->order));
-
+
if (cap_comment) {
wtap_optionblock_foreach_option(cf_info->shb, show_comment, NULL);
}
@@ -851,10 +851,85 @@ print_stats_table_header(void)
}
static void
+put_comment(wtap_optionblock_t block _U_, guint option_id, wtap_opttype_e option_type _U_, wtap_option_type* option, void* user_data _U_)
+{
+ switch(option_id)
+ {
+ case OPT_COMMENT:
+ if (option != NULL && option->stringval != NULL) {
+ putsep();
+ putquote();
+ printf("%s", option->stringval);
+ putquote();
+ }
+ break;
+ default:
+ /* Don't show other options */
+ break;
+ }
+}
+
+static void
+put_capture_hardware(wtap_optionblock_t block _U_, guint option_id, wtap_opttype_e option_type _U_, wtap_option_type* option, void* user_data _U_)
+{
+ switch(option_id)
+ {
+ case OPT_SHB_HARDWARE:
+ if (option != NULL && option->stringval != NULL) {
+ putsep();
+ putquote();
+ printf("%s", option->stringval);
+ putquote();
+ }
+ break;
+ default:
+ /* Don't show other options */
+ break;
+ }
+}
+
+static void
+put_capture_os(wtap_optionblock_t block _U_, guint option_id, wtap_opttype_e option_type _U_, wtap_option_type* option, void* user_data _U_)
+{
+ switch(option_id)
+ {
+ case OPT_SHB_OS:
+ if (option != NULL && option->stringval != NULL) {
+ putsep();
+ putquote();
+ printf("%s", option->stringval);
+ putquote();
+ }
+ break;
+ default:
+ /* Don't show other options */
+ break;
+ }
+}
+
+static void
+put_capture_userappl(wtap_optionblock_t block _U_, guint option_id, wtap_opttype_e option_type _U_, wtap_option_type* option, void* user_data _U_)
+{
+ switch(option_id)
+ {
+ case OPT_SHB_USERAPPL:
+ if (option != NULL && option->stringval != NULL) {
+ putsep();
+ putquote();
+ printf("%s", option->stringval);
+ putquote();
+ }
+ break;
+ default:
+ /* Don't show other options */
+ break;
+ }
+}
+
+static void
print_stats_table(const gchar *filename, capture_info *cf_info)
{
const gchar *file_type_string, *file_encap_string;
- gchar *str;
/* Build printable strings for various stats */
file_type_string = wtap_file_type_subtype_string(cf_info->file_type);
@@ -1027,33 +1102,21 @@ print_stats_table(const gchar *filename, capture_info *cf_info)
putquote();
}
- /* this is silly to put into a table format, but oh well */
+ /*
+ * 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
+ */
if (cap_comment) {
- putsep();
- putquote();
- wtap_optionblock_get_option_string(cf_info->shb, OPT_COMMENT, &str);
- printf("%s", str);
- putquote();
+ wtap_optionblock_foreach_option(cf_info->shb, put_comment, NULL);
}
if (cap_file_more_info) {
- putsep();
- putquote();
- wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_HARDWARE, &str);
- printf("%s", str);
- putquote();
+ wtap_optionblock_foreach_option(cf_info->shb, put_capture_hardware, NULL);
- putsep();
- putquote();
- wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_OS, &str);
- printf("%s", str);
- putquote();
+ wtap_optionblock_foreach_option(cf_info->shb, put_capture_os, NULL);
- putsep();
- putquote();
- wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_USERAPPL, &str);
- printf("%s", str);
- putquote();
+ wtap_optionblock_foreach_option(cf_info->shb, put_capture_userappl, NULL);
}
printf("\n");