(trunk libT) re-start work on making libT doxygen friendly. still a long ways to go on this.

This commit is contained in:
Charles Kerr 2009-05-29 19:17:12 +00:00
parent 28b327b55a
commit 452cb27f9e
27 changed files with 1543 additions and 137 deletions

View File

@ -23,6 +23,11 @@
struct tr_peerIo;
/**
* @addtogroup networked_io Networked IO
* @{
*/
/* these are PRIVATE IMPLEMENTATION details that should not be touched.
* it's included in the header for inlining and composition. */
enum
@ -259,4 +264,5 @@ static TR_INLINE tr_bool tr_bandwidthAreParentLimitsHonored( tr_bandwidth * ban
void tr_bandwidthSetPeer( tr_bandwidth * bandwidth,
struct tr_peerIo * peerIo );
/* @} */
#endif

View File

@ -21,6 +21,18 @@ extern "C" {
struct evbuffer;
/**
* @addtogroup tr_benc Variant
*
* An object that acts like a union for
* integers, strings, lists, dictionaries, booleans, and floating-point numbers.
* The structure is named tr_benc due to the historical reason that it was
* originally tightly coupled with bencoded data. It currently supports
* being parsed from, and serialized to, both bencoded notation and json notation.
*
* @{
*/
/* these are PRIVATE IMPLEMENTATION details that should not be touched.
* it's included in the header for inlining and composition */
enum
@ -207,6 +219,8 @@ int tr_bencParseStr( const uint8_t * buf,
void tr_bencMergeDicts( tr_benc * target, const tr_benc * source );
/* @} */
#ifdef __cplusplus
}
#endif

View File

@ -45,6 +45,10 @@ main( void )
TEST_CLIENT( "-TR111Z-", "Transmission 1.11+" );
TEST_CLIENT( "O1008132", "Osprey 1.0.0" );
/* gobbledygook */
TEST_CLIENT( "-IIO\x10\x2D\x04-", "-IIO%10-%04-" );
TEST_CLIENT( "-I\05O\x08\x03\x01-", "-I%05O%08%03%01-" );
TEST_CLIENT(
"\x65\x78\x62\x63\x00\x38\x7A\x44\x63\x10\x2D\x6E\x9A\xD6\x72\x3B\x33\x9F\x35\xA9",
"BitComet 0.56" );

View File

@ -412,16 +412,17 @@ tr_clientForId( char * buf, size_t buflen, const void * id_in )
/* No match */
if( !*buf )
{
struct evbuffer * out = tr_getBuffer( );
char out[32], *walk=out;
const char *in, *in_end;
for( in=(const char*)id, in_end=in+8; in!=in_end; ++in ) {
if( isprint( *in ) )
evbuffer_add_printf( out, "%c", *in );
else
evbuffer_add_printf( out, "%%%02X", (unsigned int)*in );
*walk++ = *in;
else {
tr_snprintf( walk, out+sizeof(out)-walk, "%%%02X", (unsigned int)*in );
walk += 3;
}
}
tr_strlcpy( buf, EVBUFFER_DATA( out ), buflen );
tr_releaseBuffer( out );
*walk = '\0';
tr_strlcpy( buf, out, buflen );
}
}

View File

@ -10,6 +10,9 @@
* $Id$
*/
/**
* @ingroup utils
*/
void tr_clientForId( char * buf,
size_t buflen,
const void * peer_id );

View File

@ -26,6 +26,12 @@
**/
struct evbuffer;
/**
* @addtogroup utils Utilities
* @{
*/
typedef struct tr_crypto tr_crypto;
/**
@ -99,4 +105,6 @@ char* tr_ssha1( const void * plaintext );
tr_bool tr_ssha1_matches( const char * source, const char * pass );
/* @} */
#endif

View File

@ -29,6 +29,11 @@
#include "transmission.h"
#include "net.h"
/**
* @addtogroup file_io File IO
* @{
*/
void tr_fdInit( size_t openFileLimit,
size_t globalPeerLimit );
@ -111,3 +116,4 @@ void tr_fdSetPeerLimit( uint16_t n );
uint16_t tr_fdGetPeerLimit( void );
/* @} */

View File

@ -39,8 +39,8 @@
extern "C" {
#endif
int fggets( char* *ln,
FILE * f );
/** @ingroup utils */
int fggets( char* *ln, FILE * f );
#define ggets( ln ) fggets( ln, stdin )

View File

@ -20,7 +20,13 @@
#include "transmission.h"
#include "net.h"
/** @addtogroup peers Peers
@{ */
struct tr_peerIo;
/** @brief opaque struct holding hanshake state information.
freed when the handshake is completed. */
typedef struct tr_handshake tr_handshake;
/* returns true on success, false on error */
@ -30,6 +36,7 @@ typedef tr_bool ( *handshakeDoneCB )( struct tr_handshake * handshake,
const uint8_t * peerId,
void * userData );
/** @brief instantiate a new handshake */
tr_handshake * tr_handshakeNew( struct tr_peerIo * io,
tr_encryption_mode encryptionMode,
handshakeDoneCB doneCB,
@ -45,4 +52,5 @@ struct tr_peerIo* tr_handshakeGetIO( tr_handshake * handshake );
struct tr_peerIo* tr_handshakeStealIO( tr_handshake * handshake );
/** @} */
#endif

View File

@ -19,6 +19,11 @@
struct tr_torrent;
/**
* @addtogroup file_io File IO
* @{
*/
/**
* Reads the block specified by the piece index, offset, and length.
* @return 0 on success, or an errno value on failure.
@ -62,4 +67,5 @@ void tr_ioFindFileLocation( const tr_torrent * tor,
uint64_t * fileOffset );
/* @} */
#endif

View File

@ -16,6 +16,7 @@
extern "C" {
#endif
/** @ingroup tr_benc */
int tr_jsonParse( const void * vbuf,
size_t len,
struct tr_benc * setme_benc,

1252
libtransmission/libt.dox Normal file

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,11 @@
#ifndef TR_NATPMP_H
#define TR_NATPMP_H 1
/**
* @addtogroup port_forwarding Port Forwarding
* @{
*/
typedef struct tr_natpmp tr_natpmp;
tr_natpmp * tr_natpmpInit( void );
@ -27,4 +32,5 @@ int tr_natpmpPulse( tr_natpmp *,
int port,
int isEnabled );
/* @} */
#endif

View File

@ -17,6 +17,11 @@
#ifndef TR_PEER_H
#define TR_PEER_H
/**
* @addtogroup peers Peers
* @{
*/
/**
*** Fields common to webseed and bittorrent peers
**/
@ -69,4 +74,6 @@ tr_peer_event;
#define EMSGSIZE WSAEMSGSIZE
#endif
/** @} */
#endif

View File

@ -35,6 +35,11 @@ struct tr_bandwidth;
struct tr_crypto;
struct tr_peerIo;
/**
* @addtogroup networked_io Networked IO
* @{
*/
typedef enum
{
READ_NOW,
@ -401,5 +406,6 @@ static TR_INLINE struct evbuffer * tr_peerIoGetReadBuffer( tr_peerIo * io )
return io->inbuf;
}
/* @} */
#endif

View File

@ -26,6 +26,11 @@
#include "net.h"
#include "publish.h" /* tr_publisher_tag */
/**
* @addtogroup peers Peers
* @{
*/
struct tr_peer_stat;
struct tr_torrent;
typedef struct tr_peerMgr tr_peerMgr;
@ -182,4 +187,6 @@ double tr_peerGetPieceSpeed( const tr_peer * peer,
uint64_t now,
tr_direction direction );
/* @} */
#endif

View File

@ -25,6 +25,11 @@ struct tr_torrent;
struct tr_peer;
struct tr_bitfield;
/**
* @addtogroup peers Peers
* @{
*/
typedef struct tr_peermsgs tr_peermsgs;
tr_peermsgs* tr_peerMsgsNew( struct tr_torrent * torrent,
@ -65,4 +70,5 @@ size_t tr_generateAllowedSet( tr_piece_index_t * setmePieces,
const tr_address * addr );
/* @} */
#endif

View File

@ -30,6 +30,11 @@
#define MAX_STACK_ARRAY_SIZE 7168
/**
* @addtogroup utils Utilities
* @{
*/
typedef struct tr_lock tr_lock;
typedef struct tr_thread tr_thread;
@ -73,4 +78,6 @@ long munmap( void *ptr,
#endif
/* @} */
#endif

View File

@ -32,6 +32,11 @@
#include "transmission.h"
#include "net.h"
/**
* @addtogroup port_forwarding Port Forwarding
* @{
*/
struct tr_bindsockets;
typedef struct tr_shared tr_shared;
@ -50,4 +55,5 @@ tr_bool tr_sharedTraversalIsEnabled( const tr_shared * s );
int tr_sharedTraversalStatus( const tr_shared * );
/** @} */
#endif

View File

@ -31,6 +31,11 @@
#include "transmission.h"
/**
* @addtogroup utils Utilities
* @{
*/
/**
* A simple pointer array that resizes itself dynamically.
*/
@ -110,4 +115,5 @@ void* tr_ptrArrayFindSorted( tr_ptrArray * array,
const void * key,
int compare(const void*, const void*) );
/* @} */
#endif

View File

@ -438,7 +438,7 @@ handle_clutch( struct evhttp_request * req,
send_simple_response( req, HTTP_NOTFOUND,
"<p>Couldn't find Transmission's web interface files!</p>"
"<p>Users: to tell Transmission where to look, "
"set the TRANSMISSION_WEB_HOME environmental "
"set the TRANSMISSION_WEB_HOME environment "
"variable to the folder where the web interface's "
"index.html is located.</p>"
"<p>Package Builders: to set a custom default at compile time, "

View File

@ -186,9 +186,30 @@ enum
SESSION_MAGIC_NUMBER = 3845
};
static inline tr_bool tr_isSession( const tr_session * session )
static TR_INLINE tr_bool tr_isSession( const tr_session * session )
{
return ( session != NULL ) && ( session->magicNumber == SESSION_MAGIC_NUMBER );
}
static TR_INLINE tr_bool tr_isPreallocationMode( tr_preallocation_mode m )
{
return ( m == TR_PREALLOCATE_NONE )
|| ( m == TR_PREALLOCATE_SPARSE )
|| ( m == TR_PREALLOCATE_FULL );
}
static TR_INLINE tr_bool tr_isEncryptionMode( tr_encryption_mode m )
{
return ( m == TR_CLEAR_PREFERRED )
|| ( m == TR_ENCRYPTION_PREFERRED )
|| ( m == TR_ENCRYPTION_REQUIRED );
}
static TR_INLINE tr_bool tr_isPriority( tr_priority_t p )
{
return ( p == TR_PRI_LOW )
|| ( p == TR_PRI_NORMAL )
|| ( p == TR_PRI_HIGH );
}
#endif

View File

@ -29,6 +29,11 @@
extern "C" {
#endif
/**
* @addtogroup utils Utilities
* @{
*/
extern int tr_optind;
typedef struct tr_option
@ -73,4 +78,6 @@ void tr_getopt_usage( const char * appName,
} /* extern "C" */
#endif
/** @} */
#endif /* TR_GETOPT_H */

View File

@ -25,9 +25,8 @@
/*
* This file defines the public API for the libtransmission library.
*
* Other headers suitable for public consumption are bencode.h
* and utils.h. Most of the remaining headers in libtransmission
* should be considered private to libtransmission.
* Other headers with a public API are bencode.h and utils.h.
* Most of the remaining headers in libtransmission are private.
*/
#ifndef TR_TRANSMISSION_H
#define TR_TRANSMISSION_H 1
@ -36,7 +35,15 @@
extern "C" {
#endif
/***
****
**** Basic Types
****
***/
#include <inttypes.h> /* uintN_t */
#include <time.h> /* time_t */
#ifndef PRId64
#define PRId64 "lld"
#endif
@ -46,9 +53,8 @@ extern "C" {
#ifndef PRIu32
#define PRIu32 "lu"
#endif
#include <time.h> /* time_t */
#if defined( WIN32 ) && defined(_MSC_VER)
#if defined(WIN32) && defined(_MSC_VER)
#define TR_INLINE __inline
#else
#define TR_INLINE inline
@ -57,68 +63,22 @@ extern "C" {
#define SHA_DIGEST_LENGTH 20
#define TR_INET6_ADDRSTRLEN 46
#define TR_RPC_SESSION_ID_HEADER "X-Transmission-Session-Id"
typedef uint32_t tr_file_index_t;
typedef uint32_t tr_piece_index_t;
typedef uint64_t tr_block_index_t;
typedef uint16_t tr_port;
typedef uint8_t tr_bool;
enum
{
TR_PRI_LOW = -1,
TR_PRI_NORMAL = 0, /* since NORMAL is 0, memset initializes nicely */
TR_PRI_HIGH = 1
};
typedef int8_t tr_priority_t;
static TR_INLINE tr_bool tr_isPriority( tr_priority_t p )
{
return ( p == TR_PRI_LOW )
|| ( p == TR_PRI_NORMAL )
|| ( p == TR_PRI_HIGH );
}
/**
* @brief returns Transmission's default configuration file directory.
*
* The default configuration directory is determined this way:
* 1. If the TRANSMISSION_HOME environmental variable is set, its value is used.
* 2. On Darwin, "${HOME}/Library/Application Support/${appname}" is used.
* 3. On Windows, "${CSIDL_APPDATA}/${appname}" is used.
* 4. If XDG_CONFIG_HOME is set, "${XDG_CONFIG_HOME}/${appname}" is used.
* 5. ${HOME}/.config/${appname}" is used as a last resort.
*/
const char* tr_getDefaultConfigDir( const char * appname );
/**
* @brief returns Transmisson's default download directory.
*
* The default download directory is determined this way:
* 1. If the HOME environmental variable is set, "${HOME}/Downloads" is used.
* 2. On Windows, "${CSIDL_MYDOCUMENTS}/Downloads" is used.
* 3. Otherwise, getpwuid(getuid())->pw_dir + "/Downloads" is used.
*/
const char* tr_getDefaultDownloadDir( void );
typedef struct tr_ctor tr_ctor;
typedef struct tr_info tr_info;
typedef struct tr_torrent tr_torrent;
typedef struct tr_session tr_session;
struct tr_benc;
/**
* @addtogroup tr_session Session
*
* A libtransmission session is created by calling tr_sessionInit().
* libtransmission creates a thread for itself so that it can operate
* independently of the caller's event loop. The session will continue
* until tr_sessionClose() is called.
*
* @{
*/
typedef int8_t tr_priority_t;
#define TR_RPC_SESSION_ID_HEADER "X-Transmission-Session-Id"
typedef enum
{
@ -128,13 +88,6 @@ typedef enum
}
tr_preallocation_mode;
static TR_INLINE tr_bool tr_isPreallocationMode( tr_preallocation_mode m )
{
return ( m == TR_PREALLOCATE_NONE )
|| ( m == TR_PREALLOCATE_SPARSE )
|| ( m == TR_PREALLOCATE_FULL );
}
typedef enum
{
TR_PROXY_HTTP,
@ -151,23 +104,56 @@ typedef enum
}
tr_encryption_mode;
static TR_INLINE tr_bool tr_isEncryptionMode( tr_encryption_mode m )
{
return ( m == TR_CLEAR_PREFERRED )
|| ( m == TR_ENCRYPTION_PREFERRED )
|| ( m == TR_ENCRYPTION_REQUIRED );
}
/***
****
**** Startup & Shutdown
****
***/
/**
* @addtogroup tr_session Session
*
* A libtransmission session is created by calling tr_sessionInit().
* libtransmission creates a thread for itself so that it can operate
* independently of the caller's event loop. The session will continue
* until tr_sessionClose() is called.
*
* @{
*/
/**
* @brief returns Transmission's default configuration file directory.
*
* The default configuration directory is determined this way:
* -# If the TRANSMISSION_HOME environment variable is set, its value is used.
* -# On Darwin, "${HOME}/Library/Application Support/${appname}" is used.
* -# On Windows, "${CSIDL_APPDATA}/${appname}" is used.
* -# If XDG_CONFIG_HOME is set, "${XDG_CONFIG_HOME}/${appname}" is used.
* -# ${HOME}/.config/${appname}" is used as a last resort.
*/
const char* tr_getDefaultConfigDir( const char * appname );
/**
* @brief returns Transmisson's default download directory.
*
* The default download directory is determined this way:
* -# If the HOME environment variable is set, "${HOME}/Downloads" is used.
* -# On Windows, "${CSIDL_MYDOCUMENTS}/Downloads" is used.
* -# Otherwise, getpwuid(getuid())->pw_dir + "/Downloads" is used.
*/
const char* tr_getDefaultDownloadDir( void );
#define TR_DEFAULT_BIND_ADDRESS_IPV4 "0.0.0.0"
#define TR_DEFAULT_BIND_ADDRESS_IPV6 "::"
#define TR_DEFAULT_OPEN_FILE_LIMIT_STR "32"
#define TR_DEFAULT_RPC_WHITELIST "127.0.0.1"
#define TR_DEFAULT_RPC_PORT_STR "9091"
#define TR_DEFAULT_PEER_PORT_STR "51413"
#define TR_DEFAULT_PEER_SOCKET_TOS_STR "0"
#define TR_DEFAULT_PEER_LIMIT_GLOBAL_STR "240"
#define TR_DEFAULT_PEER_LIMIT_TORRENT_STR "60"
#define TR_DEFAULT_BIND_ADDRESS_IPV4 "0.0.0.0"
#define TR_DEFAULT_BIND_ADDRESS_IPV6 "::"
#define TR_DEFAULT_OPEN_FILE_LIMIT_STR "32"
#define TR_DEFAULT_RPC_WHITELIST "127.0.0.1"
#define TR_DEFAULT_RPC_PORT_STR "9091"
#define TR_DEFAULT_PEER_PORT_STR "51413"
#define TR_DEFAULT_PEER_SOCKET_TOS_STR "0"
#define TR_DEFAULT_PEER_LIMIT_GLOBAL_STR "240"
#define TR_DEFAULT_PEER_LIMIT_TORRENT_STR "60"
#define TR_PREFS_KEY_ALT_SPEED_ENABLED "alt-speed-enabled"
#define TR_PREFS_KEY_ALT_SPEED_UP "alt-speed-up"
@ -218,7 +204,6 @@ static TR_INLINE tr_bool tr_isEncryptionMode( tr_encryption_mode m )
#define TR_PREFS_KEY_USPEED "speed-limit-up"
#define TR_PREFS_KEY_UPLOAD_SLOTS_PER_TORRENT "upload-slots-per-torrent"
struct tr_benc;
/**
* Add libtransmission's default settings to the benc dictionary.
@ -243,7 +228,7 @@ struct tr_benc;
void tr_sessionGetDefaultSettings( struct tr_benc * dictionary );
/**
* Add the session's configuration settings to the benc dictionary.
* Add the session's current configuration settings to the benc dictionary.
*
* FIXME: this probably belongs in libtransmissionapp
*
@ -261,7 +246,7 @@ void tr_sessionGetSettings( tr_session *, struct tr_benc * dictionary );
*
* @param dictionary pointer to an uninitialized tr_benc
* @param configDir the configuration directory to find settings.json
* @param appName if configDir is empty, appName is used to get the default config dir.
* @param appName if configDir is empty, appName is used to find the default dir.
* @see tr_sessionGetDefaultSettings()
* @see tr_sessionInit()
* @see tr_sessionSaveSettings()
@ -285,7 +270,7 @@ void tr_sessionSaveSettings( tr_session * session,
const struct tr_benc * dictonary );
/**
* Initialize a libtransmission session.
* @brief Initialize a libtransmission session.
*
* For example, this will instantiate a session with all the default values:
* @code
@ -299,7 +284,7 @@ void tr_sessionSaveSettings( tr_session * session,
* session = tr_sessionInit( "mac", configDir, true, &settings );
*
* tr_bencFree( &settings );
* @encode
* @endcode
*
* @param tag "gtk", "macosx", "daemon", etc... this is only for pre-1.30 resume files
* @param configDir where Transmission will look for resume files, blocklists, etc.
@ -319,10 +304,11 @@ tr_session * tr_sessionInit( const char * tag,
void tr_sessionClose( tr_session * );
/**
* @brief Return the session's configuration directory
* @brief Return the session's configuration directory.
*
* This is where transmission stores its .torrent files, .resume files,
* blocklists, etc.
* blocklists, etc. It's set in tr_transmissionInit() and is immutable
* during the session.
*/
const char * tr_sessionGetConfigDir( const tr_session * );
@ -332,8 +318,7 @@ const char * tr_sessionGetConfigDir( const tr_session * );
* @see tr_sessionGetDownloadDir()
* @see tr_ctorSetDownloadDir()
*/
void tr_sessionSetDownloadDir( tr_session * session,
const char * downloadDir );
void tr_sessionSetDownloadDir( tr_session * session, const char * downloadDir );
/**
* @brief Get the default download folder for new torrents.
@ -771,7 +756,7 @@ void tr_blocklistSetEnabled ( tr_session * session,
/** @} */
/** @addtogroup tr_ctor Torrent Instantiation
/** @addtogroup tr_ctor Torrent Constructors
@{
Instantiating a tr_torrent had gotten more complicated as features were
@ -1030,6 +1015,12 @@ uint16_t tr_torrentGetPeerLimit( const tr_torrent * tor );
***** File Priorities
****/
enum
{
TR_PRI_LOW = -1,
TR_PRI_NORMAL = 0, /* since NORMAL is 0, memset initializes nicely */
TR_PRI_HIGH = 1
};
/**
* @brief Set a batch of files to a particular priority.
@ -1084,6 +1075,7 @@ const char * tr_torrentGetDownloadDir( const tr_torrent * torrent );
***
**/
/** @brief a part of tr_info that represents a single tracker */
typedef struct tr_tracker_info
{
int tier;
@ -1265,6 +1257,7 @@ void tr_torrentVerify( tr_torrent * torrent );
* tr_info
**********************************************************************/
/** @brief a part of tr_info that represents a single file of the torrent's content */
typedef struct tr_file
{
uint64_t length; /* Length of the file, in bytes */
@ -1278,6 +1271,7 @@ typedef struct tr_file
}
tr_file;
/** @brief a part of tr_info that represents a single piece of the torrent's content */
typedef struct tr_piece
{
uint8_t hash[SHA_DIGEST_LENGTH]; /* pieces hash */
@ -1287,6 +1281,7 @@ typedef struct tr_piece
}
tr_piece;
/** @brief information about a torrent that comes from its metainfo file */
struct tr_info
{
/* Flags */
@ -1581,17 +1576,18 @@ const tr_stat * tr_torrentStat( tr_torrent * torrent );
reduce the CPU load if you're calling tr_torrentStat() frequently. */
const tr_stat * tr_torrentStatCached( tr_torrent * torrent );
/** @deprecated this method will be removed in 1.40 */
/** @deprecated */
void tr_torrentSetAddedDate( tr_torrent * torrent,
time_t addedDate );
/** @deprecated this method will be removed in 1.40 */
/** @deprecated */
void tr_torrentSetActivityDate( tr_torrent * torrent,
time_t activityDate );
/** @deprecated this method will be removed in 1.40 */
void tr_torrentSetDoneDate( tr_torrent * torrent,
time_t doneDate );
/** @deprecated */
void tr_torrentSetDoneDate( tr_torrent * torrent, time_t doneDate );
/** @} */
/** @brief Sanity checker to test that the direction is TR_UP or TR_DOWN */
static TR_INLINE tr_bool tr_isDirection( tr_direction d ) { return d==TR_UP || d==TR_DOWN; }
@ -1599,8 +1595,6 @@ static TR_INLINE tr_bool tr_isDirection( tr_direction d ) { return d==TR_UP || d
/** @brief Sanity checker to test that a bool is TRUE or FALSE */
static TR_INLINE tr_bool tr_isBool( tr_bool b ) { return b==1 || b==0; }
/** @} */
#ifdef __cplusplus
}
#endif

View File

@ -17,6 +17,11 @@
#ifndef TR_UPNP_H
#define TR_UPNP_H 1
/**
* @addtogroup port_forwarding Port Forwarding
* @{
*/
typedef struct tr_upnp tr_upnp;
tr_upnp * tr_upnpInit( void );
@ -27,4 +32,5 @@ int tr_upnpPulse( tr_upnp *,
int port,
int isEnabled,
int doPortCheck );
/* @} */
#endif

View File

@ -31,6 +31,11 @@ extern "C" {
****
***/
/**
* @addtogroup utils Utilities
* @{
*/
#ifndef FALSE
#define FALSE 0
#endif
@ -192,13 +197,15 @@ char* tr_getLogTimeStr( char * buf,
int tr_wildmat( const char * text,
const char * pattern );
/** a portability wrapper for basename(). */
char* tr_basename( const char * path ) TR_GNUC_MALLOC;
/** @brief Portability wrapper for basename() that uses the system implementation if available */
char* tr_basename( const char * path ) TR_GNUC_MALLOC;
/** a portability wrapper for dirname(). */
char* tr_dirname( const char * path ) TR_GNUC_MALLOC;
/** @brief Portability wrapper for dirname() that uses the system implementation if available */
char* tr_dirname( const char * path ) TR_GNUC_MALLOC;
/**
* @brief Portability wrapper for mkdir()
*
* a portability wrapper around mkdir().
* On WIN32, the `permissions' argument is unused.
*
@ -214,39 +221,39 @@ int tr_mkdir( const char * path,
* @return zero on success, or -1 if an error occurred
* (in which case errno is set appropriately).
*/
int tr_mkdirp( const char * path,
int permissions );
int tr_mkdirp( const char * path, int permissions );
/**
* Loads a file and returns its contents.
* @brief Loads a file and returns its contents.
* On failure, NULL is returned and errno is set.
*/
uint8_t* tr_loadFile( const char * filename,
size_t * size ) TR_GNUC_MALLOC;
uint8_t* tr_loadFile( const char * filename, size_t * size ) TR_GNUC_MALLOC;
/* creates a filename from a series of elements using the
correct separator for filenames. */
char* tr_buildPath( const char * first_element, ... )
TR_GNUC_NULL_TERMINATED
TR_GNUC_MALLOC;
/** @brief build a filename from a series of elements using the
platform's correct directory separator. */
char* tr_buildPath( const char * first_element, ... ) TR_GNUC_NULL_TERMINATED
TR_GNUC_MALLOC;
struct timeval;
void tr_timevalMsec( uint64_t milliseconds,
struct timeval * setme );
void tr_timevalMsec( uint64_t milliseconds, struct timeval * setme );
/* return the current date in milliseconds */
/** @brief return the current date in milliseconds */
uint64_t tr_date( void );
/* wait the specified number of milliseconds */
/** @brief wait the specified number of milliseconds */
void tr_wait( uint64_t delay_milliseconds );
char* tr_utf8clean( const char * str,
int max_len,
tr_bool * err );
/**
* @brief make a copy of 'str' whose non-utf8 content has been corrected or stripped
* @param str the string to make a clean copy of
* @param len the length of the string to copy. If -1, the entire string is used.
* @param err if an error occurs and err is non-NULL, it's set to TRUE.
*/
char* tr_utf8clean( const char * str, int len, tr_bool * err ) TR_GNUC_MALLOC;
/***
@ -268,8 +275,8 @@ void tr_releaseBuffer( struct evbuffer * buf );
****
***/
/* Sometimes the system defines MAX/MIN, sometimes not. In the latter
case, define those here since we will use them */
/* Sometimes the system defines MAX/MIN, sometimes not.
In the latter case, define those here since we will use them */
#ifndef MAX
#define MAX( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) )
#endif
@ -337,19 +344,20 @@ char* tr_base64_decode( const void * input,
int inlen,
int * outlen ) TR_GNUC_MALLOC;
size_t tr_strlcpy( char * dst,
const void * src,
size_t siz );
/** @brief Portability wrapper for strlcpy() that uses the system implementation if available */
size_t tr_strlcpy( char * dst, const void * src, size_t siz );
int tr_snprintf( char * buf,
size_t buflen,
const char * fmt,
... ) TR_GNUC_PRINTF( 3, 4 );
/** @brief Portability wrapper for snprintf() that uses the system implementation if available */
int tr_snprintf( char * buf, size_t buflen,
const char * fmt, ... ) TR_GNUC_PRINTF( 3, 4 );
const char* tr_strerror( int );
char* tr_strstrip( char * str );
/** @brief strips leading and trailing whitspace from a string
@return the stripped string */
char* tr_strstrip( char * str );
/** @brief Portability wrapper for memmem() that uses the system implementation if available */
const char* tr_memmem( const char * haystack, size_t haystack_len,
const char * needle, size_t needle_len );
@ -454,7 +462,7 @@ static TR_INLINE tr_bool tr_bitfieldHas( const tr_bitfield * b, size_t nth )
double tr_getRatio( double numerator, double denominator );
int* tr_parseNumberRange( const char * str, int str_len, int * setmeCount );
int* tr_parseNumberRange( const char * str, int str_len, int * setmeCount ) TR_GNUC_MALLOC;
int tr_ptr2int( void* );
@ -469,6 +477,7 @@ void* tr_int2ptr( int );
*/
char* tr_strratio( char * buf, size_t buflen, double ratio, const char * infinity );
/** @brief Portability wrapper for localtime_r() that uses the system implementation if available */
struct tm * tr_localtime_r( const time_t *_clock, struct tm *_result );
@ -480,4 +489,6 @@ int tr_moveFile( const char * oldpath, const char * newpath );
}
#endif
/** @} */
#endif

View File

@ -17,6 +17,11 @@
#ifndef TR_VERIFY_H
#define TR_VERIFY_H 1
/**
* @addtogroup file_io File IO
* @{
*/
typedef void ( *tr_verify_done_cb )( tr_torrent * tor );
void tr_verifyAdd( tr_torrent * tor,
@ -28,4 +33,6 @@ tr_bool tr_verifyInProgress( const tr_torrent * tor );
void tr_verifyClose( tr_session * );
/* @} */
#endif