++inCount;
/* zap the linefeed */
- if(( walk = strchr( line, '\r' ))) *walk = '\0';
- if(( walk = strchr( line, '\n' ))) *walk = '\0';
+ if(( walk = strchr( line, '\r' ))) *walk = '\0';
+ if(( walk = strchr( line, '\n' ))) *walk = '\0';
if( !parseLine( line, &range ) )
{
static struct cache_block *
findBlock( tr_cache * cache,
- tr_torrent * torrent,
+ tr_torrent * torrent,
tr_piece_index_t piece,
uint32_t offset )
{
}
#endif
-#if defined( SYS_DARWIN )
+#if defined( SYS_DARWIN )
/**
* 1. Enable readahead for reasons described above w/POSIX_FADV_SEQUENTIAL.
*
*/
{
const int err = errno;
- fcntl( file->fd, F_NOCACHE, 1 );
- fcntl( file->fd, F_RDAHEAD, 1 );
+ fcntl( file->fd, F_NOCACHE, 1 );
+ fcntl( file->fd, F_RDAHEAD, 1 );
errno = err;
}
#endif
for( pch=name; pch && *pch; ++pch )
if( *pch == '/' )
*pch = '_';
-
+
ret = tr_strdup_printf( "%s.%16.16s", name, inf->hashString );
tr_free( name );
escape( inf->hashEscaped, inf->hash, SHA_DIGEST_LENGTH );
/* maybe get the display name */
-
if( tr_bencDictFindStr( d, "display-name", &str ) ) {
tr_free( inf->name );
inf->name = tr_strdup( str );
what |= EVBUFFER_ERROR;
}
- tr_net_strerror( errstr, sizeof( errstr ), e );
+ tr_net_strerror( errstr, sizeof( errstr ), e );
dbgmsg( io, "event_read_cb got an error. res is %d, what is %hd, errno is %d (%s)", res, what, e, errstr );
if( io->gotError != NULL )
tr_netSetTOS( socket, session->peerSocketTOS );
maybeSetCongestionAlgorithm( socket, session->peer_congestion_algorithm );
}
-
+
io = tr_new0( tr_peerIo, 1 );
io->magicNumber = MAGIC_NUMBER;
io->refCount = 1;
short what = EVBUFFER_READ | EVBUFFER_ERROR;
if( res == 0 )
what |= EVBUFFER_EOF;
- tr_net_strerror( errstr, sizeof( errstr ), e );
+ tr_net_strerror( errstr, sizeof( errstr ), e );
dbgmsg( io, "tr_peerIoTryRead got an error. res is %d, what is %hd, errno is %d (%s)", res, what, e, errstr );
io->gotError( io, what, io->userData );
}
char errstr[512];
const short what = EVBUFFER_WRITE | EVBUFFER_ERROR;
- tr_net_strerror( errstr, sizeof( errstr ), e );
+ tr_net_strerror( errstr, sizeof( errstr ), e );
dbgmsg( io, "tr_peerIoTryWrite got an error. res is %d, what is %hd, errno is %d (%s)", n, what, e, errstr );
if( io->gotError != NULL )
assertSortedAndUnique( t, compare );
return ret;
}
-
EVBUFFER_LENGTH( out ) = content_len - server->stream.avail_out;
#if 0
- fprintf( stderr, "compressed response is %.2f of original (raw==%zu bytes; compressed==%zu)\n",
+ fprintf( stderr, "compressed response is %.2f of original (raw==%zu bytes; compressed==%zu)\n",
(double)EVBUFFER_LENGTH(out)/content_len,
content_len, EVBUFFER_LENGTH(out) );
#endif
{
int i;
int maxTier = -1;
-
- for( i=0; i<n; ++i )
+
+ for( i=0; i<n; ++i )
{
tgt[i].tier = src[i].tier;
tgt[i].announce = tr_strdup( src[i].announce );
if( ( *str == '%' ) && ( str[1] == '\'' ) )
str = str + 1;
-
+
}
*out = '\0';
const char * end;
const char zero = '\0';
struct evbuffer * buf = evbuffer_new( );
-
+
while( !tr_utf8_validate( in, inlen, &end ) )
{
const int good_len = end - in;
in += ( good_len + 1 );
evbuffer_add( buf, "?", 1 );
}
-
+
evbuffer_add( buf, in, inlen );
evbuffer_add( buf, &zero, 1 );
ret = tr_memdup( EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) );
{
char * pt;
char buf[128];
- const int max_precision = (int) log10( 1.0 / DBL_EPSILON ) - 1;
- tr_snprintf( buf, sizeof( buf ), "%.*f", max_precision, x );
+ const int max_precision = (int) log10( 1.0 / DBL_EPSILON ) - 1;
+ tr_snprintf( buf, sizeof( buf ), "%.*f", max_precision, x );
if(( pt = strstr( buf, localeconv()->decimal_point )))
pt[precision ? precision+1 : 0] = '\0';
return atof(buf);
char * name;
uint64_t value;
};
-
+
struct formatter_units
{
struct formatter_unit units[4];
static struct formatter_units mem_units;
unsigned int tr_mem_K = 0u;
-
+
void
tr_formatter_mem_init( unsigned int kilo,
const char * kb, const char * mb,
return byte_count;
}
-static int
-compareVerifyByPriorityAndSize( const void * va, const void * vb )
-{
- const struct verify_node * a = va;
- const struct verify_node * b = vb;
+static int
+compareVerifyByPriorityAndSize( const void * va, const void * vb )
+{
+ const struct verify_node * a = va;
+ const struct verify_node * b = vb;
/* higher priority comes before lower priority */
const tr_priority_t pa = tr_torrentGetPriority( a->torrent );
if( a->current_size < b->current_size ) return -1;
if( a->current_size > b->current_size ) return 1;
return 0;
-}
+}
void
tr_verifyAdd( tr_torrent * tor,
const tr_address * addr;
CURL * e = curl_easy_init( );
const long verbose = getenv( "TR_CURL_VERBOSE" ) != NULL;
- char * cookie_filename = tr_buildPath( s->configDir, "cookies.txt", NULL );
+ char * cookie_filename = tr_buildPath( s->configDir, "cookies.txt", NULL );
curl_easy_setopt( e, CURLOPT_AUTOREFERER, 1L );
- curl_easy_setopt( e, CURLOPT_COOKIEFILE, cookie_filename );
+ curl_easy_setopt( e, CURLOPT_COOKIEFILE, cookie_filename );
curl_easy_setopt( e, CURLOPT_ENCODING, "gzip;q=1.0, deflate, identity" );
curl_easy_setopt( e, CURLOPT_FOLLOWLOCATION, 1L );
curl_easy_setopt( e, CURLOPT_MAXREDIRS, -1L );
if( task->range )
curl_easy_setopt( e, CURLOPT_RANGE, task->range );
- tr_free( cookie_filename );
+ tr_free( cookie_filename );
return e;
}
* http://msdn.microsoft.com/en-us/library/ms740141%28VS.85%29.aspx
* On win32, any two of the parameters, readfds, writefds, or exceptfds,
* can be given as null. At least one must be non-null, and any non-null
- * descriptor set must contain at least one handle to a socket.
+ * descriptor set must contain at least one handle to a socket.
*/
static void
tr_select( int nfds,
char errstr[512];
const int e = EVUTIL_SOCKET_ERROR( );
tr_net_strerror( errstr, sizeof( errstr ), e );
- dbgmsg( "Error: select (%d) %s", e, errstr );
+ dbgmsg( "Error: select (%d) %s", e, errstr );
}
#else
select( nfds, r_fd_set, w_fd_set, c_fd_set, t );