Ethereal-dev: [Ethereal-dev] Added output file type selection for GUI file merge
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: "Mark C. Brown" <mbrown@xxxxxxxxxx>
Date: Sat, 16 Oct 2004 13:56:07 -0400
Greetings, Added ability to specify file type for resulting output file from the merge operation in the GUI, rather than always using the libpcap format. Thanks! Mark -- "If a train station is where a train stops, | Mark C. Brown then what's a workstation?" -- D. Huber | mbrown@xxxxxxxxxx
Index: merge.c
===================================================================
--- merge.c (revision 12319)
+++ merge.c (working copy)
@@ -375,7 +375,7 @@
* Convenience function: merge two files into one.
*/
gboolean
-merge_n_files(int out_fd, int in_file_count, char **in_filenames, gboolean do_append, int *err)
+merge_n_files(int out_fd, int in_file_count, char **in_filenames, int filetype, gboolean do_append, int *err)
{
extern char *optarg;
extern int optind;
@@ -386,7 +386,10 @@
/* initialize out_file */
out_file.fd = out_fd;
out_file.pdh = NULL; /* wiretap dumpfile */
- out_file.file_type = WTAP_FILE_PCAP; /* default to "libpcap" */
+ if (filetype == WTAP_FILE_UNKNOWN)
+ out_file.file_type = WTAP_FILE_PCAP; /* default to "libpcap" */
+ else
+ out_file.file_type = filetype;
out_file.frame_type = -2; /* leave type alone */
out_file.snaplen = 0; /* no limit */
out_file.count = 1; /* frames output */
Index: merge.h
===================================================================
--- merge.h (revision 12319)
+++ merge.h (working copy)
@@ -152,7 +152,7 @@
* @return TRUE if function succeeded
*/
extern gboolean
-merge_n_files(int out_fd, int in_file_count, char **in_filenames, gboolean do_append, int *err);
+merge_n_files(int out_fd, int in_file_count, char **in_filenames, int filetype, gboolean do_append, int *err);
#ifdef __cplusplus
Index: gtk/file_dlg.c
===================================================================
--- gtk/file_dlg.c (revision 12319)
+++ gtk/file_dlg.c (working copy)
@@ -78,6 +78,7 @@
static void file_color_import_destroy_cb(GtkWidget *win, gpointer user_data);
static void file_color_export_ok_cb(GtkWidget *w, gpointer fs);
static void file_color_export_destroy_cb(GtkWidget *win, gpointer user_data);
+static void set_file_type_list(GtkWidget *option_menu);
#define E_FILE_M_RESOLVE_KEY "file_dlg_mac_resolve_key"
#define E_FILE_N_RESOLVE_KEY "file_dlg_network_resolve_key"
@@ -107,6 +108,13 @@
*/
static GtkWidget *file_save_as_w;
+/* XXX - can we make these not be static? */
+static packet_range_t range;
+static gboolean color_marked;
+static int filetype;
+static GtkWidget *cfmark_cb;
+static GtkWidget *ft_om;
+static GtkWidget *range_tb;
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -731,7 +739,7 @@
}
/*
- * Keep a static pointer to the current "Marge Capture File" window, if
+ * Keep a static pointer to the current "Merge Capture File" window, if
* any, so that if somebody tries to do "File:Merge" while there's already
* an "Merge Capture File" window up, we just pop up the existing one,
* rather than creating a new one.
@@ -742,8 +750,9 @@
void
file_merge_cmd(GtkWidget *w)
{
- GtkWidget *main_hb, *main_vb, *filter_hbox, *filter_bt, *filter_te,
- *prepend_rb, *chrono_rb, *append_rb, *prev;
+ GtkWidget *main_hb, *main_vb, *ft_hb, *ft_lb, *filter_hbox,
+ *filter_bt, *filter_te, *prepend_rb, *chrono_rb,
+ *append_rb, *prev;
#if GTK_MAJOR_VERSION < 2
GtkAccelGroup *accel_group;
#endif
@@ -810,6 +819,24 @@
gtk_box_pack_start(GTK_BOX(main_hb), main_vb, FALSE, FALSE, 0);
gtk_widget_show(main_vb);
+ /* File type row */
+ range_tb = NULL;
+ ft_hb = gtk_hbox_new(FALSE, 3);
+ gtk_container_add(GTK_CONTAINER(main_vb), ft_hb);
+ gtk_widget_show(ft_hb);
+
+ ft_lb = gtk_label_new("Merged output file type:");
+ gtk_box_pack_start(GTK_BOX(ft_hb), ft_lb, FALSE, FALSE, 0);
+ gtk_widget_show(ft_lb);
+
+ ft_om = gtk_option_menu_new();
+
+ /* Generate the list of file types we can save. */
+ set_file_type_list(ft_om);
+ gtk_box_pack_start(GTK_BOX(ft_hb), ft_om, FALSE, FALSE, 0);
+ gtk_widget_show(ft_om);
+
+
filter_hbox = gtk_hbox_new(FALSE, 1);
gtk_container_border_width(GTK_CONTAINER(filter_hbox), 0);
gtk_box_pack_start(GTK_BOX(main_vb), filter_hbox, FALSE, FALSE, 0);
@@ -995,19 +1022,19 @@
/* chonological order */
in_filenames[0] = cfile.filename;
in_filenames[1] = cf_name;
- merge_ok = merge_n_files(out_fd, 2, in_filenames, FALSE, &err);
+ merge_ok = merge_n_files(out_fd, 2, in_filenames, filetype, FALSE, &err);
} else {
rb = OBJECT_GET_DATA(w, E_MERGE_PREPEND_KEY);
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (rb))) {
/* prepend file */
in_filenames[0] = cfile.filename;
in_filenames[1] = cf_name;
- merge_ok = merge_n_files(out_fd, 2, in_filenames, TRUE, &err);
+ merge_ok = merge_n_files(out_fd, 2, in_filenames, filetype, TRUE, &err);
} else {
/* append file */
in_filenames[0] = cf_name;
in_filenames[1] = cfile.filename;
- merge_ok = merge_n_files(out_fd, 2, in_filenames, TRUE, &err);
+ merge_ok = merge_n_files(out_fd, 2, in_filenames, filetype, TRUE, &err);
}
}
@@ -1123,14 +1150,6 @@
file_save_as_cmd_cb(w, data);
}
-/* XXX - can we make these not be static? */
-static packet_range_t range;
-static gboolean color_marked;
-static int filetype;
-static GtkWidget *cfmark_cb;
-static GtkWidget *ft_om;
-static GtkWidget *range_tb;
-
static gboolean
can_save_with_wiretap(int ft)
{
@@ -1203,7 +1222,8 @@
if (filetype != new_filetype) {
/* We can select only the filtered or marked packets to be saved if we can
use Wiretap to save the file. */
- range_set_displayed_sensitive(range_tb, can_save_with_wiretap(new_filetype));
+ if (range_tb != NULL)
+ range_set_displayed_sensitive(range_tb, can_save_with_wiretap(new_filetype));
filetype = new_filetype;
file_set_save_marked_sensitive();
}
Index: gtk/main.c
===================================================================
--- gtk/main.c (revision 12319)
+++ gtk/main.c (working copy)
@@ -1319,7 +1319,7 @@
out_fd = create_tempfile(tmpname, sizeof tmpname, "ether");
/* merge the files in chonological order */
- merge_ok = merge_n_files(out_fd, in_file_count, in_filenames, FALSE, &err);
+ merge_ok = merge_n_files(out_fd, in_file_count, in_filenames, WTAP_FILE_PCAP, FALSE, &err);
if(!merge_ok) {
/* merge failed */
- Follow-Ups:
- Prev by Date: Re: [Ethereal-dev] Problems with new net-snmp-5.1.2 archive (COPS dissector)
- Next by Date: RE: [Ethereal-dev] g_unichar_get_mirror_char error building 0.10.6?
- Previous by thread: Re: [Ethereal-dev] Duplicate win32 setup code
- Next by thread: Re: [Ethereal-dev] Added output file type selection for GUI file merge
- Index(es):





