1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 01:03:01 +00:00

(trunk libT) fix long-standing wart of a few public API calls returning strdup'ed char*, rather than a const char* like all the others

This commit is contained in:
Charles Kerr 2009-04-16 19:14:37 +00:00
parent 3f00d88ed8
commit cdd779bb2a
4 changed files with 20 additions and 26 deletions

View file

@ -643,10 +643,10 @@ tr_rpcSetWhitelist( tr_rpc_server * server,
}
}
char*
const char*
tr_rpcGetWhitelist( const tr_rpc_server * server )
{
return tr_strdup( server->whitelistStr ? server->whitelistStr : "" );
return server->whitelistStr ? server->whitelistStr : "";
}
void
@ -675,10 +675,10 @@ tr_rpcSetUsername( tr_rpc_server * server,
dbgmsg( "setting our Username to [%s]", server->username );
}
char*
const char*
tr_rpcGetUsername( const tr_rpc_server * server )
{
return tr_strdup( server->username ? server->username : "" );
return server->username ? server->username : "";
}
void
@ -693,10 +693,10 @@ tr_rpcSetPassword( tr_rpc_server * server,
dbgmsg( "setting our Password to [%s]", server->password );
}
char*
const char*
tr_rpcGetPassword( const tr_rpc_server * server )
{
return tr_strdup( server->password ? server->password : "" );
return server->password ? server->password : "" ;
}
void

View file

@ -46,17 +46,17 @@ tr_bool tr_rpcGetWhitelistEnabled( const tr_rpc_server * server );
void tr_rpcSetWhitelist( tr_rpc_server * server,
const char * whitelist );
char* tr_rpcGetWhitelist( const tr_rpc_server * server );
const char* tr_rpcGetWhitelist( const tr_rpc_server * server );
void tr_rpcSetPassword( tr_rpc_server * server,
const char * password );
char* tr_rpcGetPassword( const tr_rpc_server * server );
const char* tr_rpcGetPassword( const tr_rpc_server * server );
void tr_rpcSetUsername( tr_rpc_server * server,
const char * username );
char* tr_rpcGetUsername( const tr_rpc_server * server );
const char* tr_rpcGetUsername( const tr_rpc_server * server );
void tr_rpcSetPasswordEnabled( tr_rpc_server * server,
tr_bool isEnabled );

View file

@ -308,9 +308,6 @@ const tr_socketList * tr_getSessionBindSockets( const tr_session * session );
void
tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
{
int i, n=0;
char * freeme[16];
assert( tr_bencIsDict( d ) );
tr_bencDictReserve( d, 30 );
@ -344,10 +341,10 @@ tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_AUTH_REQUIRED, tr_sessionIsRPCPasswordEnabled( s ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_BIND_ADDRESS, tr_sessionGetRPCBindAddress( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_ENABLED, tr_sessionIsRPCEnabled( s ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_PASSWORD, freeme[n++] = tr_sessionGetRPCPassword( s ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_PASSWORD, tr_sessionGetRPCPassword( s ) );
tr_bencDictAddInt ( d, TR_PREFS_KEY_RPC_PORT, tr_sessionGetRPCPort( s ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_USERNAME, freeme[n++] = tr_sessionGetRPCUsername( s ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_WHITELIST, freeme[n++] = tr_sessionGetRPCWhitelist( s ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_USERNAME, tr_sessionGetRPCUsername( s ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_WHITELIST, tr_sessionGetRPCWhitelist( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_WHITELIST_ENABLED, tr_sessionGetRPCWhitelistEnabled( s ) );
tr_bencDictAddBool( d, TR_PREFS_KEY_ALT_SPEED_ENABLED, tr_sessionUsesAltSpeed( s ) );
tr_bencDictAddInt ( d, TR_PREFS_KEY_ALT_SPEED_UP, tr_sessionGetAltSpeed( s, TR_UP ) );
@ -363,9 +360,6 @@ tr_sessionGetSettings( tr_session * s, struct tr_benc * d )
tr_ntop_non_ts( tr_socketListGetType( tr_getSessionBindSockets( s ), TR_AF_INET ) ) );
tr_bencDictAddStr ( d, TR_PREFS_KEY_BIND_ADDRESS_IPV6,
tr_ntop_non_ts( tr_socketListGetType( tr_getSessionBindSockets( s ), TR_AF_INET6 ) ) );
for( i=0; i<n; ++i )
tr_free( freeme[i] );
}
void
@ -1858,7 +1852,7 @@ tr_sessionSetRPCWhitelist( tr_session * session,
tr_rpcSetWhitelist( session->rpcServer, whitelist );
}
char*
const char*
tr_sessionGetRPCWhitelist( const tr_session * session )
{
assert( tr_isSession( session ) );
@ -1893,7 +1887,7 @@ tr_sessionSetRPCPassword( tr_session * session,
tr_rpcSetPassword( session->rpcServer, password );
}
char*
const char*
tr_sessionGetRPCPassword( const tr_session * session )
{
assert( tr_isSession( session ) );
@ -1910,7 +1904,7 @@ tr_sessionSetRPCUsername( tr_session * session,
tr_rpcSetUsername( session->rpcServer, username );
}
char*
const char*
tr_sessionGetRPCUsername( const tr_session * session )
{
assert( tr_isSession( session ) );

View file

@ -373,10 +373,10 @@ void tr_sessionSetRPCWhitelist( tr_session * session,
const char * whitelist );
/** @brief get the Access Control List for allowing/denying RPC requests.
@return a comma-separated string of whitelist domains. tr_free() when done.
@return a comma-separated string of whitelist domains.
@see tr_sessionInit
@see tr_sessionSetRPCWhitelist */
char* tr_sessionGetRPCWhitelist( const tr_session * );
const char* tr_sessionGetRPCWhitelist( const tr_session * );
void tr_sessionSetRPCWhitelistEnabled( tr_session * session,
tr_bool isEnabled );
@ -390,12 +390,12 @@ void tr_sessionSetRPCUsername( tr_session * session,
const char * username );
/** @brief get the password used to restrict RPC requests.
@return the password string. tr_free() when done.
@return the password string.
@see tr_sessionInit()
@see tr_sessionSetRPCPassword() */
char* tr_sessionGetRPCPassword( const tr_session * session );
const char* tr_sessionGetRPCPassword( const tr_session * session );
char* tr_sessionGetRPCUsername( const tr_session * session );
const char* tr_sessionGetRPCUsername( const tr_session * session );
void tr_sessionSetRPCPasswordEnabled( tr_session * session,
tr_bool isEnabled );