From e652eefa2642213b073298de5e5019486ee728ba Mon Sep 17 00:00:00 2001 From: Richard Nyberg Date: Sat, 7 Oct 2006 09:47:07 +0000 Subject: [PATCH] Add value queries for total amount up- and downloaded. Use the cached values for torrent size and amount gotten when the torrent isn't active. --- btpd/cli_if.c | 12 ++++++++++-- misc/ipcdefs.h | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/btpd/cli_if.c b/btpd/cli_if.c index c2b0a7d..4bb07c4 100644 --- a/btpd/cli_if.c +++ b/btpd/cli_if.c @@ -59,14 +59,14 @@ write_ans(struct io_buffer *iob, struct tlib *tl, enum ipc_tval val) switch (val) { case IPC_TVAL_CGOT: if (tl->tp == NULL) - buf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); + buf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->content_have); else buf_print(iob, "i%dei%llde", IPC_TYPE_NUM, (long long)cm_content(tl->tp)); return; case IPC_TVAL_CSIZE: if (tl->tp == NULL) - buf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); + buf_print(iob, "i%dei%llde", IPC_TYPE_ERR, tl->content_size); else buf_print(iob, "i%dei%llde", IPC_TYPE_NUM, (long long)tl->tp->total_length); @@ -168,6 +168,14 @@ write_ans(struct io_buffer *iob, struct tlib *tl, enum ipc_tval val) } buf_print(iob, "i%de", ts); return; + case IPC_TVAL_TOTDWN: + buf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->tot_down + + (tl->tp == NULL ? 0 : tl->tp->net->downloaded)); + return; + case IPC_TVAL_TOTUP: + buf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->tot_up + + (tl->tp == NULL ? 0 : tl->tp->net->uploaded)); + return; case IPC_TVAL_TRERR: buf_print(iob, "i%dei%ue", IPC_TYPE_NUM, tl->tp == NULL ? 0 : tr_errors(tl->tp)); diff --git a/misc/ipcdefs.h b/misc/ipcdefs.h index 612c118..f36d724 100644 --- a/misc/ipcdefs.h +++ b/misc/ipcdefs.h @@ -38,6 +38,8 @@ TVDEF(RATEUP, NUM, "rate_up") TVDEF(SESSDWN, NUM, "sess_down") TVDEF(SESSUP, NUM, "sess_up") TVDEF(STATE, TSTATE, "state") +TVDEF(TOTDWN, NUM, "total_down") +TVDEF(TOTUP, NUM, "total_up") TVDEF(TRERR, NUM, "tr_errors") #ifdef __IPCTV #undef __IPCTV