Пример #1
0
int
main( void )
{
    int i;
    int test = 0;

    for( i = 0; i < 100000; ++i )
    {
        int       j;
        int       val = 0;
        uint8_t * pch = tr_peerIdNew( );

        check( strlen( (char*)pch ) == 20 );
        check( !memcmp( pch, PEERID_PREFIX, 8 ) );

        for( j = 8; j < 20; ++j )
        {
            char tmp[2] = { pch[j], '\0' };
            val += strtoul( tmp, NULL, 36 );
        }

        check( ( val % 36 ) == 0 );

        tr_free( pch );
    }

    return 0;
}
Пример #2
0
const uint8_t*
tr_getPeerId( void )
{
    static uint8_t * id = NULL;

    if( id == NULL )
        id = tr_peerIdNew( );
    return id;
}