tRetrieve piece len, number and sha1 from torrent file - libeech - bittorrent library
 (HTM) git clone git://z3bra.org/libeech.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 97095244b34d1cc1b0678b9dcd84908ae9388cb6
 (DIR) parent 802b7ec302e36a3e2bc57cae0d09114093181ecc
 (HTM) Author: z3bra <contactatz3bradotorg>
       Date:   Sat, 10 Feb 2018 13:54:56 +0100
       
       Retrieve piece len, number and sha1 from torrent file
       
       Diffstat:
         M libeech.c                           |       7 +++++++
         M libeech.h                           |       3 +++
       
       2 files changed, 10 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/libeech.c b/libeech.c
       t@@ -388,6 +388,13 @@ glch_loadtorrent(struct torrent *t, char *b, size_t s)
                t->nfile = torrentfiles(t);
                t->peers = NULL;
        
       +        /* pieces related values */
       +        t->psz = bekint(&t->info, "piece length", 12);
       +        t->npiece = t->sz / t->psz + !!(t->sz % t->psz);
       +        t->pieces = malloc(t->npiece * 20);
       +        bekstr(&t->be, "pieces", 6, &v);
       +        memcpy(t->pieces, v.off, v.end - v.off);
       +
                return 0;
        }
        
 (DIR) diff --git a/libeech.h b/libeech.h
       t@@ -38,11 +38,14 @@ struct torrent {
                char id[21];
                char ih[20];
                char tr[PATH_MAX];
       +        char *pieces;
                struct be be;
                struct be info;
                struct peer *peers;
                struct file *files;
       +        long npiece;
                long nfile;
       +        long psz;
                long sz;
                long dl;
                long ul;