Have "f_datalen" keep track of the number of bytes of uncompressed file
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 19 Aug 2005 01:17:24 +0000 (01:17 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 19 Aug 2005 01:17:24 +0000 (01:17 +0000)
data, so that "f_len" still keeps the size of the underlying file (which
is necessary in order to make the progress bar when files are being read
work correctly).

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15415 f5534014-38df-0310-8fa8-9805f1628bb7

cfile.h
file.c
gtk/main.c
summary.c
tethereal.c

diff --git a/cfile.h b/cfile.h
index 3dc11d4da46119762ad29fa008e956994d28f73c..d78461c72d90f4da6f11cef22baaee0ad5723de5 100644 (file)
--- a/cfile.h
+++ b/cfile.h
@@ -47,7 +47,8 @@ typedef struct _capture_file {
   gchar       *filename;  /* Name of capture file */
   gboolean     is_tempfile; /* Is capture file a temporary file? */
   gboolean     user_saved;/* If capture file is temporary, has it been saved by user yet? */
-  long         f_len;     /* Length of capture file */
+  long         f_datalen; /* Size of capture file data (uncompressed) */
+  long         f_len;     /* Length of capture file (compressed if file is) */
   guint16      cd_t;      /* File type of capture file */
   int          lnk_t;     /* Link-layer type with which to save capture */
   guint32      vers;      /* Version.  For tcpdump minor is appended to major */
diff --git a/file.c b/file.c
index 74c8978a478db00562aa878cef32b69bc44778f4..e79b8e3aaa7e2cc46c89bdc90ed818a40efbfd2c 100644 (file)
--- a/file.c
+++ b/file.c
@@ -199,6 +199,7 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
 
   cf->wth = wth;
   cf->filed = fd;
+  cf->f_datalen = 0;
   cf->f_len = cf_stat.st_size;
 
   /* Set the file name because we need it to set the follow stream filter.
@@ -297,6 +298,7 @@ cf_reset_state(capture_file *cf)
   packet_list_clear();
   packet_list_thaw();
 
+  cf->f_datalen = 0;
   cf->f_len = 0;
   cf->count = 0;
   cf->esec  = 0;
@@ -891,7 +893,7 @@ read_packet(capture_file *cf, long offset)
     cf->plist_end = fdata;
 
     cf->count++;
-    cf->f_len = offset + phdr->caplen;
+    cf->f_datalen = offset + phdr->caplen;
     fdata->num = cf->count;
     add_packet_to_packet_list(fdata, cf, pseudo_header, buf, TRUE);
   } else {
index e33d622717dd2a8c76c117d06df3df82dd8b58b4..5e99501c808832cbe41fec87ecd11fe9a56a584e 100644 (file)
@@ -1209,12 +1209,12 @@ set_display_filename(capture_file *cf)
   }
 
   /* convert file size */
-  if (cf->f_len/1024/1024 > 10) {
-    size_str = g_strdup_printf("%ld MB", cf->f_len/1024/1024);
-  } else if (cf->f_len/1024 > 10) {
-    size_str = g_strdup_printf("%ld KB", cf->f_len/1024);
+  if (cf->f_datalen/1024/1024 > 10) {
+    size_str = g_strdup_printf("%ld MB", cf->f_datalen/1024/1024);
+  } else if (cf->f_datalen/1024 > 10) {
+    size_str = g_strdup_printf("%ld KB", cf->f_datalen/1024);
   } else {
-    size_str = g_strdup_printf("%ld Bytes", cf->f_len);
+    size_str = g_strdup_printf("%ld Bytes", cf->f_datalen);
   }
 
   /* statusbar */
@@ -1352,21 +1352,21 @@ main_cf_cb_live_capture_update_continue(capture_file *cf)
 
     statusbar_pop_file_msg();
 
-    if (cf->f_len/1024/1024 > 10) {
+    if (cf->f_datalen/1024/1024 > 10) {
         capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld MB", 
             get_interface_descriptive_name(capture_opts->iface), 
             capture_opts->save_file,
-            cf->f_len/1024/1024);
-    } else if (cf->f_len/1024 > 10) {
+            cf->f_datalen/1024/1024);
+    } else if (cf->f_datalen/1024 > 10) {
         capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld KB", 
             get_interface_descriptive_name(capture_opts->iface), 
             capture_opts->save_file,
-            cf->f_len/1024);
+            cf->f_datalen/1024);
     } else {
         capture_msg = g_strdup_printf(" %s: <live capture in progress> File: %s %ld Bytes", 
             get_interface_descriptive_name(capture_opts->iface), 
             capture_opts->save_file,
-            cf->f_len);
+            cf->f_datalen);
     }
 
     statusbar_push_file_msg(capture_msg);
index e9df777805c3b1d2914c1c50aa7dabfcc45efb85..511cf47f18bd87b86db6932963f9eb319cfce89f 100644 (file)
--- a/summary.c
+++ b/summary.c
@@ -106,7 +106,7 @@ summary_fill_in(capture_file *cf, summary_tally *st)
   }
 
   st->filename = cf->filename;
-  st->file_length = cf->f_len;
+  st->file_length = cf->f_datalen;
   st->encap_type = cf->cd_t;
   st->has_snap = cf->has_snap;
   st->snap = cf->snap;
index 92595f32751262f322751c70dc12c1c438f705a8..ec69777f28963f775c71a3e20dac2761a9ea018e 100644 (file)
@@ -2970,6 +2970,7 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
 
   cf->wth = wth;
   cf->filed = -1;      /* not used, but set it anyway */
+  cf->f_datalen = 0;   /* not used, but set it anyway */
   cf->f_len = 0;       /* not used, but set it anyway */
 
   /* Set the file name because we need it to set the follow stream filter.