Add -b / --use-bit option to display rates in bit/s instead of bytes/s

Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
Thomas Graf
2014-05-08 15:16:38 +02:00
parent 127ffda015
commit 46ec101b00
6 changed files with 56 additions and 20 deletions

View File

@ -59,6 +59,7 @@ static char *usage_text =
"\n" \
"Output:\n" \
" -U, --use-si Use SI units\n" \
" -b, --use-bit Display in bits instead of btyes\n" \
"\n" \
"Module configuration:\n" \
" modparm := MODULE:optlist,MODULE:optlist,...\n" \
@ -170,7 +171,7 @@ static int parse_args_post(int argc, char *argv[])
for (;;)
{
char *gostr = "i:o:p:r:R:s:aU" \
char *gostr = "i:o:p:r:R:s:aUb" \
"L:hvVf:";
struct option long_opts[] = {
@ -182,6 +183,7 @@ static int parse_args_post(int argc, char *argv[])
{"sleep-interval", 1, 0, 's'},
{"show-all", 0, 0, 'a'},
{"use-si", 0, 0, 'U'},
{"use-bit", 0, 0, 'b'},
{"lifetime", 1, 0, 'L'},
{0, 0, 0, 0},
};
@ -225,6 +227,10 @@ static int parse_args_post(int argc, char *argv[])
cfg_setbool(cfg, "use_si", cfg_true);
break;
case 'b':
cfg_setbool(cfg, "use_bit", cfg_true);
break;
case 'L':
cfg_setint(cfg, "lifetime", strtoul(optarg, NULL, 0));
break;