From 0553cda6dab3f69ccd32adb6d60723e9baf56d4a Mon Sep 17 00:00:00 2001 From: Jakub Zawadzki Date: Wed, 27 Sep 2017 22:03:43 +0200 Subject: [PATCH] Instroduce col_finalize(), to allow creating column_info based not only on preferences. Change-Id: I417e6accff3390a9b1839cd6b44266b76aa754c3 Reviewed-on: https://code.wireshark.org/review/23767 Petri-Dish: Jakub Zawadzki Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/column.c | 37 ++++++++++++++++++++++++++----------- epan/column.h | 4 ++++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/epan/column.c b/epan/column.c index 6d4fa62d3b..1851dbf55e 100644 --- a/epan/column.c +++ b/epan/column.c @@ -808,22 +808,15 @@ get_column_tooltip(const gint col) } void -build_column_format_array(column_info *cinfo, const gint num_cols, const gboolean reset_fences) +col_finalize(column_info *cinfo) { int i; col_item_t* col_item; - /* Build the column format array */ - col_setup(cinfo, num_cols); - for (i = 0; i < cinfo->num_cols; i++) { col_item = &cinfo->columns[i]; - col_item->col_fmt = get_column_format(i); - col_item->col_title = g_strdup(get_column_title(i)); if (col_item->col_fmt == COL_CUSTOM) { - col_item->col_custom_fields = g_strdup(get_column_custom_fields(i)); - col_item->col_custom_occurrence = get_column_custom_occurrence(i); if(!dfilter_compile(col_item->col_custom_fields, &col_item->col_custom_dfilter, NULL)) { /* XXX: Should we issue a warning? */ g_free(col_item->col_custom_fields); @@ -863,9 +856,6 @@ build_column_format_array(column_info *cinfo, const gint num_cols, const gboolea else col_item->col_buf = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); - if(reset_fences) - col_item->col_fence = 0; - cinfo->col_expr.col_expr[i] = ""; cinfo->col_expr.col_expr_val[i] = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN); } @@ -888,6 +878,31 @@ build_column_format_array(column_info *cinfo, const gint num_cols, const gboolea } } +void +build_column_format_array(column_info *cinfo, const gint num_cols, const gboolean reset_fences) +{ + int i; + col_item_t* col_item; + + /* Build the column format array */ + col_setup(cinfo, num_cols); + + for (i = 0; i < cinfo->num_cols; i++) { + col_item = &cinfo->columns[i]; + col_item->col_fmt = get_column_format(i); + col_item->col_title = g_strdup(get_column_title(i)); + if (col_item->col_fmt == COL_CUSTOM) { + col_item->col_custom_fields = g_strdup(get_column_custom_fields(i)); + col_item->col_custom_occurrence = get_column_custom_occurrence(i); + } + + if(reset_fences) + col_item->col_fence = 0; + } + + col_finalize(cinfo); +} + /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/epan/column.h b/epan/column.h index 365652e2e4..04a219a71f 100644 --- a/epan/column.h +++ b/epan/column.h @@ -78,6 +78,10 @@ gint get_column_char_width(const gint format); WS_DLL_PUBLIC gchar *get_column_tooltip(const gint col); +WS_DLL_PUBLIC +void +col_finalize(column_info *cinfo); + WS_DLL_PUBLIC void build_column_format_array(column_info *cinfo, const gint num_cols, const gboolean reset_fences);