diff options
Diffstat (limited to 'epan/column-utils.c')
-rw-r--r-- | epan/column-utils.c | 451 |
1 files changed, 235 insertions, 216 deletions
diff --git a/epan/column-utils.c b/epan/column-utils.c index 581f5e6078..33eaa1f2ed 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -50,21 +50,12 @@ col_setup(column_info *cinfo, const gint num_cols) int i; cinfo->num_cols = num_cols; - cinfo->col_fmt = g_new(gint, num_cols); - cinfo->fmt_matx = g_new(gboolean*, num_cols); + cinfo->columns = g_new(col_item_t, num_cols); cinfo->col_first = g_new(int, NUM_COL_FMTS); cinfo->col_last = g_new(int, NUM_COL_FMTS); - cinfo->col_title = g_new(gchar*, num_cols); - cinfo->col_custom_field = g_new(gchar*, num_cols); - cinfo->col_custom_occurrence = g_new(gint, num_cols); - cinfo->col_custom_field_ids = g_new(GSList *, num_cols); for (i = 0; i < num_cols; i++) { - cinfo->col_custom_field_ids[i] = NULL; + cinfo->columns[i].col_custom_field_ids = NULL; } - cinfo->col_custom_dfilter = g_new(struct epan_dfilter*, num_cols); - cinfo->col_data = g_new(const gchar*, num_cols); - cinfo->col_buf = g_new(gchar*, num_cols); - cinfo->col_fence = g_new(int, num_cols); cinfo->col_expr.col_expr = g_new(const gchar*, num_cols + 1); cinfo->col_expr.col_expr_val = g_new(gchar*, num_cols + 1); @@ -81,13 +72,13 @@ col_custom_ids_free_wrapper(gpointer data, gpointer user_data _U_) } static void -col_custom_field_ids_free(column_info *cinfo, int col) +col_custom_field_ids_free(GSList** custom_field_id) { - if (cinfo->col_custom_field_ids[col] != NULL) { - g_slist_foreach(cinfo->col_custom_field_ids[col], col_custom_ids_free_wrapper, NULL); - g_slist_free(cinfo->col_custom_field_ids[col]); + if (*custom_field_id != NULL) { + g_slist_foreach(*custom_field_id, col_custom_ids_free_wrapper, NULL); + g_slist_free(*custom_field_id); } - cinfo->col_custom_field_ids[col] = NULL; + *custom_field_id = NULL; } /* Cleanup all the data structures for constructing column data; undoes @@ -96,26 +87,23 @@ void col_cleanup(column_info *cinfo) { int i; + col_item_t* col_item; for (i = 0; i < cinfo->num_cols; i++) { - g_free(cinfo->fmt_matx[i]); - g_free(cinfo->col_title[i]); - g_free(cinfo->col_custom_field[i]); - dfilter_free(cinfo->col_custom_dfilter[i]); - g_free(cinfo->col_buf[i]); + col_item = &cinfo->columns[i]; + g_free(col_item->fmt_matx); + g_free(col_item->col_title); + g_free(col_item->col_custom_field); + dfilter_free(col_item->col_custom_dfilter); + g_free((gchar*)col_item->col_data); + g_free(col_item->col_buf); g_free(cinfo->col_expr.col_expr_val[i]); - col_custom_field_ids_free(cinfo, i); + col_custom_field_ids_free(&col_item->col_custom_field_ids); } - g_free(cinfo->col_fmt); - g_free(cinfo->fmt_matx); + g_free(cinfo->columns); g_free(cinfo->col_first); g_free(cinfo->col_last); - g_free(cinfo->col_title); - g_free(cinfo->col_custom_field); - g_free(cinfo->col_custom_occurrence); - g_free(cinfo->col_custom_field_ids); - g_free(cinfo->col_custom_dfilter); /* * XXX - MSVC doesn't correctly handle the "const" qualifier; it thinks * "const XXX **" means "pointer to const pointer to XXX", i.e. that @@ -123,10 +111,6 @@ col_cleanup(column_info *cinfo) * pointer to const XXX", i.e. that it's a pointer to a pointer to * something that's "const"ant. Cast its bogus complaints away. */ - g_free((gchar **)cinfo->col_data); - g_free(cinfo->col_buf); - g_free(cinfo->col_fence); - /* XXX - see above */ g_free((gchar **)cinfo->col_expr.col_expr); g_free(cinfo->col_expr.col_expr_val); } @@ -136,14 +120,16 @@ void col_init(column_info *cinfo, const struct epan_session *epan) { int i; + col_item_t* col_item; if (!cinfo) return; for (i = 0; i < cinfo->num_cols; i++) { - cinfo->col_buf[i][0] = '\0'; - cinfo->col_data[i] = cinfo->col_buf[i]; - cinfo->col_fence[i] = 0; + col_item = &cinfo->columns[i]; + col_item->col_buf[0] = '\0'; + col_item->col_data = col_item->col_buf; + col_item->col_fence = 0; cinfo->col_expr.col_expr[i] = ""; cinfo->col_expr.col_expr_val[i][0] = '\0'; } @@ -178,13 +164,15 @@ void col_set_fence(column_info *cinfo, const gint el) { int i; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - cinfo->col_fence[i] = (int)strlen(cinfo->col_data[i]); + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + col_item->col_fence = (int)strlen(col_item->col_data); } } } @@ -194,13 +182,15 @@ void col_clear_fence(column_info *cinfo, const gint el) { int i; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - cinfo->col_fence[i] = 0; + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + col_item->col_fence = 0; } } } @@ -211,14 +201,16 @@ col_get_text(column_info *cinfo, const gint el) { int i; const gchar* text = NULL; + col_item_t* col_item; if (!(cinfo && (cinfo)->col_first[el] >= 0)) { return NULL; } for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - text = (cinfo->col_data[i]); + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + text = (col_item->col_data); } } return text; @@ -235,13 +227,14 @@ void col_clear(column_info *cinfo, const gint el) { int i; - int fence; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { /* * At this point, either * @@ -258,14 +251,13 @@ col_clear(column_info *cinfo, const gint el) * going to clear the column, and if it's at the end, * we don't do anything. */ - fence = cinfo->col_fence[i]; - if (cinfo->col_buf[i] == cinfo->col_data[i] || fence == 0) { + if (col_item->col_buf == col_item->col_data || col_item->col_fence == 0) { /* * The fence isn't at the end of the column, or the column wasn't * last set with "col_set_str()", so clear the column out. */ - cinfo->col_buf[i][fence] = '\0'; - cinfo->col_data[i] = cinfo->col_buf[i]; + col_item->col_buf[col_item->col_fence] = '\0'; + col_item->col_data = col_item->col_buf; } cinfo->col_expr.col_expr[i] = ""; cinfo->col_expr.col_expr_val[i][0] = '\0'; @@ -273,12 +265,12 @@ col_clear(column_info *cinfo, const gint el) } } -#define COL_CHECK_APPEND(cinfo, i, max_len) \ - if (cinfo->col_data[i] != cinfo->col_buf[i]) { \ +#define COL_CHECK_APPEND(col_item, max_len) \ + if (col_item->col_data != col_item->col_buf) { \ /* This was set with "col_set_str()"; copy the string they \ set it to into the buffer, so we can append to it. */ \ - g_strlcpy(cinfo->col_buf[i], cinfo->col_data[i], max_len); \ - cinfo->col_data[i] = cinfo->col_buf[i]; \ + g_strlcpy(col_item->col_buf, col_item->col_data, max_len); \ + col_item->col_data = col_item->col_buf; \ } #define COL_CHECK_REF_TIME(fd, buf) \ @@ -300,19 +292,21 @@ have_custom_cols(column_info *cinfo) void col_custom_set_edt(epan_dissect_t *edt, column_info *cinfo) { int i; + col_item_t* col_item; if (!HAVE_CUSTOM_COLS(cinfo)) return; for (i = cinfo->col_first[COL_CUSTOM]; i <= cinfo->col_last[COL_CUSTOM]; i++) { - if (cinfo->fmt_matx[i][COL_CUSTOM] && - cinfo->col_custom_field[i] && - cinfo->col_custom_field_ids[i]) { - cinfo->col_data[i] = cinfo->col_buf[i]; - cinfo->col_expr.col_expr[i] = epan_custom_set(edt, cinfo->col_custom_field_ids[i], - cinfo->col_custom_occurrence[i], - cinfo->col_buf[i], + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[COL_CUSTOM] && + col_item->col_custom_field && + col_item->col_custom_field_ids) { + col_item->col_data = col_item->col_buf; + cinfo->col_expr.col_expr[i] = epan_custom_set(edt, col_item->col_custom_field_ids, + col_item->col_custom_occurrence, + col_item->col_buf, cinfo->col_expr.col_expr_val[i], COL_MAX_LEN); } @@ -323,6 +317,7 @@ void col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo) { int i; + col_item_t* col_item; if (!HAVE_CUSTOM_COLS(cinfo)) return; @@ -331,17 +326,18 @@ col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo) i <= cinfo->col_last[COL_CUSTOM]; i++) { int i_list = 0; - col_custom_field_ids_free(cinfo, i); + col_item = &cinfo->columns[i]; + col_custom_field_ids_free(&col_item->col_custom_field_ids); - if (cinfo->fmt_matx[i][COL_CUSTOM] && - cinfo->col_custom_dfilter[i]) { - epan_dissect_prime_dfilter(edt, cinfo->col_custom_dfilter[i]); - if (cinfo->col_custom_field) { + if (col_item->fmt_matx[COL_CUSTOM] && + col_item->col_custom_dfilter) { + epan_dissect_prime_dfilter(edt, col_item->col_custom_dfilter); + if (col_item->col_custom_field) { gchar **fields; guint i_field = 0; fields = g_regex_split_simple(" *([^ \\|]+) *(?:(?:\\|\\|)|(?:or))? *", - cinfo->col_custom_field[i], G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED); + col_item->col_custom_field, G_REGEX_ANCHORED, G_REGEX_MATCH_ANCHORED); for (i_field =0; i_field < g_strv_length(fields); i_field += 1) { if (fields[i_field] && *fields[i_field]) { @@ -354,8 +350,8 @@ col_custom_prime_edt(epan_dissect_t *edt, column_info *cinfo) idx = g_new(int, 1); *idx = id; - cinfo->col_custom_field_ids[i] = - g_slist_insert(cinfo->col_custom_field_ids[i], idx, i_list); + col_item->col_custom_field_ids = + g_slist_insert(col_item->col_custom_field_ids, idx, i_list); i_list += 1; } } @@ -373,6 +369,7 @@ col_append_lstr(column_info *cinfo, const gint el, const gchar *str1, ...) size_t pos, max_len; int i; const gchar *str; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; @@ -383,13 +380,14 @@ col_append_lstr(column_info *cinfo, const gint el, const gchar *str1, ...) max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { /* * First arrange that we can append, if necessary. */ - COL_CHECK_APPEND(cinfo, i, max_len); + COL_CHECK_APPEND(col_item, max_len); - pos = strlen(cinfo->col_buf[i]); + pos = strlen(col_item->col_buf); if (pos >= max_len) return; @@ -399,7 +397,7 @@ col_append_lstr(column_info *cinfo, const gint el, const gchar *str1, ...) if G_UNLIKELY(str == NULL) str = "(null)"; - pos += g_strlcpy(&cinfo->col_buf[i][pos], str, max_len - pos); + pos += g_strlcpy(&col_item->col_buf[pos], str, max_len - pos); } while (pos < max_len && (str = va_arg(ap, const char *)) != COL_ADD_LSTR_TERMINATOR); va_end(ap); @@ -412,6 +410,7 @@ col_do_append_fstr(column_info *cinfo, const int el, const char *separator, cons { size_t len, max_len, sep_len; int i; + col_item_t* col_item; sep_len = (separator) ? strlen(separator) : 0; @@ -421,19 +420,20 @@ col_do_append_fstr(column_info *cinfo, const int el, const char *separator, cons max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { /* * First arrange that we can append, if necessary. */ - COL_CHECK_APPEND(cinfo, i, max_len); + COL_CHECK_APPEND(col_item, max_len); - len = strlen(cinfo->col_buf[i]); + len = strlen(col_item->col_buf); /* * If we have a separator, append it if the column isn't empty. */ if (sep_len != 0 && len != 0) { - g_strlcat(cinfo->col_buf[i], separator, max_len); + g_strlcat(col_item->col_buf, separator, max_len); len += sep_len; } @@ -441,7 +441,7 @@ col_do_append_fstr(column_info *cinfo, const int el, const char *separator, cons va_list ap2; G_VA_COPY(ap2, ap); - g_vsnprintf(&cinfo->col_buf[i][len], (guint32)(max_len - len), format, ap2); + g_vsnprintf(&col_item->col_buf[len], (guint32)(max_len - len), format, ap2); va_end(ap2); } } @@ -493,6 +493,7 @@ col_prepend_fstr(column_info *cinfo, const gint el, const gchar *format, ...) char orig_buf[COL_BUF_MAX_LEN]; const char *orig; int max_len; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; @@ -503,26 +504,27 @@ col_prepend_fstr(column_info *cinfo, const gint el, const gchar *format, ...) max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - if (cinfo->col_data[i] != cinfo->col_buf[i]) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + if (col_item->col_data != col_item->col_buf) { /* This was set with "col_set_str()"; which is effectively const */ - orig = cinfo->col_data[i]; + orig = col_item->col_data; } else { - g_strlcpy(orig_buf, cinfo->col_buf[i], max_len); + g_strlcpy(orig_buf, col_item->col_buf, max_len); orig = orig_buf; } va_start(ap, format); - g_vsnprintf(cinfo->col_buf[i], max_len, format, ap); + g_vsnprintf(col_item->col_buf, max_len, format, ap); va_end(ap); /* * Move the fence, unless it's at the beginning of the string. */ - if (cinfo->col_fence[i] > 0) - cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]); + if (col_item->col_fence > 0) + col_item->col_fence += (int) strlen(col_item->col_buf); - g_strlcat(cinfo->col_buf[i], orig, max_len); - cinfo->col_data[i] = cinfo->col_buf[i]; + g_strlcat(col_item->col_buf, orig, max_len); + col_item->col_data = col_item->col_buf; } } } @@ -534,6 +536,7 @@ col_prepend_fence_fstr(column_info *cinfo, const gint el, const gchar *format, . char orig_buf[COL_BUF_MAX_LEN]; const char *orig; int max_len; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; @@ -544,29 +547,30 @@ col_prepend_fence_fstr(column_info *cinfo, const gint el, const gchar *format, . max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - if (cinfo->col_data[i] != cinfo->col_buf[i]) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + if (col_item->col_data != col_item->col_buf) { /* This was set with "col_set_str()"; which is effectively const */ - orig = cinfo->col_data[i]; + orig = col_item->col_data; } else { - g_strlcpy(orig_buf, cinfo->col_buf[i], max_len); + g_strlcpy(orig_buf, col_item->col_buf, max_len); orig = orig_buf; } va_start(ap, format); - g_vsnprintf(cinfo->col_buf[i], max_len, format, ap); + g_vsnprintf(col_item->col_buf, max_len, format, ap); va_end(ap); /* * Move the fence if it exists, else create a new fence at the * end of the prepended data. */ - if (cinfo->col_fence[i] > 0) { - cinfo->col_fence[i] += (int) strlen(cinfo->col_buf[i]); + if (col_item->col_fence > 0) { + col_item->col_fence += (int) strlen(col_item->col_buf); } else { - cinfo->col_fence[i] = (int) strlen(cinfo->col_buf[i]); + col_item->col_fence = (int) strlen(col_item->col_buf); } - g_strlcat(cinfo->col_buf[i], orig, max_len); - cinfo->col_data[i] = cinfo->col_buf[i]; + g_strlcat(col_item->col_buf, orig, max_len); + col_item->col_data = col_item->col_buf; } } } @@ -577,8 +581,8 @@ void col_add_str(column_info *cinfo, const gint el, const gchar* str) { int i; - int fence; size_t max_len; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; @@ -589,21 +593,21 @@ col_add_str(column_info *cinfo, const gint el, const gchar* str) max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - fence = cinfo->col_fence[i]; - if (fence != 0) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + if (col_item->col_fence != 0) { /* * We will append the string after the fence. * First arrange that we can append, if necessary. */ - COL_CHECK_APPEND(cinfo, i, max_len); + COL_CHECK_APPEND(col_item, max_len); } else { /* * There's no fence, so we can just write to the string. */ - cinfo->col_data[i] = cinfo->col_buf[i]; + col_item->col_data = col_item->col_buf; } - g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence); + g_strlcpy(&col_item->col_buf[col_item->col_fence], str, max_len - col_item->col_fence); } } } @@ -614,8 +618,8 @@ void col_set_str(column_info *cinfo, const gint el, const gchar* str) { int i; - int fence; size_t max_len; + col_item_t* col_item; DISSECTOR_ASSERT(str); @@ -628,22 +632,22 @@ col_set_str(column_info *cinfo, const gint el, const gchar* str) max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - fence = cinfo->col_fence[i]; - if (fence != 0) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + if (col_item->col_fence != 0) { /* * We will append the string after the fence. * First arrange that we can append, if necessary. */ - COL_CHECK_APPEND(cinfo, i, max_len); + COL_CHECK_APPEND(col_item, max_len); - g_strlcpy(&cinfo->col_buf[i][fence], str, max_len - fence); + g_strlcpy(&col_item->col_buf[col_item->col_fence], str, max_len - col_item->col_fence); } else { /* * There's no fence, so we can just set the column to point * to the string. */ - cinfo->col_data[i] = str; + col_item->col_data = str; } } } @@ -657,6 +661,7 @@ col_add_lstr(column_info *cinfo, const gint el, const gchar *str1, ...) gsize pos; gsize max_len; const gchar *str; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; @@ -667,19 +672,20 @@ col_add_lstr(column_info *cinfo, const gint el, const gchar *str1, ...) max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - pos = cinfo->col_fence[i]; + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + pos = col_item->col_fence; if (pos != 0) { /* * We will append the string after the fence. * First arrange that we can append, if necessary. */ - COL_CHECK_APPEND(cinfo, i, max_len); + COL_CHECK_APPEND(col_item, max_len); } else { /* * There's no fence, so we can just write to the string. */ - cinfo->col_data[i] = cinfo->col_buf[i]; + col_item->col_data = col_item->col_buf; } va_start(ap, str1); @@ -688,7 +694,7 @@ col_add_lstr(column_info *cinfo, const gint el, const gchar *str1, ...) if G_UNLIKELY(str == NULL) str = "(null)"; - pos += g_strlcpy(&cinfo->col_buf[i][pos], str, max_len - pos); + pos += g_strlcpy(&col_item->col_buf[pos], str, max_len - pos); } while (pos < max_len && (str = va_arg(ap, const char *)) != COL_ADD_LSTR_TERMINATOR); va_end(ap); @@ -702,8 +708,8 @@ col_add_fstr(column_info *cinfo, const gint el, const gchar *format, ...) { va_list ap; int i; - int fence; int max_len; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; @@ -714,22 +720,22 @@ col_add_fstr(column_info *cinfo, const gint el, const gchar *format, ...) max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { - fence = cinfo->col_fence[i]; - if (fence != 0) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { + if (col_item->col_fence != 0) { /* * We will append the string after the fence. * First arrange that we can append, if necessary. */ - COL_CHECK_APPEND(cinfo, i, max_len); + COL_CHECK_APPEND(col_item, max_len); } else { /* * There's no fence, so we can just write to the string. */ - cinfo->col_data[i] = cinfo->col_buf[i]; + col_item->col_data = col_item->col_buf; } va_start(ap, format); - g_vsnprintf(&cinfo->col_buf[i][fence], max_len - fence, format, ap); + g_vsnprintf(&col_item->col_buf[col_item->col_fence], max_len - col_item->col_fence, format, ap); va_end(ap); } } @@ -741,6 +747,7 @@ col_do_append_str(column_info *cinfo, const gint el, const gchar* separator, { int i; size_t len, max_len; + col_item_t* col_item; if (el == COL_INFO) max_len = COL_MAX_INFO_LEN; @@ -748,23 +755,24 @@ col_do_append_str(column_info *cinfo, const gint el, const gchar* separator, max_len = COL_MAX_LEN; for (i = cinfo->col_first[el]; i <= cinfo->col_last[el]; i++) { - if (cinfo->fmt_matx[i][el]) { + col_item = &cinfo->columns[i]; + if (col_item->fmt_matx[el]) { /* * First arrange that we can append, if necessary. */ - COL_CHECK_APPEND(cinfo, i, max_len); + COL_CHECK_APPEND(col_item, max_len); - len = cinfo->col_buf[i][0]; + len = col_item->col_buf[0]; /* * If we have a separator, append it if the column isn't empty. */ if (separator != NULL) { if (len != 0) { - g_strlcat(cinfo->col_buf[i], separator, max_len); + g_strlcat(col_item->col_buf, separator, max_len); } } - g_strlcat(cinfo->col_buf[i], str, max_len); + g_strlcat(col_item->col_buf, str, max_len); } } } @@ -795,16 +803,17 @@ col_append_sep_str(column_info *cinfo, const gint el, const gchar* separator, gboolean col_has_time_fmt(column_info *cinfo, const gint col) { - return ((cinfo->fmt_matx[col][COL_CLS_TIME]) || - (cinfo->fmt_matx[col][COL_ABS_TIME]) || - (cinfo->fmt_matx[col][COL_ABS_YMD_TIME]) || - (cinfo->fmt_matx[col][COL_ABS_YDOY_TIME]) || - (cinfo->fmt_matx[col][COL_UTC_TIME]) || - (cinfo->fmt_matx[col][COL_UTC_YMD_TIME]) || - (cinfo->fmt_matx[col][COL_UTC_YDOY_TIME]) || - (cinfo->fmt_matx[col][COL_REL_TIME]) || - (cinfo->fmt_matx[col][COL_DELTA_TIME]) || - (cinfo->fmt_matx[col][COL_DELTA_TIME_DIS])); + col_item_t* col_item = &cinfo->columns[col]; + return ((col_item->fmt_matx[COL_CLS_TIME]) || + (col_item->fmt_matx[COL_ABS_TIME]) || + (col_item->fmt_matx[COL_ABS_YMD_TIME]) || + (col_item->fmt_matx[COL_ABS_YDOY_TIME]) || + (col_item->fmt_matx[COL_UTC_TIME]) || + (col_item->fmt_matx[COL_UTC_YMD_TIME]) || + (col_item->fmt_matx[COL_UTC_YDOY_TIME]) || + (col_item->fmt_matx[COL_REL_TIME]) || + (col_item->fmt_matx[COL_DELTA_TIME]) || + (col_item->fmt_matx[COL_DELTA_TIME_DIS])); } static void @@ -919,21 +928,21 @@ set_abs_ymd_time(const frame_data *fd, gchar *buf, gboolean local) static void col_set_abs_ymd_time(const frame_data *fd, column_info *cinfo, const int col) { - set_abs_ymd_time(fd, cinfo->col_buf[col], TRUE); + set_abs_ymd_time(fd, cinfo->columns[col].col_buf, TRUE); cinfo->col_expr.col_expr[col] = "frame.time"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static void col_set_utc_ymd_time(const frame_data *fd, column_info *cinfo, const int col) { - set_abs_ymd_time(fd, cinfo->col_buf[col], FALSE); + set_abs_ymd_time(fd, cinfo->columns[col].col_buf, FALSE); cinfo->col_expr.col_expr[col] = "frame.time"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static void @@ -1042,21 +1051,21 @@ set_abs_ydoy_time(const frame_data *fd, gchar *buf, gboolean local) static void col_set_abs_ydoy_time(const frame_data *fd, column_info *cinfo, const int col) { - set_abs_ydoy_time(fd, cinfo->col_buf[col], TRUE); + set_abs_ydoy_time(fd, cinfo->columns[col].col_buf, TRUE); cinfo->col_expr.col_expr[col] = "frame.time"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static void col_set_utc_ydoy_time(const frame_data *fd, column_info *cinfo, const int col) { - set_abs_ydoy_time(fd, cinfo->col_buf[col], FALSE); + set_abs_ydoy_time(fd, cinfo->columns[col].col_buf, FALSE); cinfo->col_expr.col_expr[col] = "frame.time"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static void @@ -1296,7 +1305,7 @@ col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col) nstime_t del_rel_ts; if (!fd->flags.has_ts) { - cinfo->col_buf[col][0] = '\0'; + cinfo->columns[col].col_buf[0] = '\0'; return; } @@ -1304,19 +1313,19 @@ col_set_rel_time(const frame_data *fd, column_info *cinfo, const int col) switch (timestamp_get_seconds_type()) { case TS_SECONDS_DEFAULT: - set_time_seconds(fd, &del_rel_ts, cinfo->col_buf[col]); + set_time_seconds(fd, &del_rel_ts, cinfo->columns[col].col_buf); cinfo->col_expr.col_expr[col] = "frame.time_relative"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); break; case TS_SECONDS_HOUR_MIN_SEC: - set_time_hour_min_sec(fd, &del_rel_ts, cinfo->col_buf[col]); + set_time_hour_min_sec(fd, &del_rel_ts, cinfo->columns[col].col_buf); cinfo->col_expr.col_expr[col] = "frame.time_relative"; set_time_seconds(fd, &del_rel_ts, cinfo->col_expr.col_expr_val[col]); break; default: g_assert_not_reached(); } - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static void @@ -1328,12 +1337,12 @@ col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col) switch (timestamp_get_seconds_type()) { case TS_SECONDS_DEFAULT: - set_time_seconds(fd, &del_cap_ts, cinfo->col_buf[col]); + set_time_seconds(fd, &del_cap_ts, cinfo->columns[col].col_buf); cinfo->col_expr.col_expr[col] = "frame.time_delta"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); break; case TS_SECONDS_HOUR_MIN_SEC: - set_time_hour_min_sec(fd, &del_cap_ts, cinfo->col_buf[col]); + set_time_hour_min_sec(fd, &del_cap_ts, cinfo->columns[col].col_buf); cinfo->col_expr.col_expr[col] = "frame.time_delta"; set_time_seconds(fd, &del_cap_ts, cinfo->col_expr.col_expr_val[col]); break; @@ -1341,7 +1350,7 @@ col_set_delta_time(const frame_data *fd, column_info *cinfo, const int col) g_assert_not_reached(); } - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static void @@ -1350,7 +1359,7 @@ col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col) nstime_t del_dis_ts; if (!fd->flags.has_ts) { - cinfo->col_buf[col][0] = '\0'; + cinfo->columns[col].col_buf[0] = '\0'; return; } @@ -1358,12 +1367,12 @@ col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col) switch (timestamp_get_seconds_type()) { case TS_SECONDS_DEFAULT: - set_time_seconds(fd, &del_dis_ts, cinfo->col_buf[col]); + set_time_seconds(fd, &del_dis_ts, cinfo->columns[col].col_buf); cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); break; case TS_SECONDS_HOUR_MIN_SEC: - set_time_hour_min_sec(fd, &del_dis_ts, cinfo->col_buf[col]); + set_time_hour_min_sec(fd, &del_dis_ts, cinfo->columns[col].col_buf); cinfo->col_expr.col_expr[col] = "frame.time_delta_displayed"; set_time_seconds(fd, &del_dis_ts, cinfo->col_expr.col_expr_val[col]); break; @@ -1371,7 +1380,7 @@ col_set_delta_time_dis(const frame_data *fd, column_info *cinfo, const int col) g_assert_not_reached(); } - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static void @@ -1469,21 +1478,21 @@ set_abs_time(const frame_data *fd, gchar *buf, gboolean local) static void col_set_abs_time(const frame_data *fd, column_info *cinfo, const int col) { - set_abs_time(fd, cinfo->col_buf[col], TRUE); + set_abs_time(fd, cinfo->columns[col].col_buf, TRUE); cinfo->col_expr.col_expr[col] = "frame.time"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static void col_set_utc_time(const frame_data *fd, column_info *cinfo, const int col) { - set_abs_time(fd, cinfo->col_buf[col], FALSE); + set_abs_time(fd, cinfo->columns[col].col_buf, FALSE); cinfo->col_expr.col_expr[col] = "frame.time"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } static gboolean @@ -1554,11 +1563,11 @@ set_epoch_time(const frame_data *fd, gchar *buf) static void col_set_epoch_time(const frame_data *fd, column_info *cinfo, const int col) { - if (set_epoch_time(fd, cinfo->col_buf[col])) { + if (set_epoch_time(fd, cinfo->columns[col].col_buf)) { cinfo->col_expr.col_expr[col] = "frame.time_delta"; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->columns[col].col_buf,COL_MAX_LEN); } - cinfo->col_data[col] = cinfo->col_buf[col]; + cinfo->columns[col].col_data = cinfo->columns[col].col_buf; } void @@ -1719,7 +1728,7 @@ col_set_cls_time(const frame_data *fd, column_info *cinfo, const gint col) static void col_set_fmt_time(const frame_data *fd, column_info *cinfo, const gint fmt, const gint col) { - COL_CHECK_REF_TIME(fd, cinfo->col_buf[col]); + COL_CHECK_REF_TIME(fd, cinfo->columns[col].col_buf); switch (fmt) { case COL_CLS_TIME: @@ -1784,6 +1793,7 @@ void col_set_time(column_info *cinfo, const gint el, const nstime_t *ts, const char *fieldname) { int col; + col_item_t* col_item; if (!CHECK_COL(cinfo, el)) return; @@ -1793,39 +1803,40 @@ col_set_time(column_info *cinfo, const gint el, const nstime_t *ts, const char * */ for (col = cinfo->col_first[el]; col <= cinfo->col_last[el]; col++) { - if (cinfo->fmt_matx[col][el]) { + col_item = &cinfo->columns[col]; + if (col_item->fmt_matx[el]) { switch (timestamp_get_precision()) { case TS_PREC_FIXED_SEC: - display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + display_signed_time(col_item->col_buf, COL_MAX_LEN, (gint32) ts->secs, ts->nsecs / 1000000000, TO_STR_TIME_RES_T_SECS); break; case TS_PREC_FIXED_DSEC: - display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + display_signed_time(col_item->col_buf, COL_MAX_LEN, (gint32) ts->secs, ts->nsecs / 100000000, TO_STR_TIME_RES_T_DSECS); break; case TS_PREC_FIXED_CSEC: - display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + display_signed_time(col_item->col_buf, COL_MAX_LEN, (gint32) ts->secs, ts->nsecs / 10000000, TO_STR_TIME_RES_T_CSECS); break; case TS_PREC_FIXED_MSEC: - display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + display_signed_time(col_item->col_buf, COL_MAX_LEN, (gint32) ts->secs, ts->nsecs / 1000000, TO_STR_TIME_RES_T_MSECS); break; case TS_PREC_FIXED_USEC: - display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + display_signed_time(col_item->col_buf, COL_MAX_LEN, (gint32) ts->secs, ts->nsecs / 1000, TO_STR_TIME_RES_T_USECS); break; case TS_PREC_FIXED_NSEC: case TS_PREC_AUTO: /* default to maximum */ - display_signed_time(cinfo->col_buf[col], COL_MAX_LEN, + display_signed_time(col_item->col_buf, COL_MAX_LEN, (gint32) ts->secs, ts->nsecs, TO_STR_TIME_RES_T_NSECS); break; default: g_assert_not_reached(); } - cinfo->col_data[col] = cinfo->col_buf[col]; + col_item->col_data = col_item->col_buf; cinfo->col_expr.col_expr[col] = fieldname; - g_strlcpy(cinfo->col_expr.col_expr_val[col],cinfo->col_buf[col],COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col],col_item->col_buf,COL_MAX_LEN); } } } @@ -1835,6 +1846,7 @@ col_set_addr(packet_info *pinfo, const int col, const address *addr, const gbool const gboolean fill_col_exprs, const gboolean res) { const char *name; + col_item_t* col_item = &pinfo->cinfo->columns[col]; if (addr->type == AT_NONE) { /* No address, nothing to do */ @@ -1842,10 +1854,10 @@ col_set_addr(packet_info *pinfo, const int col, const address *addr, const gbool } if (res && (name = get_addr_name(addr)) != NULL) - pinfo->cinfo->col_data[col] = name; + col_item->col_data = name; else { - pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; - address_to_str_buf(addr, pinfo->cinfo->col_buf[col], COL_MAX_LEN); + col_item->col_data = col_item->col_buf; + address_to_str_buf(addr, col_item->col_buf, COL_MAX_LEN); } if (!fill_col_exprs) @@ -1862,6 +1874,7 @@ static void col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gboolean is_src, const gboolean fill_col_exprs _U_) { guint32 port; + col_item_t* col_item = &pinfo->cinfo->columns[col]; if (is_src) port = pinfo->srcport; @@ -1873,17 +1886,17 @@ col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gbo switch (pinfo->ptype) { case PT_SCTP: if (is_res) - g_strlcpy(pinfo->cinfo->col_buf[col], sctp_port_to_display(pinfo->pool, port), COL_MAX_LEN); + g_strlcpy(col_item->col_buf, sctp_port_to_display(pinfo->pool, port), COL_MAX_LEN); else - guint32_to_str_buf(port, pinfo->cinfo->col_buf[col], COL_MAX_LEN); + guint32_to_str_buf(port, col_item->col_buf, COL_MAX_LEN); break; case PT_TCP: guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); if (is_res) - g_strlcpy(pinfo->cinfo->col_buf[col], tcp_port_to_display(pinfo->pool, port), COL_MAX_LEN); + g_strlcpy(col_item->col_buf, tcp_port_to_display(pinfo->pool, port), COL_MAX_LEN); else - g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); + g_strlcpy(col_item->col_buf, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); if (is_src) pinfo->cinfo->col_expr.col_expr[col] = "tcp.srcport"; else @@ -1893,9 +1906,9 @@ col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gbo case PT_UDP: guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); if (is_res) - g_strlcpy(pinfo->cinfo->col_buf[col], udp_port_to_display(pinfo->pool, port), COL_MAX_LEN); + g_strlcpy(col_item->col_buf, udp_port_to_display(pinfo->pool, port), COL_MAX_LEN); else - g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); + g_strlcpy(col_item->col_buf, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); if (is_src) pinfo->cinfo->col_expr.col_expr[col] = "udp.srcport"; else @@ -1908,13 +1921,13 @@ col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gbo else pinfo->cinfo->col_expr.col_expr[col] = "ddp.dst_socket"; guint32_to_str_buf(port, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); - g_strlcpy(pinfo->cinfo->col_buf[col], pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); + g_strlcpy(col_item->col_buf, pinfo->cinfo->col_expr.col_expr_val[col], COL_MAX_LEN); break; case PT_IPX: /* XXX - resolve IPX socket numbers */ - g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port); - g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN); + g_snprintf(col_item->col_buf, COL_MAX_LEN, "0x%04x", port); + g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], col_item->col_buf,COL_MAX_LEN); if (is_src) pinfo->cinfo->col_expr.col_expr[col] = "ipx.src.socket"; else @@ -1923,8 +1936,8 @@ col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gbo case PT_IDP: /* XXX - resolve IDP socket numbers */ - g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%04x", port); - g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN); + g_snprintf(col_item->col_buf, COL_MAX_LEN, "0x%04x", port); + g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], col_item->col_buf,COL_MAX_LEN); if (is_src) pinfo->cinfo->col_expr.col_expr[col] = "idp.src.socket"; else @@ -1933,8 +1946,8 @@ col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gbo case PT_USB: /* XXX - resolve USB endpoint numbers */ - g_snprintf(pinfo->cinfo->col_buf[col], COL_MAX_LEN, "0x%08x", port); - g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], pinfo->cinfo->col_buf[col],COL_MAX_LEN); + g_snprintf(col_item->col_buf, COL_MAX_LEN, "0x%08x", port); + g_strlcpy(pinfo->cinfo->col_expr.col_expr_val[col], col_item->col_buf,COL_MAX_LEN); if (is_src) pinfo->cinfo->col_expr.col_expr[col] = "usb.src.endpoint"; else @@ -1944,7 +1957,7 @@ col_set_port(packet_info *pinfo, const int col, const gboolean is_res, const gbo default: break; } - pinfo->cinfo->col_data[col] = pinfo->cinfo->col_buf[col]; + col_item->col_data = col_item->col_buf; } gboolean @@ -1953,7 +1966,7 @@ col_based_on_frame_data(column_info *cinfo, const gint col) g_assert(cinfo); g_assert(col < cinfo->num_cols); - switch (cinfo->col_fmt[col]) { + switch (cinfo->columns[col].col_fmt) { case COL_NUMBER: case COL_CLS_TIME: case COL_ABS_TIME: @@ -1977,10 +1990,12 @@ col_based_on_frame_data(column_info *cinfo, const gint col) void col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, const gboolean fill_col_exprs) { - switch (cinfo->col_fmt[col]) { + col_item_t* col_item = &cinfo->columns[col]; + + switch (col_item->col_fmt) { case COL_NUMBER: - guint32_to_str_buf(fd->num, cinfo->col_buf[col], COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + guint32_to_str_buf(fd->num, col_item->col_buf, COL_MAX_LEN); + col_item->col_data = col_item->col_buf; break; case COL_CLS_TIME: @@ -1994,17 +2009,17 @@ col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, case COL_DELTA_TIME: case COL_DELTA_TIME_DIS: /* TODO: Pass on fill_col_exprs */ - col_set_fmt_time(fd, cinfo, cinfo->col_fmt[col], col); + col_set_fmt_time(fd, cinfo, col_item->col_fmt, col); break; case COL_PACKET_LENGTH: - guint32_to_str_buf(fd->pkt_len, cinfo->col_buf[col], COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + guint32_to_str_buf(fd->pkt_len, col_item->col_buf, COL_MAX_LEN); + col_item->col_data = col_item->col_buf; break; case COL_CUMULATIVE_BYTES: - guint32_to_str_buf(fd->cum_bytes, cinfo->col_buf[col], COL_MAX_LEN); - cinfo->col_data[col] = cinfo->col_buf[col]; + guint32_to_str_buf(fd->cum_bytes, col_item->col_buf, COL_MAX_LEN); + col_item->col_data = col_item->col_buf; break; default: @@ -2014,10 +2029,10 @@ col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, if (!fill_col_exprs) return; - switch (cinfo->col_fmt[col]) { + switch (col_item->col_fmt) { case COL_NUMBER: cinfo->col_expr.col_expr[col] = "frame.number"; - g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col], col_item->col_buf, COL_MAX_LEN); break; case COL_CLS_TIME: @@ -2035,7 +2050,7 @@ col_fill_in_frame_data(const frame_data *fd, column_info *cinfo, const gint col, case COL_PACKET_LENGTH: cinfo->col_expr.col_expr[col] = "frame.len"; - g_strlcpy(cinfo->col_expr.col_expr_val[col], cinfo->col_buf[col], COL_MAX_LEN); + g_strlcpy(cinfo->col_expr.col_expr_val[col], col_item->col_buf, COL_MAX_LEN); break; case COL_CUMULATIVE_BYTES: @@ -2050,16 +2065,18 @@ void col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fill_fd_colums) { int i; + col_item_t* col_item; if (!pinfo->cinfo) return; for (i = 0; i < pinfo->cinfo->num_cols; i++) { + col_item = &pinfo->cinfo->columns[i]; if (col_based_on_frame_data(pinfo->cinfo, i)) { if (fill_fd_colums) col_fill_in_frame_data(pinfo->fd, pinfo->cinfo, i, fill_col_exprs); } else { - switch (pinfo->cinfo->col_fmt[i]) { + switch (col_item->col_fmt) { case COL_DEF_SRC: case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */ col_set_addr(pinfo, i, &pinfo->src, TRUE, fill_col_exprs, TRUE); @@ -2136,7 +2153,7 @@ col_fill_in(packet_info *pinfo, const gboolean fill_col_exprs, const gboolean fi g_assert_not_reached(); break; default: - if (pinfo->cinfo->col_fmt[i] >= NUM_COL_FMTS) { + if (col_item->col_fmt >= NUM_COL_FMTS) { g_assert_not_reached(); } /* @@ -2158,26 +2175,28 @@ void col_fill_in_error(column_info *cinfo, frame_data *fdata, const gboolean fill_col_exprs, const gboolean fill_fd_colums) { int i; + col_item_t* col_item; if (!cinfo) return; for (i = 0; i < cinfo->num_cols; i++) { + col_item = &cinfo->columns[i]; if (col_based_on_frame_data(cinfo, i)) { if (fill_fd_colums) col_fill_in_frame_data(fdata, cinfo, i, fill_col_exprs); - } else if (cinfo->col_fmt[i] == COL_INFO) { + } else if (col_item->col_fmt == COL_INFO) { /* XXX - say more than this */ - cinfo->col_data[i] = "Read error"; + col_item->col_data = "Read error"; } else { - if (cinfo->col_fmt[i] >= NUM_COL_FMTS) { + if (col_item->col_fmt >= NUM_COL_FMTS) { g_assert_not_reached(); } /* * No dissection was done, and these columns are set as the * result of the dissection, so.... */ - cinfo->col_data[i] = "???"; + col_item->col_data = "???"; break; } } |