~ubuntu-branches/ubuntu/hardy/transmission/hardy-updates

« back to all changes in this revision

Viewing changes to libtransmission/internal.h

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Benner
  • Date: 2008-01-05 09:16:52 UTC
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20080105091652-8cf0z4rb3pu8d6jt
Tags: upstream-1.00
ImportĀ upstreamĀ versionĀ 1.00

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: internal.h 4037 2007-12-02 01:27:14Z charles $
 
2
 * $Id: internal.h 4404 2008-01-01 17:20:20Z charles $
3
3
 *
4
 
 * Copyright (c) 2005-2007 Transmission authors and contributors
 
4
 * Copyright (c) 2005-2008 Transmission authors and contributors
5
5
 *
6
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
7
 * copy of this software and associated documentation files (the "Software"),
43
43
#define FALSE 0
44
44
#endif
45
45
 
46
 
int tr_torrentIsPrivate( const tr_torrent * );
47
 
 
48
 
void tr_torrentRecheckCompleteness( tr_torrent * );
49
 
 
50
46
int tr_trackerInfoInit( struct tr_tracker_info  * info,
51
47
                        const char              * address,
52
48
                        int                       address_len );
55
51
 
56
52
void tr_peerIdNew ( char* buf, int buflen );
57
53
 
58
 
void tr_torrentResetTransferStats( tr_torrent * );
59
 
 
60
 
void tr_torrentSetHasPiece( tr_torrent * tor, int pieceIndex, int has );
61
 
 
62
 
void tr_torrentLock    ( const tr_torrent * );
63
 
void tr_torrentUnlock  ( const tr_torrent * );
64
 
 
65
 
int  tr_torrentIsSeed  ( const tr_torrent * );
66
 
 
67
 
void tr_torrentChangeMyPort  ( tr_torrent * );
68
 
 
69
 
int tr_torrentExists( tr_handle *, const uint8_t * );
70
 
tr_torrent* tr_torrentFindFromHash( tr_handle *, const uint8_t * );
71
 
tr_torrent* tr_torrentFindFromObfuscatedHash( tr_handle *, const uint8_t* );
72
 
 
73
 
void tr_torrentGetRates( const tr_torrent *, float * toClient, float * toPeer );
74
 
 
75
 
/* get the index of this piece's first block */
76
 
#define tr_torPieceFirstBlock(tor,piece) ( (piece) * (tor)->blockCountInPiece )
77
 
 
78
 
/* what piece index is this block in? */
79
 
#define tr_torBlockPiece(tor,block) ( (block) / (tor)->blockCountInPiece )
80
 
 
81
 
/* how many blocks are in this piece? */
82
 
#define tr_torPieceCountBlocks(tor,piece) \
83
 
    ( ((piece)==((tor)->info.pieceCount-1)) ? (tor)->blockCountInLastPiece : (tor)->blockCountInPiece )
84
 
 
85
 
/* how many bytes are in this piece? */
86
 
#define tr_torPieceCountBytes(tor,piece) \
87
 
    ( ((piece)==((tor)->info.pieceCount-1)) ? (tor)->lastPieceSize : (tor)->info.pieceSize )
88
 
 
89
 
/* how many bytes are in this block? */
90
 
#define tr_torBlockCountBytes(tor,block) \
91
 
    ( ((block)==((tor)->blockCount-1)) ? (tor)->lastBlockSize : (tor)->blockSize )
92
 
 
93
 
#define tr_block(a,b) _tr_block(tor,a,b)
94
 
int _tr_block( const tr_torrent * tor, int index, int begin );
95
 
 
96
 
uint64_t tr_pieceOffset( const tr_torrent * tor, int index, int begin, int length );
97
 
 
98
 
typedef enum
99
 
{
100
 
   TR_RECHECK_NONE,
101
 
   TR_RECHECK_WAIT,
102
 
   TR_RECHECK_NOW
103
 
}
104
 
tr_recheck_state;
105
 
 
106
 
#define TR_ID_LEN  20
107
 
 
108
 
struct tr_torrent
109
 
{
110
 
    tr_handle                 * handle;
111
 
    tr_info                     info;
112
 
 
113
 
    tr_speedlimit               uploadLimitMode;
114
 
    tr_speedlimit               downloadLimitMode;
115
 
    struct tr_ratecontrol     * upload;
116
 
    struct tr_ratecontrol     * download;
117
 
    struct tr_ratecontrol     * swarmspeed;
118
 
 
119
 
    int                        error;
120
 
    char                       errorString[128];
121
 
 
122
 
    uint8_t                    obfuscatedHash[SHA_DIGEST_LENGTH];
123
 
 
124
 
    /* Where to download */
125
 
    char                     * destination;
126
 
    
127
 
    /* How many bytes we ask for per request */
128
 
    int                        blockSize;
129
 
    int                        blockCount;
130
 
 
131
 
    int                        lastBlockSize;
132
 
    int                        lastPieceSize;
133
 
 
134
 
    int                        blockCountInPiece;
135
 
    int                        blockCountInLastPiece;
136
 
    
137
 
    struct tr_completion     * completion;
138
 
 
139
 
    struct tr_bitfield       * uncheckedPieces;
140
 
    cp_status_t                cpStatus;
141
 
 
142
 
    struct tr_tracker        * tracker;
143
 
    struct tr_publisher_tag  * trackerSubscription;
144
 
 
145
 
    uint64_t                   downloadedCur;
146
 
    uint64_t                   downloadedPrev;
147
 
    uint64_t                   uploadedCur;
148
 
    uint64_t                   uploadedPrev;
149
 
    uint64_t                   corruptCur;
150
 
    uint64_t                   corruptPrev;
151
 
 
152
 
    uint64_t                   startDate;
153
 
    uint64_t                   stopDate;
154
 
    uint64_t                   activityDate;
155
 
 
156
 
    tr_torrent_status_func   * status_func;
157
 
    void                     * status_func_user_data;
158
 
 
159
 
    unsigned int               pexDisabled : 1;
160
 
    unsigned int               statCur : 1;
161
 
    unsigned int               isRunning : 1;
162
 
 
163
 
    tr_recheck_state           recheckState;
164
 
 
165
 
    tr_stat                    stats[2];
166
 
 
167
 
    tr_torrent               * next;
168
 
};
169
 
 
170
54
struct tr_handle
171
55
{
172
56
    tr_encryption_mode         encryptionMode;
177
61
    tr_torrent               * torrentList;
178
62
 
179
63
    char                     * tag;
180
 
    int                        isPortSet;
 
64
    unsigned int               isPortSet : 1;
 
65
    unsigned int               isPexEnabled : 1;
181
66
 
182
67
    char                       useUploadLimit;
183
68
    char                       useDownloadLimit;
202
87
void tr_globalUnlock     ( struct tr_handle * );
203
88
int  tr_globalIsLocked   ( const struct tr_handle * );
204
89
 
205
 
 
206
90
#endif