source: branches/1.5x/libtransmission/makemeta.h @ 8204

Last change on this file since 8204 was 8204, checked in by charles, 13 years ago

(1.5x libT) various backports for 1.52:
(1) recognize Aria2 as a client
(2) remove jhujhiti's tr_suspectAddress(), since he removed it from trunka
(3) on Mac, better detection of where the Web UI files are located
(4) reintroduce the web task queue
(5) various minor formatting changes to reduce the diffs between 1.52 and trunk

  • Property svn:keywords set to Date Rev Author Id
File size: 3.6 KB
Line 
1/*
2 * This file Copyright (C) 2007-2009 Charles Kerr <charles@transmissionbt.com>
3 *
4 * This file is licensed by the GPL version 2.  Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id: makemeta.h 8204 2009-04-10 17:34:25Z charles $
11 */
12
13#ifndef TR_MAKEMETA_H
14#define TR_MAKEMETA_H 1
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20typedef struct tr_metainfo_builder_file
21{
22    char *      filename;
23    uint64_t    size;
24}
25tr_metainfo_builder_file;
26
27typedef enum
28{
29    TR_MAKEMETA_OK,
30    TR_MAKEMETA_URL,
31    TR_MAKEMETA_CANCELLED,
32    TR_MAKEMETA_IO_READ,   /* see builder.errfile, builder.errno */
33    TR_MAKEMETA_IO_WRITE   /* see builder.errfile, builder.errno */
34}
35tr_metainfo_builder_err;
36
37
38typedef struct tr_metainfo_builder
39{
40    /**
41    ***  These are set by tr_makeMetaInfoBuilderCreate()
42    ***  and cleaned up by tr_metaInfoBuilderFree()
43    **/
44
45    char *                      top;
46    tr_metainfo_builder_file *  files;
47    uint64_t                    totalSize;
48    uint32_t                    fileCount;
49    uint32_t                    pieceSize;
50    uint32_t                    pieceCount;
51    int                         isSingleFile;
52    tr_session *                handle;
53
54    /**
55    ***  These are set inside tr_makeMetaInfo()
56    ***  by copying the arguments passed to it,
57    ***  and cleaned up by tr_metaInfoBuilderFree()
58    **/
59
60    tr_tracker_info *  trackers;
61    int                trackerCount;
62    char *             comment;
63    char *             outputFile;
64    int                isPrivate;
65
66    /**
67    ***  These are set inside tr_makeMetaInfo() so the client
68    ***  can poll periodically to see what the status is.
69    ***  The client can also set abortFlag to nonzero to
70    ***  tell tr_makeMetaInfo() to abort and clean up after itself.
71    **/
72
73    uint32_t                   pieceIndex;
74    int                        abortFlag;
75    int                        isDone;
76    tr_metainfo_builder_err    result;
77
78    /* file in use when result was set to _IO_READ or _IO_WRITE */
79    char    errfile[2048];
80
81    /* errno encountered when result was set to _IO_READ or _IO_WRITE */
82    int    my_errno;
83
84    /**
85    ***  This is an implementation detail.
86    ***  The client should never use these fields.
87    **/
88
89    struct tr_metainfo_builder * nextBuilder;
90}
91tr_metainfo_builder;
92
93
94tr_metainfo_builder*tr_metaInfoBuilderCreate( tr_session * session,
95                                              const char * topFile );
96
97void                tr_metaInfoBuilderFree( tr_metainfo_builder* );
98
99/**
100 * @brief create a new .torrent file
101 *
102 * This is actually done in a worker thread, not the main thread!
103 * Otherwise the client's interface would lock up while this runs.
104 *
105 * It is the caller's responsibility to poll builder->isDone
106 * from time to time!  When the worker thread sets that flag,
107 * the caller must pass the builder to tr_metaInfoBuilderFree().
108 *
109 * @param outputFile if NULL, builder->top + ".torrent" will be used.
110
111 * @param trackers An array of trackers, sorted by tier from first to last.
112 *                 NOTE: only the `tier' and `announce' fields are used.
113 *
114 * @param trackerCount size of the `trackers' array
115 */
116void tr_makeMetaInfo( tr_metainfo_builder *   builder,
117                      const char *            outputFile,
118                      const tr_tracker_info * trackers,
119                      int                     trackerCount,
120                      const char *            comment,
121                      int                     isPrivate );
122
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif
Note: See TracBrowser for help on using the repository browser.