aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-03-20 12:57:29 -0400
committerAnders Broman <a.broman58@gmail.com>2014-03-21 17:51:45 +0000
commitd1873dbcc89eb3138027d8e5c5e4c5b12420e797 (patch)
tree3798641bfbe067ef123d9ba125371b7090e7c7fd /file.c
parent49be990fd3ec0faac89b0a0bcda9a3e4562820ab (diff)
Fix Bug 9903: 'Clicking reload-file ignores selected file format reader'
There's a relatively new feature in 1.11.3 to select a specific file format reader, instead of relying on magics or heuristics. If you select a file reader and open a file, open it, and then click the reload-file button or go to View->Reload or press the ctrl-R keymap, the file is reloaded but using the magic/heuristics again instead of the file format reader you previously chose. Likewise, the Lua relaod() function has the same issue (which is how I found this problem). I have tested this change by hand, using a Lua script, but I didn't add it to the testsuite because I need another change for my test script to work correctly. (an enhancement rather than a bug fix, which I'll submit separately) Change-Id: I48c2d9ea443e37fd9d41be43d6b6cd5a866d5b01 Reviewed-on: https://code.wireshark.org/review/764 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'file.c')
-rw-r--r--file.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/file.c b/file.c
index d57e0a9b8b..a37a0524ab 100644
--- a/file.c
+++ b/file.c
@@ -376,6 +376,7 @@ cf_open(capture_file *cf, const char *fname, unsigned int type, gboolean is_temp
cf->computed_elapsed = 0;
cf->cd_t = wtap_file_type_subtype(cf->wth);
+ cf->open_type = type;
cf->linktypes = g_array_sized_new(FALSE, FALSE, (guint) sizeof(int), 1);
cf->count = 0;
cf->packet_comment_count = 0;
@@ -470,6 +471,9 @@ cf_reset_state(capture_file *cf)
/* ...which means we have no changes to that file to save. */
cf->unsaved_changes = FALSE;
+ /* no open_routine type */
+ cf->open_type = WTAP_TYPE_AUTO;
+
/* Free up the packet buffer. */
buffer_free(&cf->buf);
@@ -4334,6 +4338,11 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
wtap_close(cf->wth);
/* Open the new file. */
+ /* XXX: this will go through all open_routines for a matching one. But right
+ now rescan_file() is only used when a file is being saved to a different
+ format than the original, and the user is not given a choice of which
+ reader to use (only which format to save it in), so doing this makes
+ sense for now. */
cf->wth = wtap_open_offline(fname, WTAP_TYPE_AUTO, err, &err_info, TRUE);
if (cf->wth == NULL) {
cf_open_failure_alert_box(fname, *err, err_info, FALSE, 0);
@@ -4768,6 +4777,10 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
the wtap structure, the filename, and the "is temporary"
status applies to the new file; just update that. */
wtap_close(cf->wth);
+ /* Although we're just "copying" and then opening the copy, it will
+ try all open_routine readers to open the copy, so we need to
+ reset the cfile's open_type. */
+ cf->open_type = WTAP_TYPE_AUTO;
cf->wth = wtap_open_offline(fname, WTAP_TYPE_AUTO, &err, &err_info, TRUE);
if (cf->wth == NULL) {
cf_open_failure_alert_box(fname, err, err_info, FALSE, 0);
@@ -4799,6 +4812,9 @@ cf_save_packets(capture_file *cf, const char *fname, guint save_format,
...as long as, for gzipped files, the process of writing
out the file *also* generates the information needed to
support fast random access to the compressed file. */
+ /* rescan_file will cause us to try all open_routines, so
+ reset cfile's open_type */
+ cf->open_type = WTAP_TYPE_AUTO;
if (rescan_file(cf, fname, FALSE, &err) != CF_READ_OK) {
/* The rescan failed; just close the file. Either
a dialog was popped up for the failure, so the
@@ -5210,7 +5226,7 @@ cf_reload(capture_file *cf) {
filename = g_strdup(cf->filename);
is_tempfile = cf->is_tempfile;
cf->is_tempfile = FALSE;
- if (cf_open(cf, filename, WTAP_TYPE_AUTO, is_tempfile, &err) == CF_OK) {
+ if (cf_open(cf, filename, cf->open_type, is_tempfile, &err) == CF_OK) {
switch (cf_read(cf, TRUE)) {
case CF_READ_OK: