aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-02-27 18:52:05 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-02-27 18:52:05 +0000
commit8011f18835c003822b0916b23f8f512e02ae4991 (patch)
tree3ba0181abbb06e48f88819c58ac0b6d23edc2a3f
parentfed921bff91575f821cba5fdbea6463f4a565f2b (diff)
bugfix to bring up correct error message if capture file couldn't be openened.
some code cleanup svn path=/trunk/; revision=13537
-rw-r--r--capture.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/capture.c b/capture.c
index b8d6ad6b62..11bc47a45d 100644
--- a/capture.c
+++ b/capture.c
@@ -109,9 +109,9 @@ capture_open_output(capture_options *capture_opts, gboolean *is_tempfile) {
/* did we fail to open the output file? */
if (capture_opts->save_file_fd == -1) {
- if (is_tempfile) {
+ if (*is_tempfile) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "The temporary file to which the capture would be saved (\"%s\")"
+ "The temporary file to which the capture would be saved (\"%s\") "
"could not be opened: %s.", capfile_name, strerror(errno));
} else {
if (capture_opts->multi_files_on) {
@@ -136,6 +136,18 @@ capture_open_output(capture_options *capture_opts, gboolean *is_tempfile) {
}
+static void
+capture_close_output(capture_options *capture_opts)
+{
+ if (capture_opts->multi_files_on) {
+ ringbuf_free();
+ } else {
+ g_free(capture_opts->save_file);
+ }
+ capture_opts->save_file = NULL;
+}
+
+
/* Open a specified file, or create a temporary file, and start a capture
to the file in question. */
/* Returns TRUE if the capture starts successfully, FALSE otherwise. */
@@ -184,24 +196,14 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
if (!capture_succeeded) {
/* We didn't succeed in doing the capture, so we don't have a save
file. */
- if (capture_opts->multi_files_on) {
- ringbuf_free();
- } else {
- g_free(capture_opts->save_file);
- }
- capture_opts->save_file = NULL;
+ capture_close_output(capture_opts);
return FALSE;
}
/* Capture succeeded; attempt to read in the capture file. */
if (cf_open(capture_opts->cf, capture_opts->save_file, is_tempfile, &err) != CF_OK) {
/* We're not doing a capture any more, so we don't have a save
file. */
- if (capture_opts->multi_files_on) {
- ringbuf_free();
- } else {
- g_free(capture_opts->save_file);
- }
- capture_opts->save_file = NULL;
+ capture_close_output(capture_opts);
return FALSE;
}
@@ -257,12 +259,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
/* We're not doing a capture any more, so we don't have a save
file. */
- if (capture_opts->multi_files_on) {
- ringbuf_free();
- } else {
- g_free(capture_opts->save_file);
- }
- capture_opts->save_file = NULL;
+ capture_close_output(capture_opts);
/* if we didn't captured even a single packet, close the file again */
if(cf_packet_count(capture_opts->cf) == 0) {