aboutsummaryrefslogtreecommitdiffstats
path: root/capture.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-09-09 20:39:01 +0000
committerGuy Harris <guy@alum.mit.edu>2002-09-09 20:39:01 +0000
commit5e8ecbaf4650a35ee0c3e9240bbcedb7def95e2c (patch)
tree7000f7732a62713bbfe2090a8de2e9282043c196 /capture.c
parent49425de3968d29fc8af95f349aba0164a2989b77 (diff)
downloadwireshark-5e8ecbaf4650a35ee0c3e9240bbcedb7def95e2c.tar.gz
wireshark-5e8ecbaf4650a35ee0c3e9240bbcedb7def95e2c.tar.bz2
wireshark-5e8ecbaf4650a35ee0c3e9240bbcedb7def95e2c.zip
From Graeme Hewson:
Currently Ethereal sets and uses a default directory for reading and writing, but only in some places. This set of patches extends the setting of the default directory to the -w option as well as the -r option, and causes all file dialogs to use and set the default consistently. (I haven't changed the Preferences/Printing/File dialog, though, as that's a special case.) There's also a fix for a bug where Ethereal was issuing the message "Ring buffer requested, but capture isn't being saved to a permanent file" even though a file was specified with -w. There also appear to be some other cleanups in his patch. svn path=/trunk/; revision=6238
Diffstat (limited to 'capture.c')
-rw-r--r--capture.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/capture.c b/capture.c
index 4e6b05b388..a645d65044 100644
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.189 2002/08/28 21:00:05 jmayer Exp $
+ * $Id: capture.c,v 1.190 2002/09/09 20:38:56 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -289,7 +289,7 @@ quote_encapsulate(const char *string)
/* Open a specified file, or create a temporary file, and start a capture
to the file in question. */
void
-do_capture(char *capfile_name)
+do_capture(const char *save_file)
{
char tmpname[128+1];
gboolean is_tempfile;
@@ -301,8 +301,14 @@ do_capture(char *capfile_name)
int capture_succeeded;
gboolean stats_known;
struct pcap_stat stats;
-
- if (capfile_name != NULL) {
+ gchar *capfile_name;
+
+ if (save_file != NULL) {
+ /* If the Sync option is set, we return to the caller while the capture
+ * is in progress. Therefore we need to take a copy of save_file in
+ * case the caller destroys it after we return.
+ */
+ capfile_name = g_strdup(save_file);
if (capture_opts.ringbuffer_on) {
/* ringbuffer is enabled */
cfile.save_file_fd = ringbuf_init(capfile_name,
@@ -331,11 +337,14 @@ do_capture(char *capfile_name)
simple_dialog(ESD_TYPE_CRIT, NULL,
file_open_error_message(errno, TRUE, WTAP_FILE_PCAP), capfile_name);
}
+ g_free(capfile_name);
return;
}
close_cap_file(&cfile);
g_assert(cfile.save_file == NULL);
cfile.save_file = capfile_name;
+ /* cfile.save_file is "g_free"ed below, which is equivalent to
+ "g_free(capfile_name)". */
if (capture_opts.sync_mode) { /* do the capture in a child process */
char ssnap[24];
@@ -676,7 +685,8 @@ do_capture(char *capfile_name)
case READ_ABORTED:
/* Exit by leaving the main loop, so that any quit functions
we registered get called. */
- gtk_main_quit();
+ if (gtk_main_level() > 0)
+ gtk_main_quit();
return;
}
}