浏览代码

Some clean up of the values sent for tget answers. Send values that makes

sense instead of errors. Fix wrong type for IPC_TVAL_CSIZE, reported by
Arnaud Bergeron.
master
Richard Nyberg 18 年前
父节点
当前提交
372cec7b53
共有 1 个文件被更改,包括 12 次插入30 次删除
  1. +12
    -30
      btpd/cli_if.c

+ 12
- 30
btpd/cli_if.c 查看文件

@@ -58,18 +58,11 @@ write_ans(struct io_buffer *iob, struct tlib *tl, enum ipc_tval val)
enum ipc_tstate ts = IPC_TSTATE_INACTIVE; enum ipc_tstate ts = IPC_TSTATE_INACTIVE;
switch (val) { switch (val) {
case IPC_TVAL_CGOT: case IPC_TVAL_CGOT:
if (tl->tp == NULL) buf_print(iob, "i%dei%llde", IPC_TYPE_NUM,
buf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->content_have); tl->tp == NULL ? tl->content_have : (long long)cm_content(tl->tp));
else
buf_print(iob, "i%dei%llde", IPC_TYPE_NUM,
(long long)cm_content(tl->tp));
return; return;
case IPC_TVAL_CSIZE: case IPC_TVAL_CSIZE:
if (tl->tp == NULL) buf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->content_size);
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);
return; return;
case IPC_TVAL_PCCOUNT: case IPC_TVAL_PCCOUNT:
if (tl->tp == NULL) if (tl->tp == NULL)
@@ -87,7 +80,7 @@ write_ans(struct io_buffer *iob, struct tlib *tl, enum ipc_tval val)
return; return;
case IPC_TVAL_PCSEEN: case IPC_TVAL_PCSEEN:
if (tl->tp == NULL) if (tl->tp == NULL)
buf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); buf_print(iob, "i%dei%de", IPC_TYPE_NUM, 0);
else { else {
unsigned long pcseen = 0; unsigned long pcseen = 0;
for (unsigned long i = 0; i < tl->tp->npieces; i++) for (unsigned long i = 0; i < tl->tp->npieces; i++)
@@ -97,31 +90,20 @@ write_ans(struct io_buffer *iob, struct tlib *tl, enum ipc_tval val)
} }
return; return;
case IPC_TVAL_RATEDWN: case IPC_TVAL_RATEDWN:
if (tl->tp == NULL) buf_print(iob, "i%dei%lue", IPC_TYPE_NUM,
buf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); tl->tp == NULL ? 0UL : tl->tp->net->rate_dwn / RATEHISTORY);
else
buf_print(iob, "i%dei%lue", IPC_TYPE_NUM,
tl->tp->net->rate_dwn / RATEHISTORY);
return; return;
case IPC_TVAL_RATEUP: case IPC_TVAL_RATEUP:
if (tl->tp == NULL) buf_print(iob, "i%dei%lue", IPC_TYPE_NUM,
buf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); tl->tp == NULL ? 0UL : tl->tp->net->rate_up / RATEHISTORY);
else
buf_print(iob, "i%dei%lue", IPC_TYPE_NUM,
tl->tp->net->rate_up / RATEHISTORY);
return; return;
case IPC_TVAL_SESSDWN: case IPC_TVAL_SESSDWN:
if (tl->tp == NULL) buf_print(iob, "i%dei%llde", IPC_TYPE_NUM,
buf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); tl->tp == NULL ? 0LL : tl->tp->net->downloaded);
else
buf_print(iob, "i%dei%llde", IPC_TYPE_NUM,
tl->tp->net->downloaded);
return; return;
case IPC_TVAL_SESSUP: case IPC_TVAL_SESSUP:
if (tl->tp == NULL) buf_print(iob, "i%dei%llde", IPC_TYPE_NUM,
buf_print(iob, "i%dei%de", IPC_TYPE_ERR, IPC_ETINACTIVE); tl->tp == NULL ? 0LL : tl->tp->net->uploaded);
else
buf_print(iob, "i%dei%llde", IPC_TYPE_NUM, tl->tp->net->uploaded);
return; return;
case IPC_TVAL_DIR: case IPC_TVAL_DIR:
if (tl->dir != NULL) if (tl->dir != NULL)


||||||
x
 
000:0
正在加载...
取消
保存