From 4443681a9e13b926e6c34da6c44cf93103d21944 Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Fri, 7 Oct 2005 03:34:27 +0000 Subject: fix Ethereal so command line capture parameter will work with kilobytes (again) remove Byte(s) from the dropdown list of filesizes, this doesn't make sense replace 1000 with 1024, as all (modern?) file managers are based on 1024 bytes for a kilobyte (the old KB vs. KiB controversy) svn path=/trunk/; revision=16149 --- capture_loop.c | 4 +--- capture_opts.c | 4 ++-- capture_sync.c | 2 -- doc/ethereal.pod | 4 ++-- doc/tethereal.pod | 4 ++-- gtk/capture_dlg.c | 45 +++++++++++++-------------------------------- tethereal.c | 2 +- 7 files changed, 21 insertions(+), 44 deletions(-) diff --git a/capture_loop.c b/capture_loop.c index c6dfd67fe6..97d8fe9967 100644 --- a/capture_loop.c +++ b/capture_loop.c @@ -1212,9 +1212,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct *stats_known = FALSE; g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_INFO, "Capture child starting ..."); -#ifdef LOG_CAPTURE_VERBOSE capture_opts_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, capture_opts); -#endif /* open the output file (temporary/specified name/ringbuffer) */ if (!capture_loop_open_output(capture_opts, &save_file_fd, errmsg, sizeof(errmsg))) { @@ -1257,7 +1255,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct /* create stop conditions */ if (capture_opts->has_autostop_filesize) cnd_autostop_size = - cnd_new(CND_CLASS_CAPTURESIZE,(long)capture_opts->autostop_filesize); + cnd_new(CND_CLASS_CAPTURESIZE,(long)capture_opts->autostop_filesize * 1024); if (capture_opts->has_autostop_duration) cnd_autostop_duration = cnd_new(CND_CLASS_TIMEOUT,(gint32)capture_opts->autostop_duration); diff --git a/capture_opts.c b/capture_opts.c index 6cb03a7a29..8024fc15a2 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -76,7 +76,7 @@ capture_opts_init(capture_options *capture_opts, void *cfile) capture_opts->has_autostop_packets = FALSE; capture_opts->autostop_packets = 0; capture_opts->has_autostop_filesize = FALSE; - capture_opts->autostop_filesize = 1024 * 1024; /* 1 MB */ + capture_opts->autostop_filesize = 1024; /* 1 MB */ capture_opts->has_autostop_duration = FALSE; capture_opts->autostop_duration = 60; /* 1 min */ @@ -113,7 +113,7 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio g_log(log_domain, log_level, "AutostopFiles (%u): %u", capture_opts->has_autostop_files, capture_opts->autostop_files); g_log(log_domain, log_level, "AutostopPackets (%u): %u", capture_opts->has_autostop_packets, capture_opts->autostop_packets); - g_log(log_domain, log_level, "AutostopFilesize(%u): %u", capture_opts->has_autostop_filesize, capture_opts->autostop_filesize); + g_log(log_domain, log_level, "AutostopFilesize(%u): %u (KB)", capture_opts->has_autostop_filesize, capture_opts->autostop_filesize); g_log(log_domain, log_level, "AutostopDuration(%u): %u", capture_opts->has_autostop_duration, capture_opts->autostop_duration); g_log(log_domain, log_level, "ForkChild : %d", capture_opts->fork_child); diff --git a/capture_sync.c b/capture_sync.c index cb0d50652e..9e02b26c44 100644 --- a/capture_sync.c +++ b/capture_sync.c @@ -335,9 +335,7 @@ sync_pipe_start(capture_options *capture_opts) { g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_start"); -#ifdef LOG_CAPTURE_VERBOSE capture_opts_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, capture_opts); -#endif capture_opts->fork_child = -1; diff --git a/doc/ethereal.pod b/doc/ethereal.pod index b36b5a6b66..d8463bc26d 100644 --- a/doc/ethereal.pod +++ b/doc/ethereal.pod @@ -174,7 +174,7 @@ where I is one of: B:I Stop writing to a capture file after I seconds have elapsed. B:I Stop writing to a capture file after it reaches a size of I -kilobytes (where a kilobyte is 1000 bytes, not 1024 bytes). If this option +kilobytes (where a kilobyte is 1024 bytes). If this option is used together with the -b option, Ethereal will stop writing to the current capture file and switch to the next one if filesize is reached. @@ -204,7 +204,7 @@ B:I switch to the next file after I seconds have elapsed, even if the current file is not completely filled up. B:I switch to the next file after it reaches a size of -I kilobytes (where a kilobyte is 1000 bytes, not 1024 bytes). +I kilobytes (where a kilobyte is 1024 bytes). B:I begin again with the first file after I number of files were written (form a ring buffer). diff --git a/doc/tethereal.pod b/doc/tethereal.pod index d3257c4285..063de402fb 100644 --- a/doc/tethereal.pod +++ b/doc/tethereal.pod @@ -245,7 +245,7 @@ where I is one of: B:I Stop writing to a capture file after I seconds have elapsed. B:I Stop writing to a capture file after it reaches a size of I -kilobytes (where a kilobyte is 1000 bytes, not 1024 bytes). If this option +kilobytes (where a kilobyte is 1024 bytes). If this option is used together with the -b option, Ethereal will stop writing to the current capture file and switch to the next one if filesize is reached. @@ -275,7 +275,7 @@ B:I switch to the next file after I seconds have elapsed, even if the current file is not completely filled up. B:I switch to the next file after it reaches a size of -I kilobytes (where a kilobyte is 1000 bytes, not 1024 bytes). +I kilobytes (where a kilobyte is 1024 bytes). B:I begin again with the first file after I number of files were written (form a ring buffer). diff --git a/gtk/capture_dlg.c b/gtk/capture_dlg.c index 1da5705cfe..8746bf6ba9 100644 --- a/gtk/capture_dlg.c +++ b/gtk/capture_dlg.c @@ -381,13 +381,11 @@ guint32 value) } -#define SIZE_UNIT_BYTES 0 -#define SIZE_UNIT_KILOBYTES 1 -#define SIZE_UNIT_MEGABYTES 2 -#define SIZE_UNIT_GIGABYTES 3 -#define MAX_SIZE_UNITS 4 +#define SIZE_UNIT_KILOBYTES 0 +#define SIZE_UNIT_MEGABYTES 1 +#define SIZE_UNIT_GIGABYTES 2 +#define MAX_SIZE_UNITS 3 static const char *size_unit_name[MAX_SIZE_UNITS] = { - "byte(s)", "kilobyte(s)", "megabyte(s)", "gigabyte(s)", @@ -410,20 +408,15 @@ static GtkWidget *size_unit_option_menu_new(guint32 value) { /* the selected menu item can't be changed, once the option_menu is created, so set the matching menu item now */ /* gigabytes */ - if(value >= 1024 * 1024 * 1024) { + if(value >= 1024 * 1024) { gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_GIGABYTES); } else { /* megabytes */ - if(value >= 1024 * 1024) { + if(value >= 1024) { gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_MEGABYTES); } else { /* kilobytes */ - if(value >= 1024) { - gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_KILOBYTES); - } else { - /* bytes */ - gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_BYTES); - } + gtk_menu_set_active(GTK_MENU(menu), SIZE_UNIT_KILOBYTES); } } @@ -437,21 +430,16 @@ static guint32 size_unit_option_menu_set_value( guint32 value) { /* gigabytes */ - if(value >= 1024 * 1024 * 1024) { - return value / (1024 * 1024 * 1024); - } - - /* megabytes */ if(value >= 1024 * 1024) { return value / (1024 * 1024); } - /* kilobytes */ + /* megabytes */ if(value >= 1024) { - return value / 1024; + return value / (1024); } - /* bytes */ + /* kilobytes */ return value; } @@ -469,30 +457,23 @@ guint32 value) switch(unit) { - case(SIZE_UNIT_BYTES): + case(SIZE_UNIT_KILOBYTES): return value; break; - case(SIZE_UNIT_KILOBYTES): + case(SIZE_UNIT_MEGABYTES): if(value > G_MAXINT / 1024) { return 0; } else { return value * 1024; } break; - case(SIZE_UNIT_MEGABYTES): + case(SIZE_UNIT_GIGABYTES): if(value > G_MAXINT / (1024 * 1024)) { return 0; } else { return value * 1024 * 1024; } break; - case(SIZE_UNIT_GIGABYTES): - if(value > G_MAXINT / (1024 * 1024 * 1024)) { - return 0; - } else { - return value * 1024 * 1024 * 1024; - } - break; default: g_assert_not_reached(); return 0; diff --git a/tethereal.c b/tethereal.c index e2d7592e72..b78250a88a 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1745,7 +1745,7 @@ capture(char *save_file, int out_file_type) /* create stop conditions */ if (capture_opts.has_autostop_filesize) cnd_stop_capturesize = cnd_new((const char*)CND_CLASS_CAPTURESIZE, - (long)capture_opts.autostop_filesize * 1000); + (long)capture_opts.autostop_filesize * 1024); if (capture_opts.has_autostop_duration) cnd_stop_timeout = cnd_new((const char*)CND_CLASS_TIMEOUT, (gint32)capture_opts.autostop_duration); -- cgit v1.2.3