diff options
author | Gerald Combs <gerald@wireshark.org> | 2018-06-27 14:10:27 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-06-27 23:40:05 +0000 |
commit | a7610e837b47b50bbe9d5b83a9d8115252592ced (patch) | |
tree | 1291053ed053c36066578dbe4b8cff2dfa932f6f /epan/column.c | |
parent | d8459d8930911b45409371a58f75357a5d2cc986 (diff) |
Sort our column descriptions.
Convert our column descriptions to a value_string and sort it by
description. This ensures that they are properly sorted in the UI.
Change-Id: I7d699a1c45906b9c42e443fcdcdcb4d8d49deb77
Reviewed-on: https://code.wireshark.org/review/28492
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/column.c')
-rw-r--r-- | epan/column.c | 118 |
1 files changed, 64 insertions, 54 deletions
diff --git a/epan/column.c b/epan/column.c index 658bbfb4eb..96e1e96d73 100644 --- a/epan/column.c +++ b/epan/column.c @@ -108,62 +108,72 @@ col_format_to_string(const gint fmt) { /* Given a format number (as defined in column-utils.h), returns its description */ const gchar * -col_format_desc(const gint fmt) { - static const gchar *const dlist[NUM_COL_FMTS] = { - "802.1Q VLAN id", /* 0) COL_8021Q_VLAN_ID */ - "Absolute date, as YYYY-MM-DD, and time", /* 1) COL_ABS_YMD_TIME */ - "Absolute date, as YYYY/DOY, and time", /* 2) COL_ABS_YDOY_TIME */ - "Absolute time", /* 3) COL_ABS_TIME */ - "Cisco VSAN", /* 4) COL_VSAN */ - "Cumulative Bytes" , /* 5) COL_CUMULATIVE_BYTES */ - "Custom", /* 6) COL_CUSTOM */ - "DCE/RPC call (cn_call_id / dg_seqnum)", /* 7) COL_DCE_CALL */ - "Delta time", /* 8) COL_DELTA_TIME */ - "Delta time displayed", /* 9) COL_DELTA_TIME_DIS */ - "Dest addr (resolved)", /* 10) COL_RES_DST */ - "Dest addr (unresolved)", /* 11) COL_UNRES_DST */ - "Dest port (resolved)", /* 12) COL_RES_DST_PORT */ - "Dest port (unresolved)", /* 13) COL_UNRES_DST_PORT */ - "Destination address", /* 14) COL_DEF_DST */ - "Destination port", /* 15) COL_DEF_DST_PORT */ - "Expert Info Severity", /* 16) COL_EXPERT */ - "FW-1 monitor if/direction", /* 17) COL_IF_DIR */ - "Frequency/Channel", /* 18) COL_FREQ_CHAN */ - "Hardware dest addr", /* 19) COL_DEF_DL_DST */ - "Hardware src addr", /* 20) COL_DEF_DL_SRC */ - "Hw dest addr (resolved)", /* 21) COL_RES_DL_DST */ - "Hw dest addr (unresolved)", /* 22) COL_UNRES_DL_DST */ - "Hw src addr (resolved)", /* 23) COL_RES_DL_SRC*/ - "Hw src addr (unresolved)", /* 24) COL_UNRES_DL_SRC */ - "IEEE 802.11 RSSI", /* 25) COL_RSSI */ - "IEEE 802.11 TX rate", /* 26) COL_TX_RATE */ - "IP DSCP Value", /* 27) COL_DSCP_VALUE */ - "Information", /* 28) COL_INFO */ - "Net dest addr (resolved)", /* 29) COL_RES_NET_DST */ - "Net dest addr (unresolved)", /* 30) COL_UNRES_NET_DST */ - "Net src addr (resolved)", /* 31) COL_RES_NET_SRC */ - "Net src addr (unresolved)", /* 32) COL_UNRES_NET_SRC */ - "Network dest addr", /* 33) COL_DEF_NET_DST */ - "Network src addr", /* 34) COL_DEF_NET_SRC */ - "Number", /* 35) COL_NUMBER */ - "Packet length (bytes)" , /* 36) COL_PACKET_LENGTH */ - "Protocol", /* 37) COL_PROTOCOL */ - "Relative time", /* 38) COL_REL_TIME */ - "Source address", /* 39) COL_DEF_SRC */ - "Source port", /* 40) COL_DEF_SRC_PORT */ - "Src addr (resolved)", /* 41) COL_RES_SRC */ - "Src addr (unresolved)", /* 42) COL_UNRES_SRC */ - "Src port (resolved)", /* 43) COL_RES_SRC_PORT */ - "Src port (unresolved)", /* 44) COL_UNRES_SRC_PORT */ - "TEI", /* 45) COL_TEI */ - "UTC date, as YYYY-MM-DD, and time", /* 46) COL_UTC_YMD_TIME */ - "UTC date, as YYYY/DOY, and time", /* 47) COL_UTC_YDOY_TIME */ - "UTC time", /* 48) COL_UTC_TIME */ - "Time (format as specified)" /* 49) COL_CLS_TIME */ +col_format_desc(const gint fmt_num) { + + /* This should be sorted alphabetically, e.g. `sort -t, -k2` */ + /* + * This is currently used in the preferences UI, so out-of-numeric-order + * performance shouldn't be an issue. + */ + static const value_string dlist_vals[] = { + + { COL_8021Q_VLAN_ID, "802.1Q VLAN id" }, + { COL_ABS_YMD_TIME, "Absolute date, as YYYY-MM-DD, and time" }, + { COL_ABS_YDOY_TIME, "Absolute date, as YYYY/DOY, and time" }, + { COL_ABS_TIME, "Absolute time" }, + { COL_VSAN, "Cisco VSAN" }, + { COL_CUMULATIVE_BYTES, "Cumulative Bytes" }, + { COL_CUSTOM, "Custom" }, + { COL_DCE_CALL, "DCE/RPC call (cn_call_id / dg_seqnum)" }, + { COL_DELTA_TIME_DIS, "Delta time displayed" }, + { COL_DELTA_TIME, "Delta time" }, + { COL_RES_DST, "Dest addr (resolved)" }, + { COL_UNRES_DST, "Dest addr (unresolved)" }, + { COL_RES_DST_PORT, "Dest port (resolved)" }, + { COL_UNRES_DST_PORT, "Dest port (unresolved)" }, + { COL_DEF_DST, "Destination address" }, + { COL_DEF_DST_PORT, "Destination port" }, + { COL_EXPERT, "Expert Info Severity" }, + { COL_IF_DIR, "FW-1 monitor if/direction" }, + { COL_FREQ_CHAN, "Frequency/Channel" }, + { COL_DEF_DL_DST, "Hardware dest addr" }, + { COL_DEF_DL_SRC, "Hardware src addr" }, + { COL_RES_DL_DST, "Hw dest addr (resolved)" }, + { COL_UNRES_DL_DST, "Hw dest addr (unresolved)" }, + { COL_RES_DL_SRC, "Hw src addr (resolved)" }, + { COL_UNRES_DL_SRC, "Hw src addr (unresolved)" }, + { COL_RSSI, "IEEE 802.11 RSSI" }, + { COL_TX_RATE, "IEEE 802.11 TX rate" }, + { COL_DSCP_VALUE, "IP DSCP Value" }, + { COL_INFO, "Information" }, + { COL_RES_NET_DST, "Net dest addr (resolved)" }, + { COL_UNRES_NET_DST, "Net dest addr (unresolved)" }, + { COL_RES_NET_SRC, "Net src addr (resolved)" }, + { COL_UNRES_NET_SRC, "Net src addr (unresolved)" }, + { COL_DEF_NET_DST, "Network dest addr" }, + { COL_DEF_NET_SRC, "Network src addr" }, + { COL_NUMBER, "Number" }, + { COL_PACKET_LENGTH, "Packet length (bytes)" }, + { COL_PROTOCOL, "Protocol" }, + { COL_REL_TIME, "Relative time" }, + { COL_DEF_SRC, "Source address" }, + { COL_DEF_SRC_PORT, "Source port" }, + { COL_RES_SRC, "Src addr (resolved)" }, + { COL_UNRES_SRC, "Src addr (unresolved)" }, + { COL_RES_SRC_PORT, "Src port (resolved)" }, + { COL_UNRES_SRC_PORT, "Src port (unresolved)" }, + { COL_TEI, "TEI" }, + { COL_CLS_TIME, "Time (format as specified)" }, + { COL_UTC_YMD_TIME, "UTC date, as YYYY-MM-DD, and time" }, + { COL_UTC_YDOY_TIME, "UTC date, as YYYY/DOY, and time" }, + { COL_UTC_TIME, "UTC time" }, + + { 0, NULL } }; - g_assert((fmt >= 0) && (fmt < NUM_COL_FMTS)); - return(dlist[fmt]); + const gchar *val_str = try_val_to_str(fmt_num, dlist_vals); + g_assert(val_str != NULL); + return val_str; } void |