1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

(trunk libT) copyediting in resume.c

This commit is contained in:
Jordan Lee 2011-04-01 03:13:44 +00:00
parent 2e05d830e5
commit 0fffd84f65

View file

@ -156,27 +156,24 @@ loadPeers( tr_benc * dict, tr_torrent * tor )
***/ ***/
static void static void
saveDND( tr_benc * dict, saveDND( tr_benc * dict, const tr_torrent * tor )
const tr_torrent * tor )
{ {
const tr_info * inf = tr_torrentInfo( tor ); tr_benc * list;
tr_file_index_t i;
const tr_info * const inf = tr_torrentInfo( tor );
const tr_file_index_t n = inf->fileCount; const tr_file_index_t n = inf->fileCount;
tr_file_index_t i;
tr_benc * list;
list = tr_bencDictAddList( dict, KEY_DND, n ); list = tr_bencDictAddList( dict, KEY_DND, n );
for( i = 0; i < n; ++i ) for( i=0; i<n; ++i )
tr_bencListAddInt( list, inf->files[i].dnd ? 1 : 0 ); tr_bencListAddInt( list, inf->files[i].dnd ? 1 : 0 );
} }
static uint64_t static uint64_t
loadDND( tr_benc * dict, loadDND( tr_benc * dict, tr_torrent * tor )
tr_torrent * tor )
{ {
uint64_t ret = 0; uint64_t ret = 0;
tr_info * inf = &tor->info; tr_benc * list = NULL;
const tr_file_index_t n = inf->fileCount; const tr_file_index_t n = tor->info.fileCount;
tr_benc * list = NULL;
if( tr_bencDictFindList( dict, KEY_DND, &list ) if( tr_bencDictFindList( dict, KEY_DND, &list )
&& ( tr_bencListSize( list ) == n ) ) && ( tr_bencListSize( list ) == n ) )
@ -186,7 +183,7 @@ loadDND( tr_benc * dict,
tr_file_index_t * dnd = tr_new( tr_file_index_t, n ); tr_file_index_t * dnd = tr_new( tr_file_index_t, n );
tr_file_index_t i, dlCount = 0, dndCount = 0; tr_file_index_t i, dlCount = 0, dndCount = 0;
for( i = 0; i < n; ++i ) for( i=0; i<n; ++i )
{ {
if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) && tmp ) if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) && tmp )
dnd[dndCount++] = i; dnd[dndCount++] = i;
@ -230,10 +227,10 @@ loadDND( tr_benc * dict,
static void static void
saveFilePriorities( tr_benc * dict, const tr_torrent * tor ) saveFilePriorities( tr_benc * dict, const tr_torrent * tor )
{ {
const tr_info * inf = tr_torrentInfo( tor ); tr_benc * list;
tr_file_index_t i;
const tr_info * const inf = tr_torrentInfo( tor );
const tr_file_index_t n = inf->fileCount; const tr_file_index_t n = inf->fileCount;
tr_file_index_t i;
tr_benc * list;
list = tr_bencDictAddList( dict, KEY_FILE_PRIORITIES, n ); list = tr_bencDictAddList( dict, KEY_FILE_PRIORITIES, n );
for( i = 0; i < n; ++i ) for( i = 0; i < n; ++i )
@ -243,10 +240,9 @@ saveFilePriorities( tr_benc * dict, const tr_torrent * tor )
static uint64_t static uint64_t
loadFilePriorities( tr_benc * dict, tr_torrent * tor ) loadFilePriorities( tr_benc * dict, tr_torrent * tor )
{ {
uint64_t ret = 0; tr_benc * list;
tr_info * inf = &tor->info; uint64_t ret = 0;
const tr_file_index_t n = inf->fileCount; const tr_file_index_t n = tor->info.fileCount;
tr_benc * list;
if( tr_bencDictFindList( dict, KEY_FILE_PRIORITIES, &list ) if( tr_bencDictFindList( dict, KEY_FILE_PRIORITIES, &list )
&& ( tr_bencListSize( list ) == n ) ) && ( tr_bencListSize( list ) == n ) )
@ -325,8 +321,9 @@ enum old_speed_modes
static uint64_t static uint64_t
loadSpeedLimits( tr_benc * dict, tr_torrent * tor ) loadSpeedLimits( tr_benc * dict, tr_torrent * tor )
{ {
uint64_t ret = 0;
tr_benc * d; tr_benc * d;
uint64_t ret = 0;
if( tr_bencDictFindDict( dict, KEY_SPEEDLIMIT_UP, &d ) ) if( tr_bencDictFindDict( dict, KEY_SPEEDLIMIT_UP, &d ) )
{ {
@ -363,11 +360,10 @@ loadSpeedLimits( tr_benc * dict, tr_torrent * tor )
} }
static uint64_t static uint64_t
loadRatioLimits( tr_benc * dict, loadRatioLimits( tr_benc * dict, tr_torrent * tor )
tr_torrent * tor )
{ {
uint64_t ret = 0;
tr_benc * d; tr_benc * d;
uint64_t ret = 0;
if( tr_bencDictFindDict( dict, KEY_RATIOLIMIT, &d ) ) if( tr_bencDictFindDict( dict, KEY_RATIOLIMIT, &d ) )
{ {
@ -384,11 +380,10 @@ loadRatioLimits( tr_benc * dict,
} }
static uint64_t static uint64_t
loadIdleLimits( tr_benc * dict, loadIdleLimits( tr_benc * dict, tr_torrent * tor )
tr_torrent * tor )
{ {
uint64_t ret = 0;
tr_benc * d; tr_benc * d;
uint64_t ret = 0;
if( tr_bencDictFindDict( dict, KEY_IDLELIMIT, &d ) ) if( tr_bencDictFindDict( dict, KEY_IDLELIMIT, &d ) )
{ {
@ -672,8 +667,7 @@ tr_torrentSaveResume( tr_torrent * tor )
} }
static uint64_t static uint64_t
loadFromFile( tr_torrent * tor, loadFromFile( tr_torrent * tor, uint64_t fieldsToLoad )
uint64_t fieldsToLoad )
{ {
int64_t i; int64_t i;
const char * str; const char * str;
@ -825,10 +819,7 @@ loadFromFile( tr_torrent * tor,
} }
static uint64_t static uint64_t
setFromCtor( tr_torrent * tor, setFromCtor( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor, int mode )
uint64_t fields,
const tr_ctor * ctor,
int mode )
{ {
uint64_t ret = 0; uint64_t ret = 0;
@ -861,17 +852,13 @@ setFromCtor( tr_torrent * tor,
} }
static uint64_t static uint64_t
useManditoryFields( tr_torrent * tor, useManditoryFields( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor )
uint64_t fields,
const tr_ctor * ctor )
{ {
return setFromCtor( tor, fields, ctor, TR_FORCE ); return setFromCtor( tor, fields, ctor, TR_FORCE );
} }
static uint64_t static uint64_t
useFallbackFields( tr_torrent * tor, useFallbackFields( tr_torrent * tor, uint64_t fields, const tr_ctor * ctor )
uint64_t fields,
const tr_ctor * ctor )
{ {
return setFromCtor( tor, fields, ctor, TR_FALLBACK ); return setFromCtor( tor, fields, ctor, TR_FALLBACK );
} }
@ -901,4 +888,3 @@ tr_torrentRemoveResume( const tr_torrent * tor )
unlink( filename ); unlink( filename );
tr_free( filename ); tr_free( filename );
} }