2006-07-16 19:39:23 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
2007-02-23 11:26:48 +00:00
|
|
|
* Copyright (c) 2005-2007 Transmission authors and contributors
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef TR_TRANSMISSION_H
|
|
|
|
#define TR_TRANSMISSION_H 1
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "version.h"
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
2007-05-09 07:00:08 +00:00
|
|
|
#ifndef PRId64
|
|
|
|
# define PRId64 "lld"
|
|
|
|
#endif
|
2006-07-16 19:39:23 +00:00
|
|
|
#ifndef PRIu64
|
2007-05-09 07:00:08 +00:00
|
|
|
# define PRIu64 "llu"
|
2006-07-16 19:39:23 +00:00
|
|
|
#endif
|
2006-08-22 02:32:46 +00:00
|
|
|
#include <time.h>
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
#define SHA_DIGEST_LENGTH 20
|
|
|
|
#ifdef __BEOS__
|
|
|
|
# include <StorageDefs.h>
|
|
|
|
# define MAX_PATH_LENGTH B_FILE_NAME_LENGTH
|
|
|
|
#else
|
|
|
|
# define MAX_PATH_LENGTH 1024
|
|
|
|
#endif
|
|
|
|
|
2006-08-14 22:42:32 +00:00
|
|
|
#ifndef INET_ADDRSTRLEN
|
|
|
|
#define INET_ADDRSTRLEN 16
|
|
|
|
#endif
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#define TR_DEFAULT_PORT 9090
|
2007-01-14 12:00:21 +00:00
|
|
|
|
2007-03-23 08:28:01 +00:00
|
|
|
#define TR_PEER_FROM__MAX 4
|
|
|
|
#define TR_PEER_FROM_INCOMING 0 /* connections made to the listening port */
|
|
|
|
#define TR_PEER_FROM_TRACKER 1 /* peers received from a tracker */
|
|
|
|
#define TR_PEER_FROM_CACHE 2 /* peers read from the peer cache */
|
|
|
|
#define TR_PEER_FROM_PEX 3 /* peers discovered via PEX */
|
|
|
|
|
2007-01-14 12:00:21 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* Error codes
|
|
|
|
**********************************************************************/
|
|
|
|
/* General errors */
|
2007-05-11 18:56:59 +00:00
|
|
|
#define TR_OK 0x00000000
|
|
|
|
#define TR_ERROR 0x81000000
|
|
|
|
#define TR_ERROR_ASSERT 0x82000000
|
2007-01-14 12:00:21 +00:00
|
|
|
/* I/O errors */
|
2007-05-11 18:56:59 +00:00
|
|
|
#define TR_ERROR_IO_MASK 0x000000FF
|
|
|
|
#define TR_ERROR_IO_PARENT 0x80000001
|
|
|
|
#define TR_ERROR_IO_PERMISSIONS 0x80000002
|
|
|
|
#define TR_ERROR_IO_SPACE 0x80000004
|
|
|
|
#define TR_ERROR_IO_RESOURCES 0x80000008
|
|
|
|
#define TR_ERROR_IO_DUP_DOWNLOAD 0x8000000A
|
|
|
|
#define TR_ERROR_IO_OTHER 0x80000010
|
2007-01-14 12:00:21 +00:00
|
|
|
/* Misc */
|
2007-05-11 18:56:59 +00:00
|
|
|
#define TR_ERROR_TC_MASK 0x00000F00
|
|
|
|
#define TR_ERROR_TC_ERROR 0x80000100
|
|
|
|
#define TR_ERROR_TC_WARNING 0x80000200
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-05-09 18:41:22 +00:00
|
|
|
#define TR_ERROR_ISSET( num, code ) ( (code) == ( (code) & (num) ) )
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_init
|
|
|
|
***********************************************************************
|
|
|
|
* Initializes a libtransmission instance. Returns a obscure handle to
|
2007-03-13 06:56:50 +00:00
|
|
|
* be passed to all functions below. The tag argument is a short string
|
|
|
|
* unique to the program invoking tr_init(), it is currently used as
|
|
|
|
* part of saved torrent files' names to prevent one frontend from
|
|
|
|
* deleting a torrent used by another. The following tags are used:
|
|
|
|
* beos cli daemon gtk macosx
|
2006-07-16 19:39:23 +00:00
|
|
|
**********************************************************************/
|
|
|
|
typedef struct tr_handle_s tr_handle_t;
|
2007-03-13 06:56:50 +00:00
|
|
|
tr_handle_t * tr_init( const char * tag );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2006-12-17 16:36:27 +00:00
|
|
|
typedef struct tr_tracker_info_s tr_tracker_info_t;
|
|
|
|
|
2006-08-20 18:15:25 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_setMessageLevel
|
|
|
|
***********************************************************************
|
2006-08-22 02:12:58 +00:00
|
|
|
* Set the level of messages to be output or queued
|
2006-08-20 18:15:25 +00:00
|
|
|
**********************************************************************/
|
|
|
|
#define TR_MSG_ERR 1
|
|
|
|
#define TR_MSG_INF 2
|
2006-08-20 22:45:04 +00:00
|
|
|
#define TR_MSG_DBG 3
|
2006-08-20 18:15:25 +00:00
|
|
|
void tr_setMessageLevel( int );
|
|
|
|
int tr_getMessageLevel( void );
|
2006-07-16 23:40:22 +00:00
|
|
|
|
2006-08-22 02:12:58 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_setMessageQueuing
|
|
|
|
***********************************************************************
|
|
|
|
* Enable or disable message queuing
|
|
|
|
**********************************************************************/
|
|
|
|
typedef struct tr_msg_list_s tr_msg_list_t;
|
|
|
|
void tr_setMessageQueuing( int );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_getQueuedMessages
|
|
|
|
***********************************************************************
|
|
|
|
* Return a list of queued messages
|
|
|
|
**********************************************************************/
|
|
|
|
tr_msg_list_t * tr_getQueuedMessages( void );
|
|
|
|
void tr_freeMessageList( tr_msg_list_t * list );
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_getPrefsDirectory
|
|
|
|
***********************************************************************
|
|
|
|
* Returns the full path to a directory which can be used to store
|
|
|
|
* preferences. The string belongs to libtransmission, do not free it.
|
|
|
|
**********************************************************************/
|
|
|
|
char * tr_getPrefsDirectory();
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_setBindPort
|
|
|
|
***********************************************************************
|
2006-09-25 18:37:45 +00:00
|
|
|
* Sets the port to listen for incoming peer connections.
|
|
|
|
* This can be safely called even with active torrents.
|
2006-07-16 19:39:23 +00:00
|
|
|
**********************************************************************/
|
|
|
|
void tr_setBindPort( tr_handle_t *, int );
|
|
|
|
|
2006-09-25 18:37:45 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_natTraversalEnable
|
|
|
|
* tr_natTraversalDisable
|
|
|
|
***********************************************************************
|
|
|
|
* Enable or disable NAT traversal using NAT-PMP or UPnP IGD.
|
|
|
|
**********************************************************************/
|
2007-01-19 04:42:31 +00:00
|
|
|
void tr_natTraversalEnable( tr_handle_t *, int enable );
|
2006-09-25 18:37:45 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2007-02-06 04:26:40 +00:00
|
|
|
* tr_handleStatus
|
2006-09-25 18:37:45 +00:00
|
|
|
***********************************************************************
|
2007-02-06 04:26:40 +00:00
|
|
|
* Returns some status info for the given handle.
|
2006-09-25 18:37:45 +00:00
|
|
|
**********************************************************************/
|
2007-02-06 04:26:40 +00:00
|
|
|
typedef struct tr_handle_status_s tr_handle_status_t;
|
|
|
|
tr_handle_status_t * tr_handleStatus( tr_handle_t * );
|
2006-09-25 18:37:45 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
2006-12-27 00:22:38 +00:00
|
|
|
* tr_setGlobalUploadLimit
|
2006-07-16 19:39:23 +00:00
|
|
|
***********************************************************************
|
|
|
|
* Sets the total upload rate limit in KB/s
|
|
|
|
**********************************************************************/
|
2006-12-27 00:22:38 +00:00
|
|
|
void tr_setGlobalUploadLimit( tr_handle_t *, int );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
2006-12-27 00:22:38 +00:00
|
|
|
* tr_setGlobalDownloadLimit
|
2006-07-16 19:39:23 +00:00
|
|
|
***********************************************************************
|
|
|
|
* Sets the total download rate limit in KB/s
|
|
|
|
**********************************************************************/
|
2006-12-27 00:22:38 +00:00
|
|
|
void tr_setGlobalDownloadLimit( tr_handle_t *, int );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentCount
|
|
|
|
***********************************************************************
|
|
|
|
* Returns the count of open torrents
|
|
|
|
**********************************************************************/
|
|
|
|
int tr_torrentCount( tr_handle_t * h );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentIterate
|
|
|
|
***********************************************************************
|
|
|
|
* Iterates on open torrents
|
|
|
|
**********************************************************************/
|
|
|
|
typedef struct tr_torrent_s tr_torrent_t;
|
|
|
|
typedef void (*tr_callback_t) ( tr_torrent_t *, void * );
|
|
|
|
void tr_torrentIterate( tr_handle_t *, tr_callback_t, void * );
|
|
|
|
|
2007-01-08 21:53:55 +00:00
|
|
|
void tr_setUseCustomLimit( tr_torrent_t * tor, int limit );
|
|
|
|
void tr_setUploadLimit( tr_torrent_t * tor, int limit );
|
|
|
|
void tr_setDownloadLimit( tr_torrent_t * tor, int limit );
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentRates
|
|
|
|
***********************************************************************
|
|
|
|
* Gets the total download and upload rates
|
|
|
|
**********************************************************************/
|
|
|
|
void tr_torrentRates( tr_handle_t *, float *, float * );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_close
|
|
|
|
***********************************************************************
|
|
|
|
* Frees memory allocated by tr_init.
|
|
|
|
**********************************************************************/
|
|
|
|
void tr_close( tr_handle_t * );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentInit
|
|
|
|
***********************************************************************
|
2007-03-22 18:07:22 +00:00
|
|
|
* Opens and parses torrent file at 'path'. If the file exists and is
|
|
|
|
* a valid torrent file, returns an handle and adds it to the list of
|
2006-07-16 19:39:23 +00:00
|
|
|
* torrents (but doesn't start it). Returns NULL and sets *error
|
2007-03-22 18:07:22 +00:00
|
|
|
* otherwise. If hash is not NULL and the torrent is already loaded
|
|
|
|
* then it's 20-byte hash will be copied in. If the TR_FLAG_SAVE flag
|
|
|
|
* is passed then a copy of the torrent file will be saved.
|
2006-07-16 19:39:23 +00:00
|
|
|
**********************************************************************/
|
|
|
|
#define TR_EINVALID 1
|
|
|
|
#define TR_EUNSUPPORTED 2
|
|
|
|
#define TR_EDUPLICATE 3
|
|
|
|
#define TR_EOTHER 666
|
|
|
|
tr_torrent_t * tr_torrentInit( tr_handle_t *, const char * path,
|
2007-03-22 18:07:22 +00:00
|
|
|
uint8_t * hash, int flags, int * error );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-04-02 20:38:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentInitData
|
|
|
|
***********************************************************************
|
|
|
|
* Like tr_torrentInit, except the actual torrent data is passed in
|
|
|
|
* instead of the filename.
|
|
|
|
**********************************************************************/
|
|
|
|
tr_torrent_t * tr_torrentInitData( tr_handle_t *, uint8_t * data,
|
|
|
|
size_t size, uint8_t * hash,
|
|
|
|
int flags, int * error );
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentInitSaved
|
|
|
|
***********************************************************************
|
|
|
|
* Opens and parses a torrent file as with tr_torrentInit, only taking
|
2007-03-22 18:07:22 +00:00
|
|
|
* the hash string of a saved torrent file instead of a filename. There
|
2006-07-16 19:39:23 +00:00
|
|
|
* are currently no valid flags for this function.
|
|
|
|
**********************************************************************/
|
|
|
|
tr_torrent_t * tr_torrentInitSaved( tr_handle_t *, const char * hashStr,
|
|
|
|
int flags, int * error );
|
|
|
|
|
2007-03-31 19:19:09 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentDisablePex
|
|
|
|
***********************************************************************
|
|
|
|
* Disable or enable peer exchange for this torrent. Peer exchange is
|
|
|
|
* enabled by default, except for private torrents where pex is
|
|
|
|
* disabled and cannot be enabled.
|
|
|
|
**********************************************************************/
|
|
|
|
void tr_torrentDisablePex( tr_torrent_t *, int disable );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentScrape
|
|
|
|
***********************************************************************
|
|
|
|
* Return torrent metainfo.
|
|
|
|
**********************************************************************/
|
2006-07-16 19:39:23 +00:00
|
|
|
typedef struct tr_info_s tr_info_t;
|
|
|
|
tr_info_t * tr_torrentInfo( tr_torrent_t * );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentScrape
|
|
|
|
***********************************************************************
|
|
|
|
* Asks the tracker for the count of seeders and leechers. Returns 0
|
|
|
|
* and fills 's' and 'l' if successful. Otherwise returns 1 if the
|
|
|
|
* tracker doesn't support the scrape protocol, is unreachable or
|
|
|
|
* replied with some error. tr_torrentScrape may block up to 20 seconds
|
|
|
|
* before returning.
|
|
|
|
**********************************************************************/
|
2006-12-02 01:46:54 +00:00
|
|
|
int tr_torrentScrape( tr_torrent_t *, int * s, int * l, int * d );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-05-11 18:56:59 +00:00
|
|
|
void tr_torrentSetFolder( tr_torrent_t *, const char * );
|
|
|
|
char * tr_torrentGetFolder( tr_torrent_t * );
|
|
|
|
|
|
|
|
int tr_torrentDuplicateDownload( tr_torrent_t * tor );
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentStart
|
|
|
|
***********************************************************************
|
|
|
|
* Starts downloading. The download is launched in a seperate thread,
|
|
|
|
* therefore tr_torrentStart returns immediately.
|
|
|
|
**********************************************************************/
|
|
|
|
void tr_torrentStart( tr_torrent_t * );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentStop
|
|
|
|
***********************************************************************
|
|
|
|
* Stops downloading and notices the tracker that we are leaving. The
|
|
|
|
* thread keeps running while doing so.
|
|
|
|
* The thread will eventually be joined, either:
|
|
|
|
* - by tr_torrentStat when the tracker has been successfully noticed,
|
|
|
|
* - by tr_torrentStat if the tracker could not be noticed within 60s,
|
|
|
|
* - by tr_torrentClose if you choose to remove the torrent without
|
|
|
|
* waiting any further.
|
|
|
|
**********************************************************************/
|
|
|
|
void tr_torrentStop( tr_torrent_t * );
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_getFinished
|
|
|
|
***********************************************************************
|
|
|
|
* The first call after a torrent is completed returns 1. Returns 0
|
|
|
|
* in other cases.
|
|
|
|
**********************************************************************/
|
|
|
|
int tr_getFinished( tr_torrent_t * );
|
|
|
|
|
2006-12-26 18:40:51 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_manualUpdate
|
|
|
|
***********************************************************************
|
|
|
|
* Reannounce to tracker regardless of wait interval
|
|
|
|
**********************************************************************/
|
|
|
|
void tr_manualUpdate( tr_torrent_t * );
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentStat
|
|
|
|
***********************************************************************
|
|
|
|
* Returns a pointer to an tr_stat_t structure with updated information
|
|
|
|
* on the torrent. The structure belongs to libtransmission (do not
|
|
|
|
* free it) and is guaranteed to be unchanged until the next call to
|
|
|
|
* tr_torrentStat.
|
|
|
|
* The interface should call this function every second or so in order
|
|
|
|
* to update itself.
|
|
|
|
**********************************************************************/
|
|
|
|
typedef struct tr_stat_s tr_stat_t;
|
|
|
|
tr_stat_t * tr_torrentStat( tr_torrent_t * );
|
|
|
|
|
2006-08-13 21:16:18 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentPeers
|
|
|
|
***********************************************************************/
|
|
|
|
typedef struct tr_peer_stat_s tr_peer_stat_t;
|
|
|
|
tr_peer_stat_t * tr_torrentPeers( tr_torrent_t *, int * peerCount );
|
2006-08-13 21:24:23 +00:00
|
|
|
void tr_torrentPeersFree( tr_peer_stat_t *, int peerCount );
|
2006-08-13 21:16:18 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentAvailability
|
|
|
|
***********************************************************************
|
|
|
|
* Use this to draw an advanced progress bar which is 'size' pixels
|
|
|
|
* wide. Fills 'tab' which you must have allocated: each byte is set
|
|
|
|
* to either -1 if we have the piece, otherwise it is set to the number
|
|
|
|
* of connected peers who have the piece.
|
|
|
|
**********************************************************************/
|
|
|
|
void tr_torrentAvailability( tr_torrent_t *, int8_t * tab, int size );
|
|
|
|
|
2006-10-13 00:23:20 +00:00
|
|
|
void tr_torrentAmountFinished( tr_torrent_t * tor, float * tab, int size );
|
2006-10-12 23:34:20 +00:00
|
|
|
|
2007-02-23 11:26:48 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentCompletion
|
|
|
|
***********************************************************************
|
|
|
|
* Returns the completion progress for each file in the torrent as an
|
|
|
|
* array of floats the same size and order as in tr_info_t. Free the
|
|
|
|
* array when done.
|
|
|
|
**********************************************************************/
|
|
|
|
float * tr_torrentCompletion( tr_torrent_t * tor );
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentRemoveSaved
|
|
|
|
***********************************************************************
|
2007-01-27 22:37:10 +00:00
|
|
|
* Removes the saved copy of a torrent file for torrents which the
|
|
|
|
* TR_FLAG_SAVE flag is set.
|
2006-07-16 19:39:23 +00:00
|
|
|
**********************************************************************/
|
|
|
|
void tr_torrentRemoveSaved( tr_torrent_t * );
|
|
|
|
|
2007-04-28 01:34:39 +00:00
|
|
|
void tr_torrentRemoveFastResume( tr_torrent_t * tor );
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* tr_torrentClose
|
|
|
|
***********************************************************************
|
|
|
|
* Frees memory allocated by tr_torrentInit. If the torrent was running,
|
|
|
|
* you must call tr_torrentStop() before closing it.
|
|
|
|
**********************************************************************/
|
2007-05-23 04:45:20 +00:00
|
|
|
void tr_torrentClose( tr_torrent_t * );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_info_s
|
|
|
|
**********************************************************************/
|
|
|
|
typedef struct tr_file_s
|
|
|
|
{
|
|
|
|
uint64_t length; /* Length of the file, in bytes */
|
|
|
|
char name[MAX_PATH_LENGTH]; /* Path to the file */
|
|
|
|
}
|
|
|
|
tr_file_t;
|
|
|
|
struct tr_info_s
|
|
|
|
{
|
|
|
|
/* Path to torrent */
|
2006-12-17 16:36:27 +00:00
|
|
|
char torrent[MAX_PATH_LENGTH];
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* General info */
|
2006-12-17 16:36:27 +00:00
|
|
|
uint8_t hash[SHA_DIGEST_LENGTH];
|
|
|
|
char hashString[2*SHA_DIGEST_LENGTH+1];
|
|
|
|
char name[MAX_PATH_LENGTH];
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Flags */
|
2007-01-27 22:37:10 +00:00
|
|
|
#define TR_FLAG_SAVE 0x01 /* save a copy of the torrent file */
|
|
|
|
#define TR_FLAG_PRIVATE 0x02 /* do not share information for this torrent */
|
2006-12-17 16:36:27 +00:00
|
|
|
int flags;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Tracker info */
|
2006-12-17 16:36:27 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
tr_tracker_info_t * list;
|
|
|
|
int count;
|
|
|
|
} * trackerList;
|
|
|
|
int trackerTiers;
|
|
|
|
|
2006-11-23 01:38:18 +00:00
|
|
|
/* Torrent info */
|
2006-12-17 16:36:27 +00:00
|
|
|
char comment[MAX_PATH_LENGTH];
|
|
|
|
char creator[MAX_PATH_LENGTH];
|
|
|
|
int dateCreated;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Pieces info */
|
2006-12-17 16:36:27 +00:00
|
|
|
int pieceSize;
|
|
|
|
int pieceCount;
|
|
|
|
uint64_t totalSize;
|
|
|
|
uint8_t * pieces;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
/* Files info */
|
2006-12-17 16:36:27 +00:00
|
|
|
int multifile;
|
|
|
|
int fileCount;
|
|
|
|
tr_file_t * files;
|
2006-07-16 19:39:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_stat_s
|
|
|
|
**********************************************************************/
|
|
|
|
struct tr_stat_s
|
|
|
|
{
|
2007-05-28 15:23:28 +00:00
|
|
|
#define TR_STATUS_CHECK_WAIT 0x001 /* Waiting in queue to check files */
|
|
|
|
#define TR_STATUS_CHECK 0x002 /* Checking files */
|
|
|
|
#define TR_STATUS_DOWNLOAD 0x004 /* Downloading */
|
|
|
|
#define TR_STATUS_SEED 0x008 /* Seeding */
|
|
|
|
#define TR_STATUS_STOPPING 0x010 /* Sending 'stopped' to the tracker */
|
|
|
|
#define TR_STATUS_STOPPED 0x020 /* Sent 'stopped' but thread still
|
2006-07-16 19:39:23 +00:00
|
|
|
running (for internal use only) */
|
2007-05-28 15:23:28 +00:00
|
|
|
#define TR_STATUS_PAUSE 0x040 /* Paused */
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-05-28 15:23:28 +00:00
|
|
|
#define TR_STATUS_ACTIVE (TR_STATUS_CHECK_WAIT|TR_STATUS_CHECK|TR_STATUS_DOWNLOAD|TR_STATUS_SEED)
|
2006-07-16 19:39:23 +00:00
|
|
|
#define TR_STATUS_INACTIVE (TR_STATUS_STOPPING|TR_STATUS_STOPPED|TR_STATUS_PAUSE)
|
2006-08-13 19:43:15 +00:00
|
|
|
int status;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2006-08-13 19:43:15 +00:00
|
|
|
int error;
|
2007-01-14 12:00:21 +00:00
|
|
|
char errorString[128];
|
2006-12-17 16:36:27 +00:00
|
|
|
int cannotConnect;
|
2007-02-27 04:00:38 +00:00
|
|
|
|
|
|
|
tr_tracker_info_t * tracker;
|
2006-08-13 19:43:15 +00:00
|
|
|
|
|
|
|
float progress;
|
|
|
|
float rateDownload;
|
|
|
|
float rateUpload;
|
|
|
|
int eta;
|
|
|
|
int peersTotal;
|
2007-03-23 08:28:01 +00:00
|
|
|
int peersFrom[TR_PEER_FROM__MAX];
|
2006-08-13 19:43:15 +00:00
|
|
|
int peersUploading;
|
|
|
|
int peersDownloading;
|
|
|
|
int seeders;
|
|
|
|
int leechers;
|
2006-12-02 01:46:54 +00:00
|
|
|
int completedFromTracker;
|
2006-08-13 19:43:15 +00:00
|
|
|
|
2007-04-04 00:55:53 +00:00
|
|
|
uint64_t left;
|
2006-08-13 19:43:15 +00:00
|
|
|
uint64_t downloaded;
|
|
|
|
uint64_t uploaded;
|
2006-08-16 19:21:09 +00:00
|
|
|
float swarmspeed;
|
2006-12-30 19:24:09 +00:00
|
|
|
|
|
|
|
#define TR_RATIO_NA -1
|
|
|
|
float ratio;
|
2007-05-25 19:14:42 +00:00
|
|
|
|
|
|
|
uint64_t startDate;
|
|
|
|
uint64_t activityDate;
|
2006-07-16 19:39:23 +00:00
|
|
|
};
|
|
|
|
|
2006-08-13 21:16:18 +00:00
|
|
|
struct tr_peer_stat_s
|
|
|
|
{
|
2006-08-14 22:42:32 +00:00
|
|
|
char addr[INET_ADDRSTRLEN];
|
2007-04-03 18:22:58 +00:00
|
|
|
const char * client;
|
2006-08-13 21:16:18 +00:00
|
|
|
|
2006-08-15 00:59:44 +00:00
|
|
|
int isConnected;
|
2007-03-23 08:28:01 +00:00
|
|
|
int from;
|
2006-11-10 04:21:46 +00:00
|
|
|
float progress;
|
2006-12-18 03:45:22 +00:00
|
|
|
int port;
|
2006-12-18 05:04:35 +00:00
|
|
|
|
|
|
|
int isDownloading;
|
|
|
|
int isUploading;
|
2006-12-18 06:16:27 +00:00
|
|
|
float downloadFromRate;
|
|
|
|
float uploadToRate;
|
2006-08-13 21:16:18 +00:00
|
|
|
};
|
|
|
|
|
2006-08-22 02:12:58 +00:00
|
|
|
struct tr_msg_list_s
|
|
|
|
{
|
|
|
|
int level;
|
2006-08-22 02:32:46 +00:00
|
|
|
time_t when;
|
2006-08-22 02:12:58 +00:00
|
|
|
char * message;
|
|
|
|
struct tr_msg_list_s * next;
|
|
|
|
};
|
|
|
|
|
2006-12-17 16:36:27 +00:00
|
|
|
struct tr_tracker_info_s
|
|
|
|
{
|
|
|
|
char * address;
|
|
|
|
int port;
|
|
|
|
char * announce;
|
2007-02-27 04:00:38 +00:00
|
|
|
char * scrape;
|
2006-12-17 16:36:27 +00:00
|
|
|
};
|
|
|
|
|
2007-02-06 04:26:40 +00:00
|
|
|
struct tr_handle_status_s
|
|
|
|
{
|
|
|
|
#define TR_NAT_TRAVERSAL_MAPPING 1
|
|
|
|
#define TR_NAT_TRAVERSAL_MAPPED 2
|
|
|
|
#define TR_NAT_TRAVERSAL_NOTFOUND 3
|
|
|
|
#define TR_NAT_TRAVERSAL_ERROR 4
|
|
|
|
#define TR_NAT_TRAVERSAL_UNMAPPING 5
|
|
|
|
#define TR_NAT_TRAVERSAL_DISABLED 6
|
|
|
|
#define TR_NAT_TRAVERSAL_IS_DISABLED( st ) \
|
|
|
|
( TR_NAT_TRAVERSAL_DISABLED == (st) || TR_NAT_TRAVERSAL_UNMAPPING == (st) )
|
|
|
|
int natTraversalStatus;
|
|
|
|
int publicPort;
|
|
|
|
};
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#ifdef __TRANSMISSION__
|
|
|
|
# include "internal.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|