diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2005-02-06 00:13:00 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2005-02-06 00:13:00 +0000 |
commit | 97866a968b4c5bc273e986775cdc9cefe52c281f (patch) | |
tree | 3b581fbf16b7876759297cd33f0890c1df52b92d | |
parent | a9cc1df5516feb8c160e78a0adf0f7cb89f7088e (diff) |
instead of initializing the capture_options in main.c, use the new function capture_opts_init
svn path=/trunk/; revision=13315
-rw-r--r-- | capture.c | 35 | ||||
-rw-r--r-- | capture.h | 4 | ||||
-rw-r--r-- | gtk/main.c | 33 |
3 files changed, 42 insertions, 30 deletions
@@ -79,6 +79,41 @@ static gboolean normal_do_capture(capture_options *capture_opts, gboolean is_tem static void stop_capture_signal_handler(int signo); +void +capture_opts_init(capture_options *capture_opts, void *cfile) +{ + capture_opts->cf = cfile; +#ifdef _WIN32 + capture_opts->buffer_size = 1; /* 1 MB */ +#endif + capture_opts->has_snaplen = FALSE; + capture_opts->snaplen = MIN_PACKET_SIZE; + capture_opts->promisc_mode = TRUE; + capture_opts->linktype = -1; /* the default linktype */ + capture_opts->capture_child = FALSE; + capture_opts->save_file = NULL; + capture_opts->save_file_fd = -1; + capture_opts->sync_mode = TRUE; + capture_opts->show_info = TRUE; + capture_opts->quit_after_cap = FALSE; + + capture_opts->multi_files_on = FALSE; + capture_opts->has_file_duration = FALSE; + capture_opts->file_duration = 60; /* 1 min */ + capture_opts->has_ring_num_files = TRUE; + capture_opts->ring_num_files = 2; + + capture_opts->has_autostop_files = FALSE; + capture_opts->autostop_files = 1; + capture_opts->has_autostop_packets = FALSE; + capture_opts->autostop_packets = 1; + capture_opts->has_autostop_filesize = FALSE; + capture_opts->autostop_filesize = 1024 * 1024; /* 1 MB */ + capture_opts->has_autostop_duration = FALSE; + capture_opts->autostop_duration = 60; /* 1 min */ +} + + /* open the output file (temporary/specified name/ringbuffer) and close the old one */ /* Returns TRUE if the file opened successfully, FALSE otherwise. */ static gboolean @@ -85,6 +85,10 @@ typedef struct capture_options_tag { } capture_options; +/* initialize the capture_options with some reasonable values */ +extern void +capture_opts_init(capture_options *capture_opts, void *cfile); + /** * Open a specified file, or create a temporary file, and start a capture * to the file in question. diff --git a/gtk/main.c b/gtk/main.c index b273f3748d..08173592d2 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1570,31 +1570,8 @@ main(int argc, char *argv[]) } #endif - capture_opts->cf = &cfile; #ifdef HAVE_LIBPCAP - capture_opts->has_snaplen = FALSE; - capture_opts->snaplen = MIN_PACKET_SIZE; - capture_opts->linktype = -1; -#ifdef _WIN32 - capture_opts->buffer_size = 1; -#endif - capture_opts->save_file_fd = -1; - capture_opts->quit_after_cap = FALSE; - - capture_opts->has_autostop_packets = FALSE; - capture_opts->autostop_packets = 1; - capture_opts->has_autostop_duration = FALSE; - capture_opts->autostop_duration = 60 /* 1 min */; - capture_opts->has_autostop_filesize = FALSE; - capture_opts->autostop_filesize = 1024 * 1024 /* 1 MB */; - capture_opts->has_autostop_files = FALSE; - capture_opts->autostop_files = 1; - - capture_opts->multi_files_on = FALSE; - capture_opts->has_ring_num_files = TRUE; - capture_opts->ring_num_files = 2; - capture_opts->has_file_duration = FALSE; - capture_opts->file_duration = 60 /* 1 min */; + capture_opts_init(capture_opts, &cfile); /* If this is a capture child process, it should pay no attention to the "prefs.capture_prom_mode" setting in the preferences file; @@ -1604,12 +1581,8 @@ main(int argc, char *argv[]) Otherwise, set promiscuous mode from the preferences setting. */ /* the same applies to other preferences settings as well. */ - if (capture_opts->capture_child) { - capture_opts->promisc_mode = TRUE; /* maybe changed by command line below */ - capture_opts->show_info = TRUE; /* maybe changed by command line below */ - capture_opts->sync_mode = TRUE; /* always true in child process */ - auto_scroll_live = FALSE; /* doesn't matter in child process */ - + if (!capture_opts->capture_child) { + auto_scroll_live = FALSE; } else { capture_opts->promisc_mode = prefs->capture_prom_mode; capture_opts->show_info = prefs->capture_show_info; |