aboutsummaryrefslogtreecommitdiffstats
path: root/capture.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-04-11 18:57:19 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-04-11 18:57:19 +0000
commit61ccc8baf1f786dc42c7f3e86a564d151974cbb3 (patch)
tree0a8d003ec4d6e27e1abf45174002438216cbaa0e /capture.c
parentfbace0592cbe08ed1d8f5b199a58b1cde9a61535 (diff)
various capture code cleanup and fixes:
display filename in statusbar while capturing print_usage banner fixed cf_cb_live_capture_prepare no longer needed rename sync_pipe_do_capture -> sync_pipe_start bugfix: sync_pipe_input_wait_for_start replaced by former implementation fix cleanup of old file in capture_input_new_file fix a tempfile detection bug (named file showed up as tempfile after capture) svn path=/trunk/; revision=14053
Diffstat (limited to 'capture.c')
-rw-r--r--capture.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/capture.c b/capture.c
index 271849be40..637711e8f8 100644
--- a/capture.c
+++ b/capture.c
@@ -83,12 +83,8 @@ capture_start(capture_options *capture_opts)
cf_close(capture_opts->cf);
/* try to start the capture child process */
- ret = sync_pipe_do_capture(capture_opts, capture_opts->save_file == NULL);
-
- if(ret) {
- /* tell callbacks (menu, ...) that capture is running now */
- cf_callback_invoke(cf_cb_live_capture_prepare, capture_opts);
- } else {
+ ret = sync_pipe_start(capture_opts, capture_opts->save_file == NULL);
+ if(!ret) {
if(capture_opts->save_file != NULL) {
g_free(capture_opts->save_file);
capture_opts->save_file = NULL;
@@ -99,6 +95,22 @@ capture_start(capture_options *capture_opts)
}
+void
+capture_stop(capture_options *capture_opts)
+{
+ /* stop the capture child gracefully */
+ sync_pipe_stop(capture_opts);
+}
+
+void
+capture_kill_child(capture_options *capture_opts)
+{
+ /* kill the capture child */
+ sync_pipe_kill(capture_opts);
+}
+
+
+
/* We've succeeded a (non real-time) capture, try to read it into a new capture file */
static gboolean
capture_input_read_all(capture_options *capture_opts, gboolean is_tempfile, gboolean drops_known,
@@ -192,12 +204,15 @@ capture_input_new_file(capture_options *capture_opts, gchar *new_file)
/* free the old filename */
if(capture_opts->save_file != NULL) {
- /* we start a new capture file, simply close the old one */
- /* XXX - is it enough to call cf_close here? */
- /* XXX - is it safe to call cf_close even if the file is close before? */
- cf_close(capture_opts->cf);
+ /* we start a new capture file, close the old one (if we had one before) */
+ if( ((capture_file *) capture_opts->cf)->state != FILE_CLOSED) {
+ cf_callback_invoke(cf_cb_live_capture_update_finished, capture_opts->cf);
+ cf_finish_tail(capture_opts->cf, &err);
+ cf_close(capture_opts->cf);
+ }
g_free(capture_opts->save_file);
is_tempfile = FALSE;
+ cf_set_tempfile(capture_opts->cf, FALSE);
} else {
/* we didn't had a save_file before, must be a tempfile */
is_tempfile = TRUE;
@@ -317,19 +332,4 @@ capture_input_closed(capture_options *capture_opts)
}
-void
-capture_stop(capture_options *capture_opts)
-{
- /* stop the capture child gracefully, if we have one */
- sync_pipe_stop(capture_opts);
-}
-
-void
-capture_kill_child(capture_options *capture_opts)
-{
- /* kill the capture child, if we have one */
- sync_pipe_kill(capture_opts);
-}
-
-
#endif /* HAVE_LIBPCAP */