Changeset 9531
- Timestamp:
- Nov 20, 2009, 4:38:19 AM (13 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 3 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/Makefile.am
r9494 r9531 28 28 JSON_parser.c \ 29 29 list.c \ 30 magnet.c \ 30 31 makemeta.c \ 31 32 metainfo.c \ … … 74 75 JSON_parser.h \ 75 76 list.h \ 77 magnet.h \ 76 78 makemeta.h \ 77 79 metainfo.h \ … … 109 111 clients-test \ 110 112 json-test \ 113 magnet-test \ 111 114 peer-msgs-test \ 112 115 rpc-test \ … … 147 150 json_test_LDFLAGS = ${apps_ldflags} 148 151 152 magnet_test_SOURCES = magnet-test.c 153 magnet_test_LDADD = ${apps_ldadd} 154 magnet_test_LDFLAGS = ${apps_ldflags} 155 149 156 rpc_test_SOURCES = rpc-test.c 150 157 rpc_test_LDADD = ${apps_ldadd} -
trunk/libtransmission/utils-test.c
r9463 r9531 9 9 #include "crypto.h" 10 10 11 /* #define VERBOSE */ 11 12 #undef VERBOSE 12 13 #define NUM_LOOPS 1 … … 282 283 } 283 284 285 static int 286 test_hex( void ) 287 { 288 char hex1[41]; 289 char hex2[41]; 290 uint8_t sha1[20]; 291 /*uint8_t sha2[20];*/ 292 293 memcpy( hex1, "fb5ef5507427b17e04b69cef31fa3379b456735a", 41 ); 294 tr_hex_to_sha1( sha1, hex1 ); 295 tr_sha1_to_hex( hex2, sha1 ); 296 check( !strcmp( hex1, hex2 ) ) 297 298 return 0; 299 } 300 284 301 int 285 302 main( void ) … … 309 326 tr_free( out ); 310 327 328 if( ( i = test_hex( ) ) ) 329 return i; 311 330 if( ( i = test_lowerbound( ) ) ) 312 331 return i; -
trunk/libtransmission/utils.c
r9497 r9531 903 903 904 904 void 905 tr_sha1_to_hex( char * out,906 const uint8_t * sha1 ) 907 { 905 tr_sha1_to_hex( char * out, const uint8_t * sha1 ) 906 { 907 int i; 908 908 static const char hex[] = "0123456789abcdef"; 909 int i; 910 911 for( i = 0; i < 20; i++ ) 912 { 913 unsigned int val = *sha1++; 909 910 for( i=0; i<20; ++i ) 911 { 912 const unsigned int val = *sha1++; 914 913 *out++ = hex[val >> 4]; 915 914 *out++ = hex[val & 0xf]; 916 915 } 916 917 917 *out = '\0'; 918 } 919 920 void 921 tr_hex_to_sha1( uint8_t * out, const char * in ) 922 { 923 int i; 924 static const char hex[] = "0123456789abcdef"; 925 926 for( i=0; i<20; ++i ) 927 { 928 const int hi = strchr( hex, *in++ ) - hex; 929 const int lo = strchr( hex, *in++ ) - hex; 930 *out++ = (uint8_t)( (hi<<4) | lo ); 931 } 918 932 } 919 933 -
trunk/libtransmission/utils.h
r9472 r9531 378 378 void * userData ); 379 379 380 void tr_sha1_to_hex( char * 380 void tr_sha1_to_hex( char * out, 381 381 const uint8_t * sha1 ) TR_GNUC_NONNULL(1,2); 382 383 void tr_hex_to_sha1( uint8_t * out, 384 const char * hex ) TR_GNUC_NONNULL(1,2); 382 385 383 386 -
trunk/libtransmission/web.c
r9513 r9531 685 685 } 686 686 } 687 688 char* 689 tr_http_unescape( const char * str, int len ) 690 { 691 char * tmp = curl_unescape( str, len ); 692 char * ret = tr_strdup( tmp ); 693 curl_free( tmp ); 694 return ret; 695 } -
trunk/libtransmission/web.h
r9516 r9531 41 41 void tr_http_escape( struct evbuffer *out, const char *str, int len, int noslashes ); 42 42 43 char* tr_http_unescape( const char * str, int len ); 44 43 45 #endif
Note: See TracChangeset
for help on using the changeset viewer.