aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-06-11 12:03:13 -0400
committerAnders Broman <a.broman58@gmail.com>2017-06-12 03:23:38 +0000
commit585d17ae7f03d76713cf8ab2959260d19dabc619 (patch)
treeb9d43744966ae757091c7db606604e6e2fd90a6d /epan
parentf4dd096afb6bb7b3ed7f036a9def10a5c27dcd66 (diff)
Add support for color xml attributes in psml and pdml formats.
Bug: 6682 Change-Id: I19330d06aa3d5692503c61369c3c650d595971f5 Reviewed-on: https://code.wireshark.org/review/22077 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stephen Donnelly <stephen.donnelly@endace.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/print.c25
-rw-r--r--epan/print.h4
2 files changed, 23 insertions, 6 deletions
diff --git a/epan/print.c b/epan/print.c
index 074621ae01..d4343aaadb 100644
--- a/epan/print.c
+++ b/epan/print.c
@@ -33,6 +33,7 @@
#include <epan/to_str.h>
#include <epan/expert.h>
#include <epan/column-info.h>
+#include <epan/color_filters.h>
#include <epan/prefs.h>
#include <epan/print.h>
#include <epan/charsets.h>
@@ -298,15 +299,23 @@ static gboolean check_protocolfilter(gchar **protocolfilter, const char *str)
}
void
-write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh)
+write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh, gboolean use_color)
{
write_pdml_data data;
+ const color_filter_t *cfp = edt->pi.fd->color_filter;
g_assert(edt);
g_assert(fh);
/* Create the output */
- fprintf(fh, "<packet>\n");
+ if (use_color && (cfp != NULL)) {
+ fprintf(fh, "<packet foreground='#%02x%02x%02x' background='#%02x%02x%02x'>\n",
+ cfp->fg_color.red, cfp->fg_color.green, cfp->fg_color.blue,
+ cfp->bg_color.red, cfp->bg_color.green, cfp->bg_color.blue);
+ }
+ else {
+ fprintf(fh, "<packet>\n");
+ }
/* Print a "geninfo" protocol as required by PDML */
print_pdml_geninfo(edt, fh);
@@ -1287,11 +1296,19 @@ write_psml_preamble(column_info *cinfo, FILE *fh)
}
void
-write_psml_columns(epan_dissect_t *edt, FILE *fh)
+write_psml_columns(epan_dissect_t *edt, FILE *fh, gboolean use_color)
{
gint i;
+ const color_filter_t *cfp = edt->pi.fd->color_filter;
- fprintf(fh, "<packet>\n");
+ if (use_color && (cfp != NULL)) {
+ fprintf(fh, "<packet foreground='#%02x%02x%02x' background='#%02x%02x%02x'>\n",
+ cfp->fg_color.red, cfp->fg_color.green, cfp->fg_color.blue,
+ cfp->bg_color.red, cfp->bg_color.green, cfp->bg_color.blue);
+ }
+ else {
+ fprintf(fh, "<packet>\n");
+ }
for (i = 0; i < edt->pi.cinfo->num_cols; i++) {
fprintf(fh, "<section>");
diff --git a/epan/print.h b/epan/print.h
index 6dedc30878..bfa2ab482a 100644
--- a/epan/print.h
+++ b/epan/print.h
@@ -92,7 +92,7 @@ WS_DLL_PUBLIC gboolean proto_tree_print(print_dissections_e print_dissections,
WS_DLL_PUBLIC gboolean print_hex_data(print_stream_t *stream, epan_dissect_t *edt);
WS_DLL_PUBLIC void write_pdml_preamble(FILE *fh, const gchar* filename);
-WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh);
+WS_DLL_PUBLIC void write_pdml_proto_tree(output_fields_t* fields, gchar **protocolfilter, pf_flags protocolfilter_flags, epan_dissect_t *edt, FILE *fh, gboolean use_color);
WS_DLL_PUBLIC void write_pdml_finale(FILE *fh);
WS_DLL_PUBLIC void write_json_preamble(FILE *fh);
@@ -111,7 +111,7 @@ WS_DLL_PUBLIC void write_ek_proto_tree(output_fields_t* fields,
epan_dissect_t *edt, FILE *fh);
WS_DLL_PUBLIC void write_psml_preamble(column_info *cinfo, FILE *fh);
-WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh);
+WS_DLL_PUBLIC void write_psml_columns(epan_dissect_t *edt, FILE *fh, gboolean use_color);
WS_DLL_PUBLIC void write_psml_finale(FILE *fh);
WS_DLL_PUBLIC void write_csv_column_titles(column_info *cinfo, FILE *fh);