From a344c9736efe5519543da1290e1ad9065d0b0cff Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 23 May 2014 10:50:02 +0000 Subject: Revert "Allow wtap_read() and wtap_seek_read() to return non-packet records." This reverts commit c0c480d08c175eed4524ea9e73ec86298f468cf4. A better way to do this is to have the record type be part of struct wtap_pkthdr; that keeps the metadata for the record together and requires fewer API changes. That is in-progress. Change-Id: Ic558f163a48e2c6d0df7f55e81a35a5e24b53bc6 Reviewed-on: https://code.wireshark.org/review/1741 Reviewed-by: Guy Harris --- ui/win32/file_dlg_win32.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'ui/win32') diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c index 47cf06cd4c..a65aaf4d0f 100644 --- a/ui/win32/file_dlg_win32.c +++ b/ui/win32/file_dlg_win32.c @@ -1119,10 +1119,8 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) { int err = 0; gchar *err_info; TCHAR string_buff[PREVIEW_STR_MAX]; - int rec_type; gint64 data_offset; - guint records = 0; - guint packets = 0; + guint packet = 0; gint64 filesize; time_t ti_time; struct tm *ti_tm; @@ -1188,24 +1186,21 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) { SetWindowText(cur_ctrl, string_buff); time(&time_preview); - while ( (rec_type = wtap_read(wth, &err, &err_info, &data_offset)) != -1 ) { - if (rec_type == REC_TYPE_PACKET) { - phdr = wtap_phdr(wth); - cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts ); - if(packets == 0) { - start_time = cur_time; - stop_time = cur_time; - } - if (cur_time < start_time) { - start_time = cur_time; - } - if (cur_time > stop_time){ - stop_time = cur_time; - } - packets++; + while ( (wtap_read(wth, &err, &err_info, &data_offset)) ) { + phdr = wtap_phdr(wth); + cur_time = nstime_to_sec( (const nstime_t *) &phdr->ts ); + if(packet == 0) { + start_time = cur_time; + stop_time = cur_time; + } + if (cur_time < start_time) { + start_time = cur_time; + } + if (cur_time > stop_time){ + stop_time = cur_time; } - records++; - if(records%100 == 0) { + packet++; + if(packet%100 == 0) { time(&time_current); if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) { is_breaked = TRUE; @@ -1215,7 +1210,7 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) { } if(err != 0) { - StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packets); + StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packet); cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS); SetWindowText(cur_ctrl, string_buff); wtap_close(wth); @@ -1224,9 +1219,9 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) { /* Packets */ if(is_breaked) { - StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packets); + StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packet); } else { - StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packets); + StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packet); } cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS); SetWindowText(cur_ctrl, string_buff); -- cgit v1.2.3