"read_cap_file()" doesn't need to be passed a file name as an argument -
authorGuy Harris <guy@alum.mit.edu>
Sun, 15 Aug 1999 01:02:26 +0000 (01:02 -0000)
committerGuy Harris <guy@alum.mit.edu>
Sun, 15 Aug 1999 01:02:26 +0000 (01:02 -0000)
it's called after "open_cap_file()" has been called, and is always
passed the file name passed to "open_cap_file()", and that file name is
stored as "cf->filename", so "read_cap_file()" can just use
"cf->filename" as the pathname of the file.

svn path=/trunk/; revision=494

capture.c
ethereal.c
file.c
file.h

index 106fc1302e7ec3b9590d46893da573b846fae608..df888226376972a62bec952206b97d983421623e 100644 (file)
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
 /* capture.c
  * Routines for packet capture windows
  *
- * $Id: capture.c,v 1.48 1999/08/15 00:26:10 guy Exp $
+ * $Id: capture.c,v 1.49 1999/08/15 01:02:24 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -626,7 +626,7 @@ capture(void) {
     /* "pch" is non-NULL only if we successfully started a capture.
        If we haven't, there's no capture file to load. */
     if ((err = open_cap_file(cf.save_file, &cf)) == 0 &&
-       (err = read_cap_file(cf.save_file, NULL, &cf)) == 0) {
+       (err = read_cap_file(NULL, &cf)) == 0) {
       set_menu_sensitivity("/File/Save", TRUE);
       set_menu_sensitivity("/File/Save As...", FALSE);
     }
index e23b08ccca48c196be1ae258eea090dd54ea7e0b..ced9adae6e8b78470cd71a8b36f716bad2c3d769 100644 (file)
@@ -1,6 +1,6 @@
-/* ETHEREal.c
+/* ethereal.c
  *
- * $Id: ethereal.c,v 1.86 1999/08/15 00:26:09 guy Exp $
+ * $Id: ethereal.c,v 1.87 1999/08/15 01:02:24 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -447,7 +447,7 @@ file_open_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
   gtk_widget_destroy(GTK_WIDGET (fs));
 
   /* save the directory name. We can write over cf_name */
-  if ((err = read_cap_file(cf_name, rfilter, &cf)) == 0) {
+  if ((err = read_cap_file(rfilter, &cf)) == 0) {
          s = strrchr(cf_name, '/');
          if (s && last_open_dir) {
                  *s = '\0';
@@ -528,7 +528,7 @@ file_save_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
        cf.save_file = g_strdup(cf_name);
        cf.user_saved = 1;
         if ((err = open_cap_file(cf_name, &cf)) == 0 &&
-           (err = read_cap_file(cf_name, g_strdup(cf.rfilter), &cf)) == 0) {
+           (err = read_cap_file(g_strdup(cf.rfilter), &cf)) == 0) {
                set_menu_sensitivity("/File/Save", FALSE);
                set_menu_sensitivity("/File/Save As...", TRUE);
        }
@@ -548,7 +548,7 @@ file_save_as_ok_cb(GtkWidget *w, GtkFileSelection *fs) {
        cf.filename = g_strdup(cf_name);
        cf.user_saved = 1;
         if ((err = open_cap_file(cf.filename, &cf)) == 0 &&
-           (err = read_cap_file(cf.filename, g_strdup(cf.rfilter), &cf)) == 0) {
+           (err = read_cap_file(g_strdup(cf.rfilter), &cf)) == 0) {
                set_menu_sensitivity("/File/Save", FALSE);
                set_menu_sensitivity("/File/Save As...", TRUE);
        }
@@ -565,7 +565,7 @@ file_reload_cmd_cb(GtkWidget *w, gpointer data) {
   if (cf.dfilter) g_free(cf.dfilter);
   cf.dfilter = g_strdup(gtk_entry_get_text(GTK_ENTRY(filter_te)));
   if (open_cap_file(cf.filename, &cf) == 0)
-    read_cap_file(cf.filename, g_strdup(cf.rfilter), &cf);
+    read_cap_file(g_strdup(cf.rfilter), &cf);
   /* XXX - change the menu if it fails? */
 }
 
@@ -1416,7 +1416,7 @@ main(int argc, char *argv[])
      up on top of us. */
   if (cf_name) {
     if ((err = open_cap_file(cf_name, &cf)) == 0)
-       err = read_cap_file(cf_name, rfilter, &cf);
+       err = read_cap_file(rfilter, &cf);
     cf_name[0] = '\0';
     if (err == 0)
       set_menu_sensitivity("/File/Save As...", TRUE);
diff --git a/file.c b/file.c
index b34e86d702bed310f5022de70e679315401f45b2..09fa256a5cf823c277d385c1a219066bb1651d39 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
 /* file.c
  * File I/O routines
  *
- * $Id: file.c,v 1.69 1999/08/15 00:55:22 guy Exp $
+ * $Id: file.c,v 1.70 1999/08/15 01:02:25 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -210,15 +210,15 @@ close_cap_file(capture_file *cf, void *w, guint context) {
 }
 
 int
-read_cap_file(char *fname, char *rfilter, capture_file *cf) {
+read_cap_file(char *rfilter, capture_file *cf) {
   gchar  *name_ptr, *load_msg, *load_fmt = " Loading: %s...";
   gchar  *done_fmt = " File: %s  Drops: %d";
   gchar  *err_fmt  = " Error: Could not load '%s'";
   gint    timeout;
   size_t  msg_len;
 
-  if ((name_ptr = (gchar *) strrchr(fname, '/')) == NULL)
-    name_ptr = fname;
+  if ((name_ptr = (gchar *) strrchr(cf->filename, '/')) == NULL)
+    name_ptr = cf->filename;
   else
     name_ptr++;
 
@@ -241,7 +241,7 @@ read_cap_file(char *fname, char *rfilter, capture_file *cf) {
   wtap_loop(cf->wth, 0, wtap_dispatch_cb, (u_char *) cf);
   wtap_close(cf->wth);
   cf->wth = NULL;
-  cf->fh = fopen(fname, "r");
+  cf->fh = fopen(cf->filename, "r");
   thaw_clist(cf);
   
   gtk_timeout_remove(timeout);
diff --git a/file.h b/file.h
index 0469fc5972cd66f17a766bb7e537ec34f70c1fac..00f5092d12a79432cc250b577b363f33af59638b 100644 (file)
--- a/file.h
+++ b/file.h
@@ -1,7 +1,7 @@
 /* file.h
  * Definitions for file structures and routines
  *
- * $Id: file.h,v 1.33 1999/08/15 00:26:11 guy Exp $
+ * $Id: file.h,v 1.34 1999/08/15 01:02:26 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -106,7 +106,7 @@ typedef struct _capture_file {
 
 int  open_cap_file(char *, capture_file *);
 void close_cap_file(capture_file *, void *, guint);
-int  read_cap_file(char *, char *, capture_file *);
+int  read_cap_file(char *, capture_file *);
 int  tail_cap_file(char *, capture_file *);
 /* size_t read_frame_header(capture_file *); */