forked from osmocom/wireshark
From Mark C. Brown: allow the file type for the merge operation to be
specified in the GUI. svn path=/trunk/; revision=12326
This commit is contained in:
parent
236123a94b
commit
4624549a99
|
@ -78,6 +78,7 @@ static void file_color_import_ok_cb(GtkWidget *w, gpointer fs);
|
|||
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 void file_color_export_destroy_cb(GtkWidget *win, gpointer user_data);
|
|||
*/
|
||||
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 @@ file_open_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
|
|||
}
|
||||
|
||||
/*
|
||||
* 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 @@ static GtkWidget *file_merge_w;
|
|||
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,23 @@ file_merge_cmd(GtkWidget *w)
|
|||
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 +1021,19 @@ file_merge_ok_cb(GtkWidget *w, gpointer fs) {
|
|||
/* 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 +1149,6 @@ file_save_cmd_cb(GtkWidget *w, gpointer data) {
|
|||
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 +1221,8 @@ select_file_type_cb(GtkWidget *w _U_, gpointer data)
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -1319,7 +1319,7 @@ dnd_merge_files(int in_file_count, char **in_filenames)
|
|||
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 */
|
||||
|
|
4
merge.c
4
merge.c
|
@ -375,7 +375,7 @@ merge_open_in_files(int in_file_count, char *in_file_names[], merge_in_file_t *i
|
|||
* 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,7 @@ merge_n_files(int out_fd, int in_file_count, char **in_filenames, gboolean do_ap
|
|||
/* initialize out_file */
|
||||
out_file.fd = out_fd;
|
||||
out_file.pdh = NULL; /* wiretap dumpfile */
|
||||
out_file.file_type = WTAP_FILE_PCAP; /* default to "libpcap" */
|
||||
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 */
|
||||
|
|
2
merge.h
2
merge.h
|
@ -152,7 +152,7 @@ merge_append_files(int in_file_count, merge_in_file_t in_files[], merge_out_file
|
|||
* @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
|
||||
|
|
Loading…
Reference in New Issue