mirror of
https://github.com/transmission/transmission
synced 2025-03-19 02:05:32 +00:00
(trunk libT) use libevent's portability wrapper for strcasecmp()
This commit is contained in:
parent
4a4842fea5
commit
075a0a8b86
5 changed files with 22 additions and 20 deletions
|
@ -14,13 +14,15 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h> /* FILE, stderr */
|
||||
#include <stdlib.h> /* qsort */
|
||||
#include <string.h> /* strcmp, strlen, strcasecmp */
|
||||
#include <string.h> /* strcmp, strlen */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <event2/util.h> /* evutil_ascii_strcasecmp() */
|
||||
|
||||
#include "transmission.h"
|
||||
#include "crypto.h" /* tr_sha1 */
|
||||
#include "fdlimit.h" /* tr_open_file_for_scanning() */
|
||||
|
@ -105,13 +107,12 @@ bestPieceSize( uint64_t totalSize )
|
|||
}
|
||||
|
||||
static int
|
||||
builderFileCompare( const void * va,
|
||||
const void * vb )
|
||||
builderFileCompare( const void * va, const void * vb )
|
||||
{
|
||||
const tr_metainfo_builder_file * a = va;
|
||||
const tr_metainfo_builder_file * b = vb;
|
||||
|
||||
return strcasecmp( a->filename, b->filename );
|
||||
return evutil_ascii_strcasecmp( a->filename, b->filename );
|
||||
}
|
||||
|
||||
tr_metainfo_builder*
|
||||
|
|
|
@ -55,10 +55,6 @@
|
|||
#define MY_REALM "Transmission"
|
||||
#define TR_N_ELEMENTS( ary ) ( sizeof( ary ) / sizeof( *ary ) )
|
||||
|
||||
#ifdef WIN32
|
||||
#define strncasecmp _strnicmp
|
||||
#endif
|
||||
|
||||
struct tr_rpc_server
|
||||
{
|
||||
tr_bool isEnabled;
|
||||
|
@ -599,7 +595,7 @@ handle_request( struct evhttp_request * req, void * arg )
|
|||
evhttp_add_header( req->output_headers, "Server", MY_REALM );
|
||||
|
||||
auth = evhttp_find_header( req->input_headers, "Authorization" );
|
||||
if( auth && !strncasecmp( auth, "basic ", 6 ) )
|
||||
if( auth && !evutil_ascii_strncasecmp( auth, "basic ", 6 ) )
|
||||
{
|
||||
int plen;
|
||||
char * p = tr_base64_decode( auth + 6, 0, &plen );
|
||||
|
|
|
@ -252,25 +252,30 @@ tr_sessionGetPublicAddress( const tr_session * session, int tr_af_type, tr_bool
|
|||
#endif
|
||||
|
||||
static int
|
||||
parse_tos(const char *string)
|
||||
parse_tos( const char *str )
|
||||
{
|
||||
char *p;
|
||||
int value;
|
||||
|
||||
if(strcasecmp(string, "") == 0 || strcasecmp(string, "default") == 0)
|
||||
if( !evutil_ascii_strcasecmp( str, "" ) )
|
||||
return 0;
|
||||
else if(strcasecmp(string, "lowcost") == 0 ||
|
||||
strcasecmp(string, "mincost") == 0)
|
||||
if( !evutil_ascii_strcasecmp( str, "default" ) )
|
||||
return 0;
|
||||
|
||||
if( !evutil_ascii_strcasecmp( str, "lowcost" ) )
|
||||
return 0x10;
|
||||
else if(strcasecmp(string, "throughput") == 0)
|
||||
if( !evutil_ascii_strcasecmp( str, "mincost" ) )
|
||||
return 0x10;
|
||||
|
||||
if( !evutil_ascii_strcasecmp( str, "throughput" ) )
|
||||
return 0x08;
|
||||
else if(strcasecmp(string, "reliability") == 0)
|
||||
if( !evutil_ascii_strcasecmp( str, "reliability" ) )
|
||||
return 0x04;
|
||||
else if(strcasecmp(string, "lowdelay") == 0)
|
||||
if( !evutil_ascii_strcasecmp( str, "lowdelay" ) )
|
||||
return 0x02;
|
||||
|
||||
value = strtol(string, &p, 0);
|
||||
if(p == NULL || p == string)
|
||||
value = strtol( str, &p, 0 );
|
||||
if( !p || ( p == str ) )
|
||||
return 0;
|
||||
|
||||
return value;
|
||||
|
|
|
@ -101,7 +101,7 @@ tr_torrentFindFromHashString( tr_session * session, const char * str )
|
|||
tr_torrent * tor = NULL;
|
||||
|
||||
while(( tor = tr_torrentNext( session, tor )))
|
||||
if( !strcasecmp( str, tor->info.hashString ) )
|
||||
if( !evutil_ascii_strcasecmp( str, tor->info.hashString ) )
|
||||
return tor;
|
||||
|
||||
return NULL;
|
||||
|
|
|
@ -854,7 +854,7 @@ tr_str_has_suffix( const char *str, const char *suffix )
|
|||
if( str_len < suffix_len )
|
||||
return FALSE;
|
||||
|
||||
return !strncasecmp( str + str_len - suffix_len, suffix, suffix_len );
|
||||
return !evutil_ascii_strncasecmp( str + str_len - suffix_len, suffix, suffix_len );
|
||||
}
|
||||
|
||||
/****
|
||||
|
|
Loading…
Add table
Reference in a new issue