Stuart Stanley's ISIS dissection support.
[obnox/wireshark/wip.git] / file.c
diff --git a/file.c b/file.c
index d30b3600ad52fe106e160047b4e044de1c505a12..fd974512f497f7f43ac7f2a1ebc37d08377b1f60 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
 /* file.c
  * File I/O routines
  *
- * $Id: file.c,v 1.134 1999/12/04 11:32:24 guy Exp $
+ * $Id: file.c,v 1.137 1999/12/12 13:25:54 oabad Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
 #include "print.h"
 #include "file.h"
 #include "util.h"
+#include "ui_util.h"
 #include "gtk/proto_draw.h"
 #include "dfilter.h"
 #include "timestamp.h"
 #include "conversation.h"
 #include "globals.h"
 
+#ifdef HAVE_DLFCN_H
+#include "plugins.h"
+#endif
+
 #ifndef __RESOLV_H__
 #include "resolv.h"
 #endif
@@ -229,6 +234,9 @@ close_cap_file(capture_file *cf, void *w)
      will there ever be more than one on the stack? */
   gtk_statusbar_pop(GTK_STATUSBAR(w), file_ctx);
 
+  /* Restore the standard title bar message. */
+  set_main_window_name("The Ethereal Network Analyzer");
+
   /* Disable all menu items that make sense only if you have a capture. */
   set_menu_sensitivity("/File/Save", FALSE);
   set_menu_sensitivity("/File/Save As...", FALSE);
@@ -247,13 +255,17 @@ close_cap_file(capture_file *cf, void *w)
   set_menu_sensitivity("/Tools/Summary", FALSE);
 }
 
+/* Set the file name in the status line, in the name for the main window,
+   and in the name for the main window's icon. */
 static void
-set_statusbar_filename(capture_file *cf)
+set_display_filename(capture_file *cf)
 {
   gchar  *name_ptr;
   size_t  msg_len;
   gchar  *done_fmt = " File: %s  Drops: %u";
   gchar  *done_msg;
+  gchar  *win_name_fmt = "%s - Ethereal";
+  gchar  *win_name;
 
   if (!cf->is_tempfile) {
     /* Get the last component of the file name, and put that in the
@@ -265,7 +277,7 @@ set_statusbar_filename(capture_file *cf)
   } else {
     /* The file we read is a temporary file from a live capture;
        we don't mention its name in the status bar. */
-    name_ptr = "<none>";
+    name_ptr = "<capture>";
   }
 
   msg_len = strlen(name_ptr) + strlen(done_fmt) + 64;
@@ -273,6 +285,12 @@ set_statusbar_filename(capture_file *cf)
   snprintf(done_msg, msg_len, done_fmt, name_ptr, cf->drops);
   gtk_statusbar_push(GTK_STATUSBAR(info_bar), file_ctx, done_msg);
   g_free(done_msg);
+
+  msg_len = strlen(name_ptr) + strlen(win_name_fmt) + 1;
+  win_name = g_malloc(msg_len);
+  snprintf(win_name, msg_len, win_name_fmt, name_ptr);
+  set_main_window_name(win_name);
+  g_free(win_name);
 }
 
 int
@@ -326,7 +344,7 @@ read_cap_file(capture_file *cf)
   gtk_progress_set_value(GTK_PROGRESS(prog_bar), 0);
 
   gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
-  set_statusbar_filename(cf);
+  set_display_filename(cf);
 
   /* Enable menu items that make sense if you have a capture file you've
      finished reading. */
@@ -471,7 +489,7 @@ finish_tail_cap_file(capture_file *cf)
   /* Pop the "<live capture in progress>" message off the status bar. */
   gtk_statusbar_pop(GTK_STATUSBAR(info_bar), file_ctx);
 
-  set_statusbar_filename(cf);
+  set_display_filename(cf);
 
   /* Restore the "File/Open" menu item. */
   set_menu_sensitivity("/File/Open...", TRUE);
@@ -763,7 +781,7 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf
   gint          i, row;
   gint         crow;
   gint                 color;
-  proto_tree   *protocol_tree;
+  proto_tree   *protocol_tree = NULL;
 
   fdata->num = cf->count;
 
@@ -815,9 +833,17 @@ add_packet_to_packet_list(frame_data *fdata, capture_file *cf, const u_char *buf
        proto_tree_free(protocol_tree);
   }
   else {
-       dissect_packet(buf, fdata, NULL);
+#ifdef HAVE_DLFCN_H
+       if (plugin_list)
+           protocol_tree = proto_tree_create_root();
+#endif
+       dissect_packet(buf, fdata, protocol_tree);
        fdata->passed_dfilter = TRUE;
        color = -1;
+#ifdef HAVE_DLFCN_H
+       if (protocol_tree)
+           proto_tree_free(protocol_tree);
+#endif
   }
   if (fdata->passed_dfilter) {
     /* If we don't have the time stamp of the previous displayed packet,
@@ -1715,6 +1741,7 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
         hdr.caplen = fd->cap_len;
         hdr.len = fd->pkt_len;
         hdr.pkt_encap = fd->lnk_t;
+        hdr.pseudo_header = fd->pseudo_header;
        wtap_seek_read(cf->cd_t, cf->fh, fd->file_off, pd, fd->cap_len);
 
         if (!wtap_dump(pdh, &hdr, pd, &err)) {