X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=file.c;h=c69e0ea51877738d14db5580992c228454b6d727;hb=0da36541d458c445f51633972348fef48e946616;hp=3e463a088a825823371015bcb42845efd7ea06dd;hpb=f228de72c3c2a7f680986fa6a72f611b054bdd19;p=obnox%2Fwireshark%2Fwip.git diff --git a/file.c b/file.c index 3e463a088a..c69e0ea518 100644 --- a/file.c +++ b/file.c @@ -60,6 +60,7 @@ #include "merge.h" #include "alert_box.h" #include "simple_dialog.h" +#include "main_statusbar.h" #include "progress_dlg.h" #include "ui_util.h" #include @@ -320,6 +321,7 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err) cf->displayed_count = 0; cf->marked_count = 0; cf->ignored_count = 0; + cf->ref_time_count = 0; cf->drops_known = FALSE; cf->drops = 0; cf->snap = wtap_snapshot_length(cf->wth); @@ -472,24 +474,46 @@ static void outofmemory_cb(gpointer dialog _U_, gint btn _U_, gpointer data _U_) main_window_exit(); } -static float calc_progbar_val(capture_file *cf, gint64 size, gint64 file_pos){ - +static float +calc_progbar_val(capture_file *cf, gint64 size, gint64 file_pos, gchar *status_str, gulong status_size) +{ float progbar_val; progbar_val = (gfloat) file_pos / (gfloat) size; if (progbar_val > 1.0) { - /* The file probably grew while we were reading it. - Update file size, and try again. */ + + /* The file probably grew while we were reading it. + * Update file size, and try again. + */ size = wtap_file_size(cf->wth, NULL); + + /* Another possibility is that we're reading a compressed file and we've + * read more (uncompressed) data from the file than exists in the + * (compressed) file. So check how much data we've actually read. + * + * This is inside this "if val > 1.0" check to avoid the lseek() when + * reading uncompressed files. Testing has (thus far) shown no progress + * bar weirdness resulting from switching from the data offset (when + * reading the first part of the file) to the real file position. + */ + file_pos = wtap_read_so_far(cf->wth, NULL); + if (size >= 0) progbar_val = (gfloat) file_pos / (gfloat) size; - /* If it's still > 1, either "wtap_file_size()" failed (in which - case there's not much we can do about it), or the file - *shrank* (in which case there's not much we can do about - it); just clip the progress value at 1.0. */ + + /* If it's still > 1, either "wtap_file_size()" failed (in which + * case there's not much we can do about it), or the file + * *shrank* (in which case there's not much we can do about + * it); just clip the progress value at 1.0. + */ if (progbar_val > 1.0f) progbar_val = 1.0f; } + + g_snprintf(status_str, status_size, + "%" G_GINT64_MODIFIER "dKB of %" G_GINT64_MODIFIER "dKB", + file_pos / 1024, size / 1024); + return progbar_val; } @@ -570,10 +594,10 @@ cf_read(capture_file *cf, gboolean from_save) if (size >= 0) { count++; /* Create the progress bar if necessary. - * Check wether it should be created or not every MIN_NUMBER_OF_PACKET + * Check whether it should be created or not every MIN_NUMBER_OF_PACKET */ if ((progbar == NULL) && !(count % MIN_NUMBER_OF_PACKET)){ - progbar_val = calc_progbar_val( cf, size, data_offset); + progbar_val = calc_progbar_val(cf, size, data_offset, status_str, sizeof(status_str)); if (from_save == FALSE) progbar = delayed_create_progress_dlg("Loading", name_ptr, TRUE, &stop_flag, &start_time, progbar_val); @@ -589,7 +613,7 @@ cf_read(capture_file *cf, gboolean from_save) that for every packet can be costly, especially on a big file. */ if (data_offset >= progbar_nextstep) { if (progbar != NULL) { - progbar_val = calc_progbar_val( cf, size, data_offset); + progbar_val = calc_progbar_val(cf, size, data_offset, status_str, sizeof(status_str)); /* update the packet lists content on the first run or frequently on very large files */ /* (on smaller files the display update takes longer than reading the file) */ #ifdef HAVE_LIBPCAP @@ -610,9 +634,6 @@ cf_read(capture_file *cf, gboolean from_save) } } #endif /* HAVE_LIBPCAP */ - g_snprintf(status_str, sizeof(status_str), - "%" G_GINT64_MODIFIER "dKB of %" G_GINT64_MODIFIER "dKB", - data_offset / 1024, size / 1024); update_progress_dlg(progbar, progbar_val, status_str); } progbar_nextstep += progbar_quantum; @@ -1828,7 +1849,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, start? */ selected_frame = cf->current_frame; - /* Mark frane num as not found */ + /* Mark frame num as not found */ selected_frame_num = -1; /* Freeze the packet list while we redo it, so we don't get any @@ -2096,8 +2117,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, progdlg_t *progbar = NULL; gboolean stop_flag; int count; - int err; - gchar *err_info; frame_data *selected_frame, *preceding_frame, *following_frame, *prev_frame; int selected_row, prev_row, preceding_row, following_row; gboolean selected_frame_seen; @@ -3913,12 +3932,12 @@ find_packet(capture_file *cf, if (prefs.gui_find_wrap) { - simple_status("Search reached the beginning. Continuing at end."); + statusbar_push_temporary_msg("Search reached the beginning. Continuing at end."); fdata = cf->plist_end; /* wrap around */ } else { - simple_status("Search reached the beginning."); + statusbar_push_temporary_msg("Search reached the beginning."); fdata = start_fd; /* stay on previous packet */ } } @@ -3928,12 +3947,12 @@ find_packet(capture_file *cf, if (fdata == NULL) { if (prefs.gui_find_wrap) { - simple_status("Search reached the end. Continuing at beginning."); + statusbar_push_temporary_msg("Search reached the end. Continuing at beginning."); fdata = cf->plist_start; /* wrap around */ } else { - simple_status("Search reached the end."); + statusbar_push_temporary_msg("Search reached the end."); fdata = start_fd; /* stay on previous packet */ } } @@ -4009,13 +4028,13 @@ cf_goto_frame(capture_file *cf, guint fnumber) if (fdata == NULL) { /* we didn't find a packet with that packet number */ - simple_status("There is no packet number %u.", fnumber); + statusbar_push_temporary_msg("There is no packet number %u.", fnumber); return FALSE; /* we failed to go to that packet */ } if (!fdata->flags.passed_dfilter) { /* that packet currently isn't displayed */ /* XXX - add it to the set of displayed packets? */ - simple_status("Packet number %u isn't displayed.", fnumber); + statusbar_push_temporary_msg("Packet number %u isn't displayed.", fnumber); return FALSE; /* we failed to go to that packet */ }