about summary refs log tree commit diff
path: root/cli/btcli.c
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2006-10-07 10:21:01 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2006-10-07 10:21:01 +0000
commit0eb36d3914b11b6cd7dc77de5380a191d0e6a124 (patch)
tree9098cc433ba957c42fc922a8eb036675d085d31e /cli/btcli.c
parente652eefa2642213b073298de5e5019486ee728ba (diff)
downloadbtpd-0eb36d3914b11b6cd7dc77de5380a191d0e6a124.tar.gz
btpd-0eb36d3914b11b6cd7dc77de5380a191d0e6a124.zip
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.

Diffstat (limited to 'cli/btcli.c')
-rw-r--r--cli/btcli.c29
1 files changed, 29 insertions, 0 deletions
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)
 {