summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-04-12 15:26:34 -0700
committerGuy Harris <guy@alum.mit.edu>2014-04-12 22:27:22 +0000
commitcb16dff992c3844936bf5829f19e5a5247458503 (patch)
tree901b7be3379f5b94f150de71d1c0f3e2fa2d12e4 /ui
parentef8a0a2ce172810d48371eb65c73b1bd4a6303ca (diff)
downloadwireshark-cb16dff992c3844936bf5829f19e5a5247458503.tar.gz
Get rid of more tvb_get_nstringz* calls.
Add an FT_STRINGZPAD type, for null-padded strings (typically fixed-length fields, where the string can be up to the length of the field, and is null-padded if it's shorter than that), and use it. Use IS_FT_STRING() in more cases, so that less code needs to know what types are string types. Add a tvb_get_stringzpad() routine, which gets null-padded strings. Currently, it does the same thing that tvb_get_string_enc() does, but that might change if we don't store string values as null-terminated strings. Change-Id: I46f56e130de8f419a19b56ded914e24cc7518a66 Reviewed-on: https://code.wireshark.org/review/1082 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui')
-rw-r--r--ui/decode_as_utils.c6
-rw-r--r--ui/gtk/decode_as_dlg.c2
-rw-r--r--ui/gtk/dissector_tables_dlg.c4
-rw-r--r--ui/gtk/main.c2
-rw-r--r--ui/gtk/packet_win.c2
-rw-r--r--ui/qt/decode_as_dialog.cpp8
6 files changed, 18 insertions, 6 deletions
diff --git a/ui/decode_as_utils.c b/ui/decode_as_utils.c
index 1463af7a72..7f5405a403 100644
--- a/ui/decode_as_utils.c
+++ b/ui/decode_as_utils.c
@@ -130,7 +130,7 @@ read_set_decode_as_entries(gchar *key, const gchar *value,
}
if (is_valid) {
- if (selector_type == FT_STRING || selector_type == FT_STRINGZ) {
+ if (IS_FT_STRING(selector_type)) {
dissector_change_string(values[0], values[1], lookup.handle);
} else {
dissector_change_uint(values[0], atoi(values[1]), lookup.handle);
@@ -191,6 +191,8 @@ decode_build_reset_list (const gchar *table_name, ftenum_t selector_type,
case FT_STRING:
case FT_STRINGZ:
+ case FT_UINT_STRING:
+ case FT_STRINGZPAD:
item->ddi_selector.sel_string = (char *)key;
break;
@@ -223,6 +225,8 @@ decode_clear_all(void)
case FT_STRING:
case FT_STRINGZ:
+ case FT_UINT_STRING:
+ case FT_STRINGZPAD:
dissector_reset_string(item->ddi_table_name,
item->ddi_selector.sel_string);
break;
diff --git a/ui/gtk/decode_as_dlg.c b/ui/gtk/decode_as_dlg.c
index afae7b7ffc..ec2b2e5dec 100644
--- a/ui/gtk/decode_as_dlg.c
+++ b/ui/gtk/decode_as_dlg.c
@@ -336,6 +336,8 @@ decode_build_show_list (const gchar *table_name, ftenum_t selector_type,
case FT_STRING:
case FT_STRINGZ:
+ case FT_UINT_STRING:
+ case FT_STRINGZPAD:
selector_name = (gchar *)key;
break;
diff --git a/ui/gtk/dissector_tables_dlg.c b/ui/gtk/dissector_tables_dlg.c
index 8964583a7c..501aee2920 100644
--- a/ui/gtk/dissector_tables_dlg.c
+++ b/ui/gtk/dissector_tables_dlg.c
@@ -145,6 +145,8 @@ decode_proto_add_to_list (const gchar *table_name _U_, ftenum_t selector_type,
case FT_STRING:
case FT_STRINGZ:
+ case FT_UINT_STRING:
+ case FT_STRINGZPAD:
str = (gchar*) key;
proto_add_to_list(tree_info, store, str, proto_name);
break;
@@ -230,6 +232,8 @@ display_dissector_table_names(const char *table_name, const char *ui_name, gpoin
break;
case FT_STRING:
case FT_STRINGZ:
+ case FT_UINT_STRING:
+ case FT_STRINGZPAD:
table_name_add_to_list(tree_info, dis_tbl_trees->str_tree_wgt, table_name, ui_name);
break;
default:
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index b351d5d497..5b0c53de32 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -612,7 +612,7 @@ get_filter_from_packet_list_row_and_column(gpointer data)
if (hfi && hfi->parent == -1) {
/* Protocol only */
buf = se_strdup(cfile.cinfo.col_expr.col_expr[column]);
- } else if (hfi && hfi->type == FT_STRING) {
+ } else if (hfi && IS_FT_STRING(hfi->type)) {
/* Custom string, add quotes */
buf = se_strdup_printf("%s == \"%s\"", cfile.cinfo.col_expr.col_expr[column],
cfile.cinfo.col_expr.col_expr_val[column]);
diff --git a/ui/gtk/packet_win.c b/ui/gtk/packet_win.c
index dd68ce6891..c25d62b48a 100644
--- a/ui/gtk/packet_win.c
+++ b/ui/gtk/packet_win.c
@@ -605,7 +605,7 @@ new_finfo_window(GtkWidget *w, struct FieldinfoWinData *DataPtr)
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(fvalue_edit), TRUE);
g_signal_connect(fvalue_edit, "value-changed", G_CALLBACK(finfo_integer_changed), DataPtr);
- } else if (finfo_type == FT_STRING || finfo_type == FT_STRINGZ) {
+ } else if (finfo_type == FT_STRING || finfo_type == FT_STRINGZ || finfo_type == FT_STRINGZPAD) {
fvalue_edit = gtk_entry_new();
gtk_entry_set_max_length(GTK_ENTRY(fvalue_edit), finfo->length);
gtk_entry_set_text(GTK_ENTRY(fvalue_edit), (const gchar*) fvalue_get(&finfo->value));
diff --git a/ui/qt/decode_as_dialog.cpp b/ui/qt/decode_as_dialog.cpp
index 8715fd5c91..f384d01a50 100644
--- a/ui/qt/decode_as_dialog.cpp
+++ b/ui/qt/decode_as_dialog.cpp
@@ -138,6 +138,8 @@ QString DecodeAsDialog::entryString(const gchar *table_name, gpointer value)
case FT_STRING:
case FT_STRINGZ:
+ case FT_UINT_STRING:
+ case FT_STRINGZPAD:
entry_str = (char *)value;
break;
@@ -341,7 +343,7 @@ void DecodeAsDialog::fillTypeColumn(QTreeWidgetItem *item)
ftenum_t selector_type = get_dissector_table_selector_type(table_name);
- if (selector_type == FT_STRING || selector_type == FT_STRINGZ) {
+ if (IS_FT_STRING(selector_type)) {
item->setText(type_col_, tr("String"));
} else {
QString type_desc = tr("Integer, base ");
@@ -430,7 +432,7 @@ void DecodeAsDialog::tableNamesCurrentIndexChanged(const QString &text)
selector_combo_box_->setCurrentIndex(0);
} else {
ftenum_t selector_type = get_dissector_table_selector_type(ui_name_to_name_[text]);
- if (selector_type == FT_STRING || selector_type == FT_STRINGZ) {
+ if (IS_FT_STRING(selector_type)) {
selector_combo_box_->setEditText(default_str_selector_);
} else {
selector_combo_box_->setEditText(default_int_selector_);
@@ -463,7 +465,7 @@ void DecodeAsDialog::selectorEditTextChanged(const QString &text)
ftenum_t selector_type = get_dissector_table_selector_type(table_name);
dissector_handle_t dissector;
- if (selector_type == FT_STRING || selector_type == FT_STRINGZ) {
+ if (IS_FT_STRING(selector_type)) {
dissector = dissector_get_default_string_handle(table_name, text.toUtf8().constData());
} else {
dissector = dissector_get_default_uint_handle(table_name, text.toInt(NULL, 0));