aboutsummaryrefslogtreecommitdiffstats
path: root/capture_sync.c
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-02-04 18:44:44 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-02-04 18:44:44 +0000
commit0861927ce30146be75bcb57b6939c0fd9fee43b3 (patch)
treef2d0d9d8c5c3712358e4169b04391e0629dfd4af /capture_sync.c
parentd7ad33dc51e0e51e6cc2903ff0ac3ce806550ce4 (diff)
huge cleanup of capture file API (functions in file.c/file.h).
This includes: all functions in file.h now have a cf_ prefix, will have doxygen tags, will have the capture_file *cf as the first parameter and I tried to generalize the return values for non trivial functions. Hopefully, I didn't introduced any new bugs, as I had to change a lot of files... svn path=/trunk/; revision=13289
Diffstat (limited to 'capture_sync.c')
-rw-r--r--capture_sync.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/capture_sync.c b/capture_sync.c
index 8dcf754ba7..d74e076bec 100644
--- a/capture_sync.c
+++ b/capture_sync.c
@@ -485,26 +485,32 @@ sync_pipe_do_capture(capture_options *capture_opts, gboolean is_tempfile) {
/* The child process started a capture.
Attempt to open the capture file and set up to read it. */
- err = cf_start_tail(capture_opts->save_file, is_tempfile, capture_opts->cf);
- if (err != 0) {
- /* We weren't able to open the capture file; user has been
- alerted. Close the sync pipe. */
+ switch(cf_start_tail(capture_opts->cf, capture_opts->save_file, is_tempfile, &err)) {
+ case CF_OK:
+ /* We were able to open and set up to read the capture file;
+ arrange that our callback be called whenever it's possible
+ to read from the sync pipe, so that it's called when
+ the child process wants to tell us something. */
+ pipe_input_set_handler(sync_pipe[PIPE_READ], (gpointer) capture_opts, &capture_opts->fork_child, sync_pipe_input_cb);
+
+ return TRUE;
+ break;
+ case CF_ERROR:
+ /* We weren't able to open the capture file; user has been
+ alerted. Close the sync pipe. */
- close(sync_pipe[PIPE_READ]);
+ close(sync_pipe[PIPE_READ]);
- /* Don't unlink the save file - leave it around, for debugging
- purposes. */
- g_free(capture_opts->save_file);
- capture_opts->save_file = NULL;
- return FALSE;
+ /* Don't unlink the save file - leave it around, for debugging
+ purposes. */
+ g_free(capture_opts->save_file);
+ capture_opts->save_file = NULL;
+ return FALSE;
+ break;
+ default:
+ g_assert_not_reached();
+ return FALSE;
}
- /* We were able to open and set up to read the capture file;
- arrange that our callback be called whenever it's possible
- to read from the sync pipe, so that it's called when
- the child process wants to tell us something. */
- pipe_input_set_handler(sync_pipe[PIPE_READ], (gpointer) capture_opts, &capture_opts->fork_child, sync_pipe_input_cb);
-
- return TRUE;
}
@@ -533,7 +539,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
XXX - do something if this fails? */
switch (cf_finish_tail(capture_opts->cf, &err)) {
- case READ_SUCCESS:
+ case CF_OK:
if(cf_packet_count(capture_opts->cf) == 0) {
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK,
"%sNo packets captured!%s\n\n"
@@ -543,13 +549,13 @@ sync_pipe_input_cb(gint source, gpointer user_data)
cf_close(capture_opts->cf);
}
break;
- case READ_ERROR:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file. */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Exit by leaving the main loop, so that any quit functions
we registered get called. */
main_window_quit();
@@ -624,8 +630,8 @@ sync_pipe_input_cb(gint source, gpointer user_data)
XXX - do something if this fails? */
switch (cf_continue_tail(capture_opts->cf, to_read, &err)) {
- case READ_SUCCESS:
- case READ_ERROR:
+ case CF_OK:
+ case CF_ERROR:
/* Just because we got an error, that doesn't mean we were unable
to read any of the file; we handle what we could get from the
file.
@@ -633,7 +639,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
XXX - abort on a read error? */
break;
- case READ_ABORTED:
+ case CF_ABORTED:
/* Kill the child capture process; the user wants to exit, and we
shouldn't just leave it running. */
kill_capture_child(capture_opts);