tSave torrent size - libeech - bittorrent library
(HTM) git clone git://z3bra.org/libeech.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 1dbca24f67c51c35b0ea0c3b7e2d98b85eec5005
(DIR) parent 565c2cd5e1797bdab81b3f82bcc5af1033330aaf
(HTM) Author: z3bra <contactatz3bradotorg>
Date: Sun, 22 Oct 2017 10:40:18 +0200
Save torrent size
Diffstat:
M libeech.c | 4 ++--
M torrent.c | 1 +
2 files changed, 3 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/libeech.c b/libeech.c
t@@ -40,8 +40,7 @@ torrentsize(struct torrent *t)
long l, sz = 0;
struct be info, file;
- if (bekv(&t->be, "info", 4, &info) < 0)
- return -1;
+ bekv(&t->be, "info", 4, &info);
if (!bekv(&info, "files", 5, &file)) {
for (i = 0; !belistnext(&file) && !belistover(&file); i++) {
l = bekint(&file, "length", 6);
t@@ -128,6 +127,7 @@ glch_loadtorrent(struct torrent *t, char *b, size_t s)
t->ul = 0;
t->dl = 0;
+ t->sz = torrentsize(t);
return 0;
}
(DIR) diff --git a/torrent.c b/torrent.c
t@@ -57,6 +57,7 @@ main(int argc, char *argv[])
printf("Peer ID: %s\n", t.id);
printf("Tracker: %s\n", t.tr);
+ printf("Length: %ld bytes\n", t.sz);
return 0;
}