Changeset 10918
- Timestamp:
- Jul 1, 2010, 5:14:34 AM (13 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/announcer.c
r10800 r10918 78 78 79 79 static int 80 compareTransfer( int a_uploaded, int a_downloaded,81 int b_uploaded, int b_downloaded )80 compareTransfer( uint32_t a_uploaded, uint32_t a_downloaded, 81 uint32_t b_uploaded, uint32_t b_downloaded ) 82 82 { 83 83 /* higher upload count goes first */ … … 137 137 char * host = NULL; 138 138 char * ret; 139 tr_urlParse( url, strlen( url ), NULL, &host, &port, NULL );139 tr_urlParse( url, -1, NULL, &host, &port, NULL ); 140 140 ret = tr_strdup_printf( "%s:%d", ( host ? host : "invalid" ), port ); 141 141 tr_free( host ); … … 173 173 tr_host * host; 174 174 char * url; 175 int up;176 int down;175 uint32_t up; 176 uint32_t down; 177 177 }; 178 178 … … 339 339 size_t i; 340 340 const char * pool = "abcdefghijklmnopqrstuvwxyz0123456789"; 341 const int poolSize = strlen( pool );341 const int poolSize = 36; 342 342 343 343 for( i=0; i<msglen; ++i ) … … 386 386 /* number of up/down/corrupt bytes since the last time we sent an 387 387 * "event=stopped" message that was acknowledged by the tracker */ 388 uint 64_t byteCounts[3];388 uint32_t byteCounts[3]; 389 389 390 390 tr_ptrArray trackers; /* tr_tracker_item */ … … 618 618 } 619 619 620 static int 620 static int8_t 621 621 getSeedProbability( int seeds, int leechers ) 622 622 { … … 625 625 626 626 if( seeds>=0 && leechers>=0 ) 627 return (int )((100.0*seeds)/(seeds+leechers));627 return (int8_t)((100.0*seeds)/(seeds+leechers)); 628 628 629 629 return -1; /* unknown */ … … 735 735 "&peer_id=%s" 736 736 "&port=%d" 737 "&uploaded=%" PRIu 64738 "&downloaded=%" PRIu 64737 "&uploaded=%" PRIu32 738 "&downloaded=%" PRIu32 739 739 "&left=%" PRIu64 740 740 "&numwant=%d" … … 757 757 758 758 if( tier->byteCounts[TR_ANN_CORRUPT] ) 759 evbuffer_add_printf( buf, "&corrupt=%" PRIu 64, tier->byteCounts[TR_ANN_CORRUPT] );759 evbuffer_add_printf( buf, "&corrupt=%" PRIu32, tier->byteCounts[TR_ANN_CORRUPT] ); 760 760 761 761 str = eventName; … … 781 781 inet_ntop( AF_INET6, ipv6, ipv6_readable, INET6_ADDRSTRLEN ); 782 782 evbuffer_add_printf( buf, "&ipv6="); 783 tr_http_escape( buf, ipv6_readable, strlen(ipv6_readable), TRUE );783 tr_http_escape( buf, ipv6_readable, -1, TRUE ); 784 784 } 785 785 … … 1170 1170 1171 1171 static uint8_t * 1172 parseOldPeers( tr_benc * bePeers, size_t * 1172 parseOldPeers( tr_benc * bePeers, size_t * byteCount ) 1173 1173 { 1174 1174 int i; … … 1198 1198 1199 1199 memcpy( walk, &addr, sizeof( tr_address ) ); 1200 port = htons( itmp );1200 port = htons( (uint16_t)itmp ); 1201 1201 memcpy( walk + sizeof( tr_address ), &port, 2 ); 1202 1202 walk += sizeof( tr_address ) + 2; -
trunk/libtransmission/clients.c
r10520 r10918 23 23 24 24 static int 25 charint( charch )25 charint( uint8_t ch ) 26 26 { 27 27 if( '0' <= ch && ch <= '9' ) return ch - '0'; … … 32 32 33 33 static int 34 getShadowInt( charch, int * setme )34 getShadowInt( uint8_t ch, int * setme ) 35 35 { 36 36 const char * str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-"; … … 52 52 53 53 static const char* 54 getMnemonicEnd( charch )54 getMnemonicEnd( uint8_t ch ) 55 55 { 56 56 switch( ch ) -
trunk/libtransmission/completion.h
r10911 r10918 93 93 } 94 94 95 static inline floattr_cpPercentComplete( const tr_completion * cp )95 static inline double tr_cpPercentComplete( const tr_completion * cp ) 96 96 { 97 97 const double ratio = tr_getRatio( cp->sizeNow, tr_torrentInfo(cp->tor)->totalSize ); … … 104 104 } 105 105 106 static inline floattr_cpPercentDone( const tr_completion * cp )106 static inline double tr_cpPercentDone( const tr_completion * cp ) 107 107 { 108 108 const double ratio = tr_getRatio( cp->sizeNow, tr_cpSizeWhenDone( cp ) ); -
trunk/libtransmission/torrent-magnet.c
r10842 r10918 349 349 } 350 350 351 float 351 double 352 352 tr_torrentGetMetadataPercent( const tr_torrent * tor ) 353 353 { 354 floatret;354 double ret; 355 355 356 356 if( tr_torrentHasMetadata( tor ) ) … … 361 361 ret = 0.0; 362 362 else 363 ret = (m->pieceCount - m->piecesNeededCount) / ( float)m->pieceCount;363 ret = (m->pieceCount - m->piecesNeededCount) / (double)m->pieceCount; 364 364 } 365 365 -
trunk/libtransmission/torrent-magnet.h
r10774 r10918 34 34 void tr_torrentSetMetadataSizeHint( tr_torrent * tor, int metadata_size ); 35 35 36 floattr_torrentGetMetadataPercent( const tr_torrent * tor );36 double tr_torrentGetMetadataPercent( const tr_torrent * tor ); 37 37 38 38 #endif -
trunk/libtransmission/torrent.c
r10912 r10918 1842 1842 { 1843 1843 tr_file * file; 1844 const uint8_tdnd = !doDownload;1844 const int8_t dnd = !doDownload; 1845 1845 tr_piece_index_t firstPiece, firstPieceDND; 1846 1846 tr_piece_index_t lastPiece, lastPieceDND; -
trunk/libtransmission/torrent.h
r10912 r10918 277 277 tr_torPieceCountBlocks( const tr_torrent * tor, const tr_piece_index_t piece ) 278 278 { 279 return piece == tor->info.pieceCount - 1 ? tor->blockCountInLastPiece 280 : tor->blockCountInPiece; 279 if( piece + 1 == tor->info.pieceCount ) 280 return tor->blockCountInLastPiece; 281 else 282 return tor->blockCountInPiece; 281 283 } 282 284 -
trunk/libtransmission/transmission.h
r10912 r10918 64 64 typedef uint32_t tr_file_index_t; 65 65 typedef uint32_t tr_piece_index_t; 66 typedef uint64_t tr_block_index_t; 66 /* assuming a 16 KiB block, a 32-bit block index gives us a maximum torrent size of 63 TiB. 67 * if we ever need to grow past that, change this to uint64_t ;) */ 68 typedef uint32_t tr_block_index_t; 67 69 typedef uint16_t tr_port; 68 70 typedef uint8_t tr_bool; … … 1722 1724 Range is [0..1] 1723 1725 @see tr_stat.status */ 1724 floatrecheckProgress;1726 double recheckProgress; 1725 1727 1726 1728 /** How much has been downloaded of the entire torrent. 1727 1729 Range is [0..1] */ 1728 floatpercentComplete;1730 double percentComplete; 1729 1731 1730 1732 /** How much of the metadata the torrent has. … … 1732 1734 For magnet links, this number will from from 0 to 1 as the metadata is downloaded. 1733 1735 Range is [0..1] */ 1734 floatmetadataPercentComplete;1736 double metadataPercentComplete; 1735 1737 1736 1738 /** How much has been downloaded of the files the user wants. This differs … … 1738 1740 Range is [0..1] 1739 1741 @see tr_stat.leftUntilDone */ 1740 floatpercentDone;1742 double percentDone; 1741 1743 1742 1744 /** How much has been uploaded to satisfy the seed ratio. 1743 1745 This is 1 if the ratio is reached or the torrent is set to seed forever. 1744 1746 Range is [0..1] */ 1745 floatseedRatioPercentDone;1747 double seedRatioPercentDone; 1746 1748 1747 1749 /** Speed all data being sent for this torrent. (KiB/s) -
trunk/libtransmission/utils.c
r10916 r10918 867 867 868 868 double 869 tr_getRatio( double numerator, doubledenominator )869 tr_getRatio( uint64_t numerator, uint64_t denominator ) 870 870 { 871 871 double ratio; 872 872 873 if( fabs(denominator) > 0.01)874 ratio = numerator / denominator;875 else if( fabs(numerator) > 0.01)873 if( denominator > 0 ) 874 ratio = numerator / (double)denominator; 875 else if( numerator > 0 ) 876 876 ratio = TR_RATIO_INF; 877 877 else -
trunk/libtransmission/utils.h
r10916 r10918 465 465 /** @brief return TR_RATIO_NA, TR_RATIO_INF, or a number in [0..1] 466 466 @return TR_RATIO_NA, TR_RATIO_INF, or a number in [0..1] */ 467 double tr_getRatio( double numerator, doubledenominator );467 double tr_getRatio( uint64_t numerator, uint64_t denominator ); 468 468 469 469 /**
Note: See TracChangeset
for help on using the changeset viewer.