added tr_sha1_to_hex()
This commit is contained in:
parent
aafadf7170
commit
d2f1c7aff3
|
@ -192,11 +192,7 @@ tr_metainfoParse( tr_info * inf, const benc_val_t * meta_in, const char * tag )
|
|||
return TR_EINVALID;
|
||||
}
|
||||
|
||||
for( i = 0; i < SHA_DIGEST_LENGTH; i++ )
|
||||
{
|
||||
snprintf( inf->hashString + i * 2, sizeof( inf->hashString ) - i * 2,
|
||||
"%02x", inf->hash[i] );
|
||||
}
|
||||
tr_sha1_to_hex( inf->hashString, inf->hash );
|
||||
savedname( inf->torrent, sizeof( inf->torrent ), inf->hashString, tag );
|
||||
|
||||
/* comment */
|
||||
|
|
|
@ -883,3 +883,16 @@ tr_getRatio( double numerator, double denominator )
|
|||
|
||||
return ratio;
|
||||
}
|
||||
|
||||
void
|
||||
tr_sha1_to_hex( char * out, const uint8_t * sha1 )
|
||||
{
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
int i;
|
||||
for (i = 0; i < 20; i++) {
|
||||
unsigned int val = *sha1++;
|
||||
*out++ = hex[val >> 4];
|
||||
*out++ = hex[val & 0xf];
|
||||
}
|
||||
*out = '\0';
|
||||
}
|
||||
|
|
|
@ -138,6 +138,8 @@ void tr_set_compare( const void * a, size_t aCount,
|
|||
int tr_compareUint16( uint16_t a, uint16_t b );
|
||||
int tr_compareUint32( uint32_t a, uint32_t b );
|
||||
|
||||
void tr_sha1_to_hex( char * out, const uint8_t * sha1 );
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
|
Loading…
Reference in New Issue