diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2005-09-14 21:57:30 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2005-09-14 21:57:30 +0000 |
commit | 84cf7ce7675b450311dcec0b34b785974b2e85d0 (patch) | |
tree | 714a0f5ff24c62c46cc312f5a3a5eb7fe1ee581c /gtk/file_dlg.c | |
parent | 1d0e5b105ca2c952f8a252b07a65e7ff883ee8b4 (diff) |
added compression support for capture file output. The Save/As dialog now has a checkbox "Compress with gzip"
currently limited to Ethereal and all the variants of libpcap filetypes only.
We might want to add output compression support to the other tools as well (tethereal, mergecap, ...).
We might also want to add support for the other filetypes, but this is only possible if the filetype functions doesn't use special output operations like fseek.
One bug is still left: if the input and output filetypes while saving are the same, Ethereal currently optimizes this by simply copy the binary file instead of using wiretap (so it will be faster but it will ignore the compress setting).
Don't know a good workaround for this, as I don't know a way to find out if the input file is currently compressed or not. One idea might be to use a heuristic on the filesize (compared to the packet size summmary). Another workaround I see is to remove this optimization, which is of course not the way I like to do it ...
svn path=/trunk/; revision=15804
Diffstat (limited to 'gtk/file_dlg.c')
-rw-r--r-- | gtk/file_dlg.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c index 7288dc8396..100b5bf193 100644 --- a/gtk/file_dlg.c +++ b/gtk/file_dlg.c @@ -1217,6 +1217,7 @@ static void select_file_type_cb(GtkWidget *w _U_, gpointer data) { int new_filetype = GPOINTER_TO_INT(data); + GtkWidget *compressed_cb; if (filetype != new_filetype) { /* We can select only the filtered or marked packets to be saved if we can @@ -1225,6 +1226,8 @@ select_file_type_cb(GtkWidget *w _U_, gpointer data) range_set_displayed_sensitive(range_tb, can_save_with_wiretap(new_filetype)); filetype = new_filetype; file_set_save_marked_sensitive(); + compressed_cb = OBJECT_GET_DATA(file_save_as_w, "compressed"); + gtk_widget_set_sensitive(compressed_cb, wtap_dump_can_compress(new_filetype)); } } @@ -1267,7 +1270,7 @@ gpointer action_after_save_data_g; void file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_save_data) { - GtkWidget *main_vb, *ft_hb, *ft_lb, *range_fr; + GtkWidget *main_vb, *ft_hb, *ft_lb, *range_fr, *compressed_cb; GtkTooltips *tooltips; #if GTK_MAJOR_VERSION < 2 @@ -1352,6 +1355,13 @@ file_save_as_cmd(action_after_save_e action_after_save, gpointer action_after_sa /* dynamic values in the range frame */ range_update_dynamics(range_tb); + /* compressed */ + compressed_cb = gtk_check_button_new_with_label("Compress with gzip"); + gtk_container_add(GTK_CONTAINER(ft_hb), compressed_cb); + gtk_widget_show(compressed_cb); + OBJECT_SET_DATA(file_save_as_w, "compressed", compressed_cb); + gtk_widget_set_sensitive(compressed_cb, wtap_dump_can_compress(cfile.cd_t)); + SIGNAL_CONNECT(file_save_as_w, "destroy", file_save_as_destroy_cb, NULL); #if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2 @@ -1389,6 +1399,7 @@ static void file_save_as_cb(GtkWidget *w _U_, gpointer fs) { gchar *cf_name; gchar *dirname; + GtkWidget *compressed_cb; #if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2 @@ -1397,9 +1408,12 @@ file_save_as_cb(GtkWidget *w _U_, gpointer fs) { cf_name = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs))); #endif + compressed_cb = OBJECT_GET_DATA(file_save_as_w, "compressed"); + /* Write out the packets (all, or only the ones from the current range) to the file with the specified name. */ - if (cf_save(&cfile, cf_name, &range, filetype) != CF_OK) { + if (cf_save(&cfile, cf_name, &range, filetype, + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compressed_cb))) != CF_OK) { /* The write failed; don't dismiss the open dialog box, just leave it around so that the user can, after they dismiss the alert box popped up for the error, try again. */ |