summaryrefslogtreecommitdiff
path: root/ui/win32
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-05-22 20:01:31 -0700
committerGuy Harris <guy@alum.mit.edu>2014-05-23 03:02:32 +0000
commitc0c480d08c175eed4524ea9e73ec86298f468cf4 (patch)
tree1234cd09094dcc8447e3fb2b13671f12aba5ae69 /ui/win32
parent6287efb9c05482531ea675bb5a3d23b03b5715ab (diff)
downloadwireshark-c0c480d08c175eed4524ea9e73ec86298f468cf4.tar.gz
Allow wtap_read() and wtap_seek_read() to return non-packet records.
This is the first step towards implementing the mechanisms requestd in bug 8590; currently, we don't return any records other than packet records from libwiretap, and just ignore non-packet records in the rest of Wireshark, but this at least gets the ball rolling. Change-Id: I34a45b54dd361f69fdad1a758d8ca4f42d67d574 Reviewed-on: https://code.wireshark.org/review/1736 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/win32')
-rw-r--r--ui/win32/file_dlg_win32.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index a65aaf4d0f..47cf06cd4c 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -1119,8 +1119,10 @@ 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 packet = 0;
+ guint records = 0;
+ guint packets = 0;
gint64 filesize;
time_t ti_time;
struct tm *ti_tm;
@@ -1186,21 +1188,24 @@ preview_set_file_info(HWND of_hwnd, gchar *preview_file) {
SetWindowText(cur_ctrl, string_buff);
time(&time_preview);
- 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;
+ 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++;
}
- packet++;
- if(packet%100 == 0) {
+ records++;
+ if(records%100 == 0) {
time(&time_current);
if(time_current-time_preview >= (time_t) prefs.gui_fileopen_preview) {
is_breaked = TRUE;
@@ -1210,7 +1215,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"), packet);
+ StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("error after reading %u packets"), packets);
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
SetWindowText(cur_ctrl, string_buff);
wtap_close(wth);
@@ -1219,9 +1224,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)"), packet);
+ StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("more than %u packets (preview timeout)"), packets);
} else {
- StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packet);
+ StringCchPrintf(string_buff, PREVIEW_STR_MAX, _T("%u"), packets);
}
cur_ctrl = GetDlgItem(of_hwnd, EWFD_PTX_PACKETS);
SetWindowText(cur_ctrl, string_buff);