forked from osmocom/wireshark
tshark: load decode_as_entries file
With Wireshark 2.0, some dissector preferences were removed in favor of 'Decode As' functionality. But the settings saved in the GUI are not loaded in tshark, preventing their use without an explicit call to '-d' option. Let's load decode_as_entries file by default and have it overridden by the '-d' option if required. Ping-Bug: 12124 Change-Id: I134a424cb6cf8fc89b7096a659ef1605314a70a2 Reviewed-on: https://code.wireshark.org/review/13956 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
8889be17d0
commit
14881e72d6
4
tshark.c
4
tshark.c
|
@ -85,6 +85,7 @@
|
|||
#endif
|
||||
#include "ui/util.h"
|
||||
#include "ui/ui_util.h"
|
||||
#include "ui/decode_as_utils.h"
|
||||
#include "ui/cli/tshark-tap.h"
|
||||
#include "register.h"
|
||||
#include "filter_files.h"
|
||||
|
@ -1297,6 +1298,9 @@ main(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* load the decode as entries of this profile */
|
||||
load_decode_as_entries();
|
||||
|
||||
tshark_debug("tshark reading preferences");
|
||||
|
||||
prefs_p = read_prefs(&gpf_open_errno, &gpf_read_errno, &gpf_path,
|
||||
|
|
|
@ -312,28 +312,26 @@ decode_as_write_entry (const gchar *table_name, ftenum_t selector_type,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
save_decode_as_entries(void)
|
||||
int
|
||||
save_decode_as_entries(gchar** err)
|
||||
{
|
||||
char *pf_dir_path;
|
||||
char *daf_path;
|
||||
FILE *da_file;
|
||||
|
||||
if (create_persconffile_dir(&pf_dir_path) == -1) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path,
|
||||
g_strerror(errno));
|
||||
*err = g_strdup_printf("Can't create directory\n\"%s\"\nfor recent file: %s.",
|
||||
pf_dir_path, g_strerror(errno));
|
||||
g_free(pf_dir_path);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
daf_path = get_persconffile_path(DECODE_AS_ENTRIES_FILE_NAME, TRUE);
|
||||
if ((da_file = ws_fopen(daf_path, "w")) == NULL) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
|
||||
"Can't open decode_as_entries file\n\"%s\": %s.", daf_path,
|
||||
g_strerror(errno));
|
||||
*err = g_strdup_printf("Can't open decode_as_entries file\n\"%s\": %s.",
|
||||
daf_path, g_strerror(errno));
|
||||
g_free(daf_path);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
fputs("# \"Decode As\" entries file for Wireshark " VERSION ".\n"
|
||||
|
@ -344,6 +342,7 @@ save_decode_as_entries(void)
|
|||
|
||||
dissector_all_tables_foreach_changed(decode_as_write_entry, da_file);
|
||||
fclose(da_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -41,7 +41,7 @@ void load_decode_as_entries(void);
|
|||
|
||||
/** Write out the "decode as" entries of the current profile.
|
||||
*/
|
||||
void save_decode_as_entries(void);
|
||||
int save_decode_as_entries(gchar** err);
|
||||
|
||||
/** This routine creates one entry in the list of protocol dissector
|
||||
* that need to be reset. It is called by the g_hash_table_foreach
|
||||
|
|
|
@ -441,7 +441,13 @@ decode_show_destroy_cb (GtkWidget *win _U_, gpointer user_data _U_)
|
|||
static void
|
||||
decode_show_save_cb (GtkWidget *win _U_, gpointer user_data _U_)
|
||||
{
|
||||
save_decode_as_entries();
|
||||
gchar* err = NULL;
|
||||
|
||||
if (save_decode_as_entries(&err) < 0)
|
||||
{
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err);
|
||||
g_free(err);
|
||||
}
|
||||
}
|
||||
|
||||
/* add a single binding to the Show list */
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "epan/epan_dissect.h"
|
||||
|
||||
#include "ui/decode_as_utils.h"
|
||||
#include "ui/simple_dialog.h"
|
||||
#include <wsutil/utf8_entities.h>
|
||||
|
||||
#include "qt_ui_utils.h"
|
||||
|
@ -640,8 +641,15 @@ void DecodeAsDialog::on_buttonBox_clicked(QAbstractButton *button)
|
|||
applyChanges();
|
||||
break;
|
||||
case QDialogButtonBox::Save:
|
||||
{
|
||||
gchar* err = NULL;
|
||||
|
||||
applyChanges();
|
||||
save_decode_as_entries();
|
||||
if (save_decode_as_entries(&err) < 0) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err);
|
||||
g_free(err);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QDialogButtonBox::Help:
|
||||
wsApp->helpTopicAction(HELP_DECODE_AS_SHOW_DIALOG);
|
||||
|
|
Loading…
Reference in New Issue