From 0eb36d3914b11b6cd7dc77de5380a191d0e6a124 Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Sat, 7 Oct 2006 10:21:01 +0000 Subject: btcli list now displays size, ratio and the percentage got of torrents. It sorts by name instead of number (should probably add options for sorting). It now also takes torrents to list as optional arguments. Added ratio to btcli stat display. Changed the help text for both commands. Some code shuffle and other tweaks. --- cli/btcli.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'cli/btcli.c') diff --git a/cli/btcli.c b/cli/btcli.c index 78a3313..f1305a2 100644 --- a/cli/btcli.c +++ b/cli/btcli.c @@ -24,6 +24,35 @@ handle_ipc_res(enum ipc_err code, const char *cmd, const char *target) return code; } +void +print_percent(long long part, long long whole) +{ + printf("%5.1f%% ", floor(1000.0 * part / whole) / 10); +} + +void +print_rate(long long rate) +{ + if (rate >= 999.995 * (1 << 10)) + printf("%6.2fMB/s ", (double)rate / (1 << 20)); + else + printf("%6.2fkB/s ", (double)rate / (1 << 10)); +} + +void +print_size(long long size) +{ + if (size >= 999.995 * (1 << 20)) + printf("%6.2fG ", (double)size / (1 << 30)); + else + printf("%6.2fM ", (double)size / (1 << 20)); +} +void +print_ratio(long long part, long long whole) +{ + printf("%7.2f ", (double)part / whole); +} + char tstate_char(enum ipc_tstate ts) { -- cgit 1.4.1