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
This commit is contained in:
Ulf Lamping 2005-10-07 03:34:27 +00:00
parent 8fc87ba3ba
commit 4443681a9e
7 changed files with 21 additions and 44 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -174,7 +174,7 @@ where I<test> is one of:
B<duration>:I<value> Stop writing to a capture file after I<value> seconds have elapsed.
B<filesize>:I<value> Stop writing to a capture file after it reaches a size of I<value>
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<duration>:I<value> switch to the next file after I<value> seconds have
elapsed, even if the current file is not completely filled up.
B<filesize>:I<value> switch to the next file after it reaches a size of
I<value> kilobytes (where a kilobyte is 1000 bytes, not 1024 bytes).
I<value> kilobytes (where a kilobyte is 1024 bytes).
B<files>:I<value> begin again with the first file after I<value> number of
files were written (form a ring buffer).

View File

@ -245,7 +245,7 @@ where I<test> is one of:
B<duration>:I<value> Stop writing to a capture file after I<value> seconds have elapsed.
B<filesize>:I<value> Stop writing to a capture file after it reaches a size of I<value>
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<duration>:I<value> switch to the next file after I<value> seconds have
elapsed, even if the current file is not completely filled up.
B<filesize>:I<value> switch to the next file after it reaches a size of
I<value> kilobytes (where a kilobyte is 1000 bytes, not 1024 bytes).
I<value> kilobytes (where a kilobyte is 1024 bytes).
B<files>:I<value> begin again with the first file after I<value> number of
files were written (form a ring buffer).

View File

@ -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;

View File

@ -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);