tGet rid of unsigned char type - libeech - bittorrent library
 (HTM) git clone git://z3bra.org/libeech.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit a191041cb05e1a0da2f597436fd393d355c4f9c9
 (DIR) parent ba84409915193ec48b1becfaf434e3a1ba780628
 (HTM) Author: z3bra <contactatz3bradotorg>
       Date:   Thu, 19 Oct 2017 08:25:24 +0200
       
       Get rid of unsigned char type
       
       Diffstat:
         M libeech.c                           |      13 ++++++-------
         M sha1.c                              |       6 +++---
         M sha1.h                              |       2 +-
         M util.c                              |       2 +-
         M util.h                              |       2 +-
       
       5 files changed, 12 insertions(+), 13 deletions(-)
       ---
 (DIR) diff --git a/libeech.c b/libeech.c
       t@@ -17,7 +17,7 @@
        
        /* helpers to retrieve attributes from metadata */
        static char * peerid();
       -static unsigned char * infohash(struct torrent *);
       +static char * infohash(struct torrent *);
        static long torrentsize(struct torrent *);
        
        /* Initialization of the torrent struct */
       t@@ -29,33 +29,32 @@ static char *
        peerid()
        {
                int n;
       -        char hex[40];
       -        unsigned char hash[20];
       +        char hex[40], hash[20];
                static char id[21] = "-GT0000-XXXXXXXXXXXX";
        
                srand(time(NULL)); /* good-enough seed */
                n = rand();
                snprintf(hex, 40, "%08x%08x\n", n, ~n);
       -        sha1((unsigned char *)hex, 16, hash);
       +        sha1(hex, 16, hash);
                memcpy(id + 8, tohex(hash, hex, 12), 12);
        
                return id;
        }
        
        /* Calculate the SHA1 hash of the "info" key */
       -static unsigned char *
       +static char *
        infohash(struct torrent *t)
        {
                char *sp;
                struct be be;
       -        static unsigned char hash[20];
       +        static char hash[20];
        
                if (bekv(&t->be, "info", 4, &be) < 0)
                        return NULL;
                sp = be.off;
                if (benext(&be) < 0)
                        return NULL;
       -        sha1((unsigned char *)sp, be.off - sp, hash);
       +        sha1(sp, be.off - sp, hash);
        
                return hash;
        }
 (DIR) diff --git a/sha1.c b/sha1.c
       t@@ -261,12 +261,12 @@ int sha1_done(sha1_context * md, unsigned char *out)
            return 0;
        }
        
       -int sha1(const unsigned char *msg, size_t len, unsigned char *hash)
       +int sha1(const char *msg, size_t len, char *hash)
        {
                sha1_context ctx;
                int ret;
                if ((ret = sha1_init(&ctx))) return ret;
       -        if ((ret = sha1_process(&ctx, msg, len))) return ret;
       -        if ((ret = sha1_done(&ctx, hash))) return ret;
       +        if ((ret = sha1_process(&ctx, (const unsigned char *)msg, len))) return ret;
       +        if ((ret = sha1_done(&ctx, (unsigned char *)hash))) return ret;
                return 0;
        }
 (DIR) diff --git a/sha1.h b/sha1.h
       t@@ -16,4 +16,4 @@ typedef struct {
        int sha1_init(sha1_context * md);
        int sha1_process(sha1_context * md, const unsigned char *in, unsigned long inlen);
        int sha1_done(sha1_context * md, unsigned char *hash);
       -int sha1(const unsigned char *in, size_t len, unsigned char *hash);
       +int sha1(const char *in, size_t len, char *hash);
 (DIR) diff --git a/util.c b/util.c
       t@@ -2,7 +2,7 @@
        #include <string.h>
        
        char *
       -tohex(unsigned char *in, char *out, size_t len)
       +tohex(char *in, char *out, size_t len)
        {
                size_t i, j;
                char hex[] = "0123456789abcdef";
 (DIR) diff --git a/util.h b/util.h
       t@@ -1,3 +1,3 @@
        /* See LICENSE file for copyright and license details. */
        #include <stdlib.h>
       -char * tohex(unsigned char *, char *, size_t);
       +char * tohex(char *, char *, size_t);