remove #include "globals.h" and access to global cfile, use access functions and...
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 4 Feb 2005 08:27:41 +0000 (08:27 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 4 Feb 2005 08:27:41 +0000 (08:27 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@13283 f5534014-38df-0310-8fa8-9805f1628bb7

capture.c
file.c
file.h

index a94430591e5d8a0e4acb4040a7fd130a03155653..3355167038e572bdb0fa0610b9396f271c9905bb 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -61,7 +61,6 @@
 #include "alert_box.h"
 #include "simple_dialog.h"
 #include <epan/prefs.h>
-#include "globals.h"
 #include "conditions.h"
 #include "ringbuffer.h"
 
@@ -128,10 +127,10 @@ capture_open_output(capture_options *capture_opts, const char *save_file, gboole
   }
 
   /* close the old file */
-  cf_close(&cfile);
+  cf_close(capture_opts->cf);
   g_assert(capture_opts->save_file == NULL);
   capture_opts->save_file = capfile_name;
-  /* cfile.save_file is "g_free"ed later, which is equivalent to
+  /* capture_opts.save_file is "g_free"ed later, which is equivalent to
      "g_free(capfile_name)". */
 
   return TRUE;
@@ -154,7 +153,7 @@ do_capture(capture_options *capture_opts, const char *save_file)
   }
 
   title = g_strdup_printf("%s: Capturing - Ethereal",
-                          get_interface_descriptive_name(cfile.iface));
+                          get_interface_descriptive_name(cf_get_iface(capture_opts->cf)));
   if (capture_opts->sync_mode) {       
     /* sync mode: do the capture in a child process */
     ret = sync_pipe_do_capture(capture_opts, is_tempfile);
@@ -199,7 +198,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
       return FALSE;
     }
     /* Capture succeeded; attempt to read in the capture file. */
-    if ((err = cf_open(capture_opts->save_file, is_tempfile, &cfile)) != 0) {
+    if ((err = cf_open(capture_opts->save_file, is_tempfile, capture_opts->cf)) != 0) {
       /* We're not doing a capture any more, so we don't have a save
         file. */
       if (capture_opts->multi_files_on) {
@@ -212,7 +211,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
     }
 
     /* Set the read filter to NULL. */
-    cfile.rfcode = NULL;
+    cf_set_rfcode(capture_opts->cf, NULL);
 
     /* Get the packet-drop statistics.
 
@@ -233,7 +232,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
        thus not have to set them here - "cf_read()" will get them from
        the file and use them. */
     if (stats_known) {
-      cfile.drops_known = TRUE;
+      cf_set_drops_known(capture_opts->cf, TRUE);
 
       /* XXX - on some systems, libpcap doesn't bother filling in
          "ps_ifdrop" - it doesn't even set it to zero - so we don't
@@ -243,9 +242,9 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
          several statistics - perhaps including various interface
          error statistics - and would tell us which of them it
          supplies, allowing us to display only the ones it does. */
-      cfile.drops = stats.ps_drop;
+      cf_set_drops(capture_opts->cf, stats.ps_drop);
     }
-    switch (cf_read(&cfile)) {
+    switch (cf_read(capture_opts->cf)) {
 
     case READ_SUCCESS:
     case READ_ERROR:
@@ -271,13 +270,13 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
     capture_opts->save_file = NULL;
 
     /* if we didn't captured even a single packet, close the file again */
-    if(cfile.count == 0) {
+    if(cf_packet_count(capture_opts->cf) == 0) {
       simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, 
       "%sNo packets captured!%s\n\n"
       "As no data was captured, closing the %scapture file!",
       simple_dialog_primary_start(), simple_dialog_primary_end(),
-      (cfile.is_tempfile) ? "temporary " : "");
-      cf_close(&cfile);
+      (cf_is_tempfile(capture_opts->cf)) ? "temporary " : "");
+      cf_close(capture_opts->cf);
     }
   return TRUE;
 }
diff --git a/file.c b/file.c
index 6e446135a6ac1ce3021839bdb4febbdce09e13b7..a5a395fd6db17111a950526094a2b5daed4a7b44 100644 (file)
--- a/file.c
+++ b/file.c
@@ -714,6 +714,14 @@ cf_packet_count(capture_file *cf)
     return cf->count;
 }
 
+/* XXX - use a macro instead? */
+/* XXX - move iface this to capture_opts? */
+gchar *
+cf_get_iface(capture_file *cf)
+{
+    return cf->iface;
+}
+
 /* XXX - use a macro instead? */
 gboolean
 cf_is_tempfile(capture_file *cf)
@@ -733,6 +741,12 @@ void cf_set_drops(capture_file *cf, guint32 drops)
     cf->drops = drops;
 }
 
+void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode)
+{
+    cf->rfcode = rfcode;
+}
+
+
 typedef struct {
   color_filter_t *colorf;
   epan_dissect_t *edt;
diff --git a/file.h b/file.h
index fb1b3f97d6b8869934a2303f7afc8ddc60f245bb..1584f994ad31682a06a1f37c5660e01a69e2d483 100644 (file)
--- a/file.h
+++ b/file.h
@@ -56,6 +56,8 @@ int cf_packet_count(capture_file *cf);
 gboolean cf_is_tempfile(capture_file *cf);
 void cf_set_drops_known(capture_file *cf, gboolean drops_known);
 void cf_set_drops(capture_file *cf, guint32 drops);
+gchar *cf_get_iface(capture_file *cf);
+void cf_set_rfcode(capture_file *cf, dfilter_t *rfcode);
 
 gboolean
 cf_merge_files(const char *out_filename, int out_fd, int in_file_count,